|
|
@ -5,6 +5,7 @@ require 'yaml'
|
|
|
|
require 'telegram/bot'
|
|
|
|
require 'telegram/bot'
|
|
|
|
require 'pp'
|
|
|
|
require 'pp'
|
|
|
|
require_relative 'commands.rb'
|
|
|
|
require_relative 'commands.rb'
|
|
|
|
|
|
|
|
require_relative 'colors.rb'
|
|
|
|
|
|
|
|
|
|
|
|
#conf = YAML.load(File.read("bot_config.yaml"))
|
|
|
|
#conf = YAML.load(File.read("bot_config.yaml"))
|
|
|
|
@conf = YAML.load_file("bot_config.yaml")
|
|
|
|
@conf = YAML.load_file("bot_config.yaml")
|
|
|
@ -18,56 +19,57 @@ admin = @conf['admin']
|
|
|
|
### Begin sanity check ###
|
|
|
|
### Begin sanity check ###
|
|
|
|
errcount = 0
|
|
|
|
errcount = 0
|
|
|
|
puts "Checking if environment is sane...\n\n"
|
|
|
|
puts "Checking if environment is sane...\n\n"
|
|
|
|
print "Checking for presence of a bot token .... "
|
|
|
|
print "Checking bot token ...................... "
|
|
|
|
if token.nil?
|
|
|
|
if token.nil?
|
|
|
|
print "FAIL!\n\n"
|
|
|
|
print "FAIL!\n\n".red.bold
|
|
|
|
puts "No bot token defined in bot_config.yaml!\nTHIS IS REQUIRED! Bot initialization failed; exiting..."
|
|
|
|
puts "No bot token defined in bot_config.yaml!\nTHIS IS REQUIRED! Bot initialization failed; exiting..."
|
|
|
|
exit(1)
|
|
|
|
exit(1)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
print "OK!\n"
|
|
|
|
print "OK\n".green.bold
|
|
|
|
end
|
|
|
|
end
|
|
|
|
print "Checking for defined bot name ........... "
|
|
|
|
print "Checking configured bot name ............ "
|
|
|
|
if @botname.nil?
|
|
|
|
if @botname.nil?
|
|
|
|
errcount += 1
|
|
|
|
errcount += 1
|
|
|
|
print "FAIL!\n\n"
|
|
|
|
print "FAIL!\n\n".red.bold
|
|
|
|
puts "Error(#{errcount.to_s}): No bot name defined. This is superficial. We'll call him Bob.\n\n"
|
|
|
|
puts "Error(#{errcount.to_s}): No bot name defined. This is superficial. We'll call him Bob.\n\n"
|
|
|
|
@botname = "Bob"
|
|
|
|
@botname = "Bob"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
print "OK!\n"
|
|
|
|
print "OK\n".green.bold
|
|
|
|
end
|
|
|
|
end
|
|
|
|
print "Checking for telnet configuration ....... "
|
|
|
|
print "Checking telnet configuration ........... "
|
|
|
|
if telnet.nil?
|
|
|
|
if telnet.nil?
|
|
|
|
errcount += 1
|
|
|
|
errcount += 1
|
|
|
|
print "FAIL!\n\n"
|
|
|
|
print "FAIL!\n\n".red.bold
|
|
|
|
puts "Error(#{errcount.to_s}): No telnet information provided in bot_config.yaml.\nThis is required for nearly all Empyrion-related " +
|
|
|
|
puts "Error(#{errcount.to_s}): No telnet information provided in bot_config.yaml.\nThis is required for nearly all Empyrion-related " +
|
|
|
|
"functions.\nTHIS SHOULD BE ADDRESSED. Continuing. (some commands will return broken messages)\n\n"
|
|
|
|
"functions.\nTHIS SHOULD BE ADDRESSED. Continuing. (some commands will return broken messages)\n\n"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
print "OK!\n"
|
|
|
|
print "OK\n".green.bold
|
|
|
|
end
|
|
|
|
end
|
|
|
|
print "Checking for administrators ............. "
|
|
|
|
print "Checking administrators ................. "
|
|
|
|
if admin.nil?
|
|
|
|
if admin.nil?
|
|
|
|
errcount += 1
|
|
|
|
errcount += 1
|
|
|
|
print "FAIL!\n\n"
|
|
|
|
print "FAIL!\n\n".red.bold
|
|
|
|
puts "Error(#{errcount.to_s}): No admin Telegram IDs provided in bot_config.yaml.\nThis is required for many functions.\n" +
|
|
|
|
puts "Error(#{errcount.to_s}): No admin Telegram IDs provided in bot_config.yaml.\nThis is required for many functions.\n" +
|
|
|
|
"THIS SHOULD BE ADDRESSED. Continuing. (some commands will not be available)\n\n"
|
|
|
|
"THIS SHOULD BE ADDRESSED. Continuing. (some commands will not be available)\n\n"
|
|
|
|
admin = ["0"]
|
|
|
|
admin = ["0"]
|
|
|
|
else
|
|
|
|
else
|
|
|
|
print "OK!\n"
|
|
|
|
print "OK\n".green.bold
|
|
|
|
end
|
|
|
|
end
|
|
|
|
print "Checking for authorised chats ........... "
|
|
|
|
print "Checking authorised chats ............... "
|
|
|
|
if @auth_chat.nil?
|
|
|
|
if @auth_chat.nil?
|
|
|
|
errcount += 1
|
|
|
|
errcount += 1
|
|
|
|
|
|
|
|
print "FAIL!\n\n".red.bold
|
|
|
|
puts "Error(#{errcount.to_s}): No authorized Telegram group IDs provided in bot_config.yaml.\nThis is required for most Empyrion-related " +
|
|
|
|
puts "Error(#{errcount.to_s}): No authorized Telegram group IDs provided in bot_config.yaml.\nThis is required for most Empyrion-related " +
|
|
|
|
"functions.\nTHIS SHOULD BE ADDRESSED. Continuing. (some commands will not be available)\n\n"
|
|
|
|
"functions.\nTHIS SHOULD BE ADDRESSED. Continuing. (some commands will not be available)\n\n"
|
|
|
|
@auth_chat = ["0"]
|
|
|
|
@auth_chat = ["0"]
|
|
|
|
else
|
|
|
|
else
|
|
|
|
print "OK!\n"
|
|
|
|
print "OK\n".green.bold
|
|
|
|
end
|
|
|
|
end
|
|
|
|
puts "Errors found: #{errcount.to_s}\n\n"
|
|
|
|
puts "Errors found: #{errcount.to_s}\n\n"
|
|
|
|
if errcount > 0
|
|
|
|
if errcount > 0
|
|
|
|
print "Environment is grinning and holding a spatula. Please review your configuration.\n\n"
|
|
|
|
print "Environment is grinning and holding a spatula. Please review your configuration.\n\n".red.bold
|
|
|
|
else
|
|
|
|
else
|
|
|
|
print "Environment appears sane.\n\n"
|
|
|
|
print "Environment appears sane.\n\n".cyan.bold
|
|
|
|
end
|
|
|
|
end
|
|
|
|
### End sanity check ###
|
|
|
|
### End sanity check ###
|
|
|
|
|
|
|
|
|
|
|
|