From f1c6f0ba07e5abcd980f1e12e8823ce865bfeeed Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 4 Aug 2006 00:44:31 +0000 Subject: Some fixes for the help system. Still not perfect, but better than before --- lib/rbot/core/config.rb | 2 +- lib/rbot/core/core.rb | 2 +- lib/rbot/plugins.rb | 23 +++++++++++------------ 3 files changed, 13 insertions(+), 14 deletions(-) (limited to 'lib/rbot') diff --git a/lib/rbot/core/config.rb b/lib/rbot/core/config.rb index 29a0b564..dfbaaab6 100644 --- a/lib/rbot/core/config.rb +++ b/lib/rbot/core/config.rb @@ -162,7 +162,7 @@ class ConfigModule < CoreBotModule m.reply help(params[:topic]) end - def help(topic="") + def help(plugin, topic="") case topic when "list" "config list => list configuration modules, config list => list configuration keys for module " diff --git a/lib/rbot/core/core.rb b/lib/rbot/core/core.rb index feff7491..fb626c31 100644 --- a/lib/rbot/core/core.rb +++ b/lib/rbot/core/core.rb @@ -90,7 +90,7 @@ class CoreModule < CoreBotModule # @bot.say m.replyto, @lang.get("hello_X") % m.sourcenick # handle help requests for "core" topics - def help(topic="") + def help(plugin, topic="") case topic when "quit" return "quit [] => quit IRC with message " diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb index 42ff2aaa..b55fbe4a 100644 --- a/lib/rbot/plugins.rb +++ b/lib/rbot/plugins.rb @@ -507,24 +507,23 @@ module Plugins key = $1 params = $2 (core_modules + plugins).each { |p| - # debug "checking #{p.name.inspect} against #{key.inspect}" + next unless p.name == key begin - return p.help(params) + return p.help(key, params) rescue Exception => err #rescue TimeoutError, StandardError, NameError, SyntaxError => err error report_error("#{p.botmodule_class} #{p.name} help() failed:", err) - end if p.name == key + end } + k = key.to_sym [core_commands, plugin_commands].each { |pl| - # debug "looking for #{key.inspect} in #{pl.keys.sort.inspect}" - if pl.has_key?(key) - p = pl[key][:botmodule] - begin - return p.help(key, params) - rescue Exception => err - #rescue TimeoutError, StandardError, NameError, SyntaxError => err - error report_error("#{p.botmodule_class} #{p.name} help() failed:", err) - end + next unless pl.has_key?(k) + p = pl[k][:botmodule] + begin + return p.help(p.name, topic) + rescue Exception => err + #rescue TimeoutError, StandardError, NameError, SyntaxError => err + error report_error("#{p.botmodule_class} #{p.name} help() failed:", err) end } end -- cgit v1.2.3