|
|
|
@ -13,26 +13,26 @@ def message_from_admin?(message, adm)
|
|
|
|
|
#puts message.from.id
|
|
|
|
|
#puts adm
|
|
|
|
|
if adm.include?(message.from.id)
|
|
|
|
|
puts "Command is from an admin. [#{message.from.username}]"
|
|
|
|
|
puts "Command is from an admin. [" + "#{message.from.username}".cyan.bold + "]"
|
|
|
|
|
return true
|
|
|
|
|
else
|
|
|
|
|
puts "Command is NOT from an admin! [#{message.from.username}]"
|
|
|
|
|
puts "Command is NOT from an admin! [" + "#{message.from.username}".yellow.bold + "]"
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def is_chat_authorized?(message, auth_chat)
|
|
|
|
|
if auth_chat.include?(message.chat.id)
|
|
|
|
|
puts "Group [#{message.chat.id}][#{message.chat.title}] is authorized"
|
|
|
|
|
puts "Group [" + "#{message.chat.id}".green.bold + "][" + "#{message.chat.title}".green + "] is authorized"
|
|
|
|
|
return true
|
|
|
|
|
else
|
|
|
|
|
puts "Group [#{message.chat.id}][#{message.chat.title}] is NOT authorized!"
|
|
|
|
|
puts "Group [" + "#{message.chat.id}".red.bold + "][" + "#{message.chat.title}".red + "] is NOT authorized!"
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def process_command_srvstart(message, command, adm)
|
|
|
|
|
puts "Received command: srvstart"
|
|
|
|
|
puts "Received command: " + "srvstart".green
|
|
|
|
|
#pp message
|
|
|
|
|
from_admin = message_from_admin?(message, adm)
|
|
|
|
|
auth_grp = is_chat_authorized?(message, @auth_chat)
|
|
|
|
@ -52,7 +52,7 @@ def process_command_srvstart(message, command, adm)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def process_command_srvstop(message, command, adm)
|
|
|
|
|
puts "Received command: srvstop"
|
|
|
|
|
puts "Received command: " + "srvstop".red
|
|
|
|
|
from_admin = message_from_admin?(message, adm)
|
|
|
|
|
auth_grp = is_chat_authorized?(message, @auth_chat)
|
|
|
|
|
if ! auth_grp && ! from_admin
|
|
|
|
@ -79,11 +79,11 @@ def process_command_srvstatus(message, command, adm)
|
|
|
|
|
if `./scripts/srvstatus.receipt #{@conf['token']} #{message.chat.id}`
|
|
|
|
|
print "Receipt sent!\nFetching details...\n"
|
|
|
|
|
else
|
|
|
|
|
print "Receipt FAILED to send (non-zero exit code on scripts/srvstatus.receipt) !!!\nContinuing to fetch details anyway...\n"
|
|
|
|
|
print "Receipt FAILED to send (non-zero exit code on scripts/srvstatus.receipt) !!!\nContinuing to fetch details anyway...\n".red.bold
|
|
|
|
|
end
|
|
|
|
|
reply = `./scripts/srvstatus #{telnet['host']} #{telnet['port']} #{telnet['pass']}`
|
|
|
|
|
else
|
|
|
|
|
print "Server did not respond!\nSending failure message...\n"
|
|
|
|
|
print "Server did not respond!\nSending failure message...\n".red.bold
|
|
|
|
|
reply = "Server is not responding!"
|
|
|
|
|
end
|
|
|
|
|
STDOUT.flush
|
|
|
|
|