Janitor/notification.rb

50 lines
942 B
Ruby
Raw Normal View History

#!/usr/bin/env ruby
2017-04-16 14:42:59 +01:00
require_relative 'Janitor'
i = 1
jan = Janitor.new
while (i > 0)
begin
return_report = jan.listen(false)
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-17 16:08:35 +01:00
rescue Exception => e
puts e.backtrace
2017-04-17 16:07:11 +01:00
puts "Error: " + e.message
end
2017-04-16 14:42:59 +01:00
end