Janitor/notification.rb

58 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

#!/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
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']
puts cmd + " - " + invokerid.to_s
2017-04-16 14:42:59 +01:00
if cmd == '!help'
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"
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)
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
#//Re-create the bot (Fucking awful, i know but here we are)
jan = Janitor.new
jan.move_self('218')
end
2017-04-16 14:42:59 +01:00
end