optimized srvstart/srvstop permission checks

pull/2/head
Aaron Johnson 7 years ago
parent a7a88a7886
commit f6e775a759

@ -25,15 +25,13 @@ 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!"
from_admin = message_from_admin?(message, adm)
auth_grp = is_chat_authorized?(message, @auth_chat)
if ! auth_grp && ! from_admin
return "Refusal: I am not authorized to perform this function for this group, meatbag."
elsif ! from_admin
return "Refusal: The meatbag #{message.from.username} is not my master."
elsif message_from_admin?(message, adm) && ! is_chat_authorized?(message, @auth_chat)
elsif ! auth_grp
return "Refusal: Although I respect your wishes, master, I am not authorized to perform this function for this group."
else
telnet = @conf['telnet']
@ -46,15 +44,13 @@ 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!"
from_admin = message_from_admin?(message, adm)
auth_grp = is_chat_authorized?(message, @auth_chat)
if ! auth_grp && ! from_admin
return "Refusal: I am not authorized to perform this function for this group, meatbag."
elsif ! from_admin
return "Refusal: The meatbag #{message.from.username} is not my master."
elsif message_from_admin?(message, adm) && ! is_chat_authorized?(message, @auth_chat)
elsif ! auth_grp
return "Refusal: Although I respect your wishes, master, I am not authorized to perform this function for this group."
else
telnet = @conf['telnet']

Loading…
Cancel
Save