parent
4c03a0952b
commit
dd98e97d1b
@ -0,0 +1,65 @@
|
|||||||
|
def message_from_admin?(message, adm)
|
||||||
|
#return @admin_userids.include? message.from.id.to_s
|
||||||
|
#puts adm.class
|
||||||
|
#puts message.from.id
|
||||||
|
#puts adm
|
||||||
|
if adm.include?(message.from.id)
|
||||||
|
puts "Command is from an admin. [#{message.from.username}]"
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
puts "Command is NOT from an admin! [#{message.from.username}]"
|
||||||
|
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"
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
puts "Group [#{message.chat.id}][#{message.chat.title}] is NOT authorized!"
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def process_command_srvstart(message, command, adm)
|
||||||
|
puts "Received command: srvstart"
|
||||||
|
#pp message
|
||||||
|
if ! message_from_admin?(message, adm)
|
||||||
|
####if ! message.from.username.nil?
|
||||||
|
#### message.from.username = "@" + message.from.username
|
||||||
|
####elsif ! message.from.first_name.nil?
|
||||||
|
#### message.from.username = message.from.first_name
|
||||||
|
####end
|
||||||
|
#return "#{message.from.username} is not an admin!"
|
||||||
|
return "Refusal: The meatbag #{message.from.username} is not my master."
|
||||||
|
elsif message_from_admin?(message, adm) && ! is_chat_authorized?(message, @auth_chat)
|
||||||
|
return "Refusal: Although I respect your wishes, master, I am not authorized to perform this function for this group."
|
||||||
|
else
|
||||||
|
telnet = @conf['telnet']
|
||||||
|
puts `./srvstart #{telnet['host']}`
|
||||||
|
#return "Starting up the Empyrion service."
|
||||||
|
return "This function is currently broken. An attempt was made, but odds are against the server having actually started.\n\n" +
|
||||||
|
"Use /status for more info."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def process_command_srvstop(message, command, adm)
|
||||||
|
puts "Received command: srvstop"
|
||||||
|
if ! message_from_admin?(message, adm)
|
||||||
|
####if ! message.from.username.nil?
|
||||||
|
#### message.from.username = "@" + message.from.username
|
||||||
|
####elsif ! message.from.first_name.nil?
|
||||||
|
#### message.from.username = message.from.first_name
|
||||||
|
####end
|
||||||
|
#return "#{message.from.username} is not an admin!"
|
||||||
|
return "Refusal: The meatbag #{message.from.username} is not my master."
|
||||||
|
elsif message_from_admin?(message, adm) && ! is_chat_authorized?(message, @auth_chat)
|
||||||
|
return "Refusal: Although I respect your wishes, master, I am not authorized to perform this function for this group."
|
||||||
|
else
|
||||||
|
telnet = @conf['telnet']
|
||||||
|
`./srvstop #{telnet['host']} #{telnet['port']} #{telnet['pass']}`
|
||||||
|
return "Affirmation: I am shutting down the Empyrion service."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in new issue