reply="Introduction: I am #{@botname}, and I am here to make life easier for meatbag admins like you. Currently I can retrieve information "+
"from an Empyrion server as well as kill the server process. I also have some pretty sweet dance moves.\n\n"+
"Commands available:\n/start or /help (Shows this message)\n/voice or /chat (Shows voice chat info)\n/srvstart (Currently non-functional)\n/srvstop\n"+
"/status (show version and online players)\n/whoami or /chatinfo\n/whereareyou or /location\n\n"+
"Check again later to see if any new functions have been added, or use /patchnotes to learn about recent updates.\n"+
"You can also view the source code at the following location:\nhttps://git.skyfall.tech/skyfall/empyrion-bot"
ifmessage_from_admin?(message,adm)
msg_from_admin=true
end
ifis_chat_authorized?(message,@auth_chat)
chat_authorized=true
end
if!msg_from_admin&&!chat_authorized
ifmessage.from.id==message.chat.id
reply=reply+"\n\nWARNING: I am not authorized to work with you directly. My functionality is limited."
else
reply=reply+"\n\nWARNING: I am not authorized to participate with this group. My functionality is limited."
end
elsifmsg_from_admin&&!chat_authorized
reply=reply+"\n\nWARNING: Although you are my master, I have not been authorized to participate in this group. My functionality is limited."
system("rm #{@tmpdir}/test.file >/dev/null 2>&1")#Attempt to clean up anyway
returnfalse
end
end
if@tmpdir.nil?
errcount+=1
print"FAIL!\n\n".red.bold
puts"Error(#{errcount.to_s}): No temporary directory defined. Using '/tmp/.skyfall/egs-bot'.\n"
@tmpdir="/tmp/.skyfall/egs-bot"
ifis_tmp_writable?
puts"Default temporary directory is writable. Continuing...\n\n"
else
errcount+=1
puts"Error(#{errcount.to_s}): Temporary directory ["+@tmpdir.red.bold+"] is not writable!\n"+"THIS IS REQUIRED!".red.bold+" Bot initialization failed; exiting..."
exit(1)
end
else
ifis_tmp_writable?
print"OK\n".green.bold
else
errcount+=1
print"FAIL!\n\n".red.bold
puts"Error(#{errcount.to_s}): Temporary directory ["+@tmpdir.red.bold+"] is not writable!\n"+"THIS IS REQUIRED!".red.bold+" Bot initialization failed; exiting..."
exit(1)
end
end
### End tmpdir check
print"Checking telnet configuration ........... "
iftelnet.nil?
iftelnet.nil?
errcount+=1
errcount+=1
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
print"OK\n".green.bold
end
end
print"Checking administrators ................. "
ifadmin.nil?
ifadmin.nil?
errcount+=1
errcount+=1
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
print"OK\n".green.bold
end
end
print"Checking authorized 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
print"OK\n".green.bold
end
print"Checking GIF URL prefix ................. "
if@gif_url_prefix.nil?
errcount+=1
print"FAIL!\n\n".red.bold
puts"Error(#{errcount.to_s}): No GIF URL prefix provided in bot_config.yaml.\nThis is required only for a couple of Easter egg features. "+
"Using the Skyfall/Togra GIF prefix instead. Continuing.\n\n"
command=message.text.split("")[0].split("@")[0].downcase#Strip command from arguments and @tags
command=message.text.split("")[0].split("@")[0].downcase#Strip command from arguments and @tags
#command = message.text
reply='Empty String'
reply='Empty String'
#conf = YAML.load_file("bot_config.yaml")
telnet=@conf['telnet']
telnet=@conf['telnet']
adm=@conf['admin']
adm=@conf['admin']
puts"Received command from #{message.from.username}: #{command}"
putsTime.now.strftime("%F %H:%M:%S").yellow+": Received command from "+"#{message.from.username}".cyan.bold+" ["+"#{message.from.id}".cyan+"]: "+"#{command}".magenta.bold
casecommand
casecommand
when'/start'
when'/start','/help'
reply="Introduction: I am #{@botname}, and I am here to make life easier for meatbag admins like you. Currently I can retrieve information "+
process_command_start(message,command,adm)
"from an Empyrion server as well as kill the server process. I also have some pretty sweet dance moves.\n\n"+
"Commands available:\n/start (Shows this message)\n/srvstart (Currently non-functional)\n/srvstop\n/status\n/whoami or /chatinfo\n/whereareyou or /location\n\n"+
if@voice_chat_enabled=="true"
"Check again later to see if any new functions have been added, or use /patchnotes to learn about recent updates."