summaryrefslogtreecommitdiffstats
path: root/bot.rb
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-01-02 01:13:29 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-01-02 01:13:29 +0100
commitdceabdbb7ede39694ecac9e71b36124e4123e741 (patch)
tree9fbab4f2f8971baa741521cf6e7ad70b267f0ba4 /bot.rb
parent09e925d6956cd7431a3466d8b659a7207e029617 (diff)
downloadlain-dceabdbb7ede39694ecac9e71b36124e4123e741.tar
lain-dceabdbb7ede39694ecac9e71b36124e4123e741.zip
Add command help
Diffstat (limited to 'bot.rb')
-rw-r--r--bot.rb28
1 files changed, 20 insertions, 8 deletions
diff --git a/bot.rb b/bot.rb
index 6040029..524bb02 100644
--- a/bot.rb
+++ b/bot.rb
@@ -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