diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-01-02 01:13:29 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-01-02 01:13:29 +0100 |
commit | dceabdbb7ede39694ecac9e71b36124e4123e741 (patch) | |
tree | 9fbab4f2f8971baa741521cf6e7ad70b267f0ba4 /bot.rb | |
parent | 09e925d6956cd7431a3466d8b659a7207e029617 (diff) | |
download | lain-dceabdbb7ede39694ecac9e71b36124e4123e741.tar lain-dceabdbb7ede39694ecac9e71b36124e4123e741.zip |
Add command help
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 |