improved sanity check

pull/11/head
Aaron Johnson 6 years ago
parent a609084384
commit 808b22ecc1

@ -15,36 +15,61 @@ admin = @conf['admin']
@auth_chat = @conf['authorized_chats'] @auth_chat = @conf['authorized_chats']
@allowed_sources = @conf['allowed_sources'] @allowed_sources = @conf['allowed_sources']
# 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 .... "
if token.nil? if token.nil?
print "FAIL!\n\n"
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
print "OK!\n"
end end
print "Checking for defined bot name ........... "
if @botname.nil? if @botname.nil?
errcount += 1 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" puts "Error(#{errcount.to_s}): No bot name defined. This is superficial. We'll call him Bob.\n\n"
@botname = "Bob" @botname = "Bob"
else
print "OK!\n"
end end
print "Checking for telnet configuration ....... "
if telnet.nil? if telnet.nil?
errcount += 1 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 " + 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
print "OK!\n"
end end
print "Checking for administrators ............. "
if admin.nil? if admin.nil?
errcount += 1 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" + 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
print "OK!\n"
end end
print "Checking for authorised chats ........... "
if @auth_chat.nil? if @auth_chat.nil?
errcount += 1 errcount += 1
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
print "OK!\n"
end end
puts "Errors found: #{errcount.to_s}\n\n" 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 "Starting [#{@botname}]...\n\n"
puts "Empyrion Host: #{telnet['host']}" puts "Empyrion Host: #{telnet['host']}"

Loading…
Cancel
Save