diff options
Diffstat (limited to 'bot.rb')
-rw-r--r-- | bot.rb | 28 |
1 files changed, 20 insertions, 8 deletions
@@ -22,6 +22,8 @@ module Lain @modules[mod] = Modules.const_get(mod).new(self, cfg) } + @commands = @modules.values.reduce({}) { |c, mod| c.merge mod.commands }.to_a.sort + $stderr.puts 'Connecting...' @cl = Jabber::Client.new(Jabber::JID.new(Config::JID)) @@ -36,23 +38,33 @@ module Lain @mucs[r] = muc muc.add_message_callback { |msg| - @modules.each { | _, mod | - begin - mod.on_message muc, msg - rescue - end - } + unless msg.from == r + @modules.each { | _, mod | + begin + mod.on_message muc, msg + rescue + end + } + end } $stderr.puts "Joining room `#{r}'..." - muc.join("#{r}/#{Config::Nick}") - muc.configure() + muc.join(r) + + begin + muc.configure + rescue + end } $stderr.puts 'Startup finished.' end + def commands + @commands + end + def run @mainthread = Thread.current Thread.stop |