|
|
|
@ -15,36 +15,61 @@ admin = @conf['admin']
|
|
|
|
|
@auth_chat = @conf['authorized_chats']
|
|
|
|
|
@allowed_sources = @conf['allowed_sources']
|
|
|
|
|
|
|
|
|
|
# Sanity check
|
|
|
|
|
### Begin sanity check ###
|
|
|
|
|
errcount = 0
|
|
|
|
|
puts "Checking if environment is sane...\n\n"
|
|
|
|
|
print "Checking for presence of a bot token .... "
|
|
|
|
|
if token.nil?
|
|
|
|
|
print "FAIL!\n\n"
|
|
|
|
|
puts "No bot token defined in bot_config.yaml!\nTHIS IS REQUIRED! Bot initialization failed; exiting..."
|
|
|
|
|
exit(1)
|
|
|
|
|
else
|
|
|
|
|
print "OK!\n"
|
|
|
|
|
end
|
|
|
|
|
print "Checking for defined bot name ........... "
|
|
|
|
|
if @botname.nil?
|
|
|
|
|
errcount += 1
|
|
|
|
|
print "FAIL!\n\n"
|
|
|
|
|
puts "Error(#{errcount.to_s}): No bot name defined. This is superficial. We'll call him Bob.\n\n"
|
|
|
|
|
@botname = "Bob"
|
|
|
|
|
else
|
|
|
|
|
print "OK!\n"
|
|
|
|
|
end
|
|
|
|
|
print "Checking for telnet configuration ....... "
|
|
|
|
|
if telnet.nil?
|
|
|
|
|
errcount += 1
|
|
|
|
|
print "FAIL!\n\n"
|
|
|
|
|
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"
|
|
|
|
|
else
|
|
|
|
|
print "OK!\n"
|
|
|
|
|
end
|
|
|
|
|
print "Checking for administrators ............. "
|
|
|
|
|
if admin.nil?
|
|
|
|
|
errcount += 1
|
|
|
|
|
print "FAIL!\n\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"
|
|
|
|
|
admin = ["0"]
|
|
|
|
|
else
|
|
|
|
|
print "OK!\n"
|
|
|
|
|
end
|
|
|
|
|
print "Checking for authorised chats ........... "
|
|
|
|
|
if @auth_chat.nil?
|
|
|
|
|
errcount += 1
|
|
|
|
|
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"
|
|
|
|
|
@auth_chat = ["0"]
|
|
|
|
|
else
|
|
|
|
|
print "OK!\n"
|
|
|
|
|
end
|
|
|
|
|
puts "Errors found: #{errcount.to_s}\n\n"
|
|
|
|
|
if errcount > 0
|
|
|
|
|
print "Environment is grinning and holding a spatula. Please review your configuration.\n\n"
|
|
|
|
|
else
|
|
|
|
|
print "Environment appears sane.\n\n"
|
|
|
|
|
end
|
|
|
|
|
### End sanity check ###
|
|
|
|
|
|
|
|
|
|
puts "Starting [#{@botname}]...\n\n"
|
|
|
|
|
puts "Empyrion Host: #{telnet['host']}"
|
|
|
|
|