commit
256d646941
@ -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
|
||||
|
@ -1,2 +1,16 @@
|
||||
ssh ajohnson@tartarus srvstart.bat
|
||||
#!/usr/bin/env sh
|
||||
#ssh ajohnson@tartarus srvstart.bat
|
||||
#ssh ajohnson@tartarus 'X:\server\alpha9\start-nova9.cmd'
|
||||
ssh ajohnson@tartarus '.\srvstart.bat'
|
||||
#echo "Yay you did it"
|
||||
|
||||
#set timeout 10
|
||||
#set host [lindex $argv 0]
|
||||
#
|
||||
#spawn ssh ajohnson@${host}
|
||||
#expect "Microsoft Windows"
|
||||
#send ".\\srvstart.bat\r"
|
||||
##expect "Logged in successfully"
|
||||
##send "saveandexit 0\r"
|
||||
#expect eof
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/expect
|
||||
#ssh ajohnson@tartarus srvstart.bat
|
||||
#ssh ajohnson@tartarus "X:\server\alpha9\start-nova9.cmd"
|
||||
#echo "Yay you did it"
|
||||
|
||||
set timeout 10
|
||||
set host [lindex $argv 0]
|
||||
|
||||
spawn ssh ajohnson@${host}
|
||||
expect "Microsoft Windows"
|
||||
send ".\\srvstart.bat\r"
|
||||
#expect "Logged in successfully"
|
||||
#send "saveandexit 0\r"
|
||||
expect eof
|
||||
|
Loading…
Reference in new issue