From dceabdbb7ede39694ecac9e71b36124e4123e741 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 2 Jan 2013 01:13:29 +0100 Subject: Add command help --- bot.rb | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'bot.rb') 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 -- cgit v1.2.3