2017-04-17 14:07:32 +01:00
|
|
|
#!/usr/bin/env ruby
|
2017-04-16 14:42:59 +01:00
|
|
|
|
|
|
|
|
require_relative 'Janitor'
|
|
|
|
|
|
|
|
|
|
i = 1
|
|
|
|
|
jan = Janitor.new
|
2017-04-17 16:17:30 +01:00
|
|
|
jan.move_self('218')
|
2017-04-17 16:44:46 +01:00
|
|
|
jan.gsay("Online and listening...") #//Greeting/MOTD eventually?
|
2017-04-16 14:42:59 +01:00
|
|
|
while (i > 0)
|
|
|
|
|
begin
|
2017-04-17 16:06:37 +01:00
|
|
|
|
2017-04-17 16:22:25 +01:00
|
|
|
return_report = jan.listen()
|
2017-04-17 16:15:47 +01:00
|
|
|
|
2017-04-17 16:17:30 +01:00
|
|
|
invokerid = return_report['invokerid']
|
|
|
|
|
cmd = return_report['msg']
|
2017-04-17 16:06:37 +01:00
|
|
|
|
2017-04-17 15:44:24 +01:00
|
|
|
puts cmd + " - " + invokerid.to_s
|
2017-04-16 14:42:59 +01:00
|
|
|
if cmd == '!help'
|
2017-04-17 14:07:32 +01:00
|
|
|
msg = "I am Janitor, you can tell me to do things."
|
|
|
|
|
jan.gsay(msg)
|
2017-04-16 14:42:59 +01:00
|
|
|
msg = "Try !roll to roll a dice"
|
|
|
|
|
jan.gsay(msg)
|
|
|
|
|
end
|
|
|
|
|
if cmd == "!stop"
|
|
|
|
|
msg = "JAN Will stop listening"
|
2017-04-17 14:07:32 +01:00
|
|
|
jan.gsay(msg)
|
2017-04-16 14:42:59 +01:00
|
|
|
puts "Stopping"
|
|
|
|
|
i = -1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if cmd.include? "!say"
|
|
|
|
|
cmd.slice! "!say"
|
|
|
|
|
input_str = cmd
|
|
|
|
|
puts "[DEBUG] " + input_str
|
|
|
|
|
jan.gsay(input_str)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if cmd == "!cleanup"
|
|
|
|
|
jan.gsay("Cleaning up..")
|
|
|
|
|
jan.check_channels()
|
|
|
|
|
jan.gsay("Channels clean!")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if cmd == "!roll"
|
|
|
|
|
jan.gsay(jan.roll)
|
2017-04-17 16:43:09 +01:00
|
|
|
end
|
|
|
|
|
|
2017-04-16 14:42:59 +01:00
|
|
|
|
2017-04-17 16:08:35 +01:00
|
|
|
rescue Exception => e
|
|
|
|
|
puts e.backtrace
|
2017-04-17 16:07:11 +01:00
|
|
|
puts "Error: " + e.message
|
2017-04-17 16:43:09 +01:00
|
|
|
|
|
|
|
|
#//Re-create the bot (Fucking awful, i know but here we are)
|
|
|
|
|
jan = Janitor.new
|
|
|
|
|
jan.move_self('218')
|
2017-04-17 14:07:32 +01:00
|
|
|
end
|
2017-04-16 14:42:59 +01:00
|
|
|
end
|