summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-02-14 16:25:04 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-02-14 16:25:04 +0100
commit0668486764d2940242315e91eeb61c54b5dfb1d7 (patch)
treeb41a4bacfabb6df3f5410ecabc7353bccda18c17
parent3527629fa971d1407d152fecad13fb346c9286da (diff)
config core module: config search command
-rw-r--r--lib/rbot/core/config.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/rbot/core/config.rb b/lib/rbot/core/config.rb
index 13f93c9d..9f5d76f0 100644
--- a/lib/rbot/core/config.rb
+++ b/lib/rbot/core/config.rb
@@ -62,6 +62,20 @@ class ConfigModule < CoreBotModule
m.reply "#{key}: #{@bot.config.items[key].desc}"
end
+ def handle_search(m, params)
+ rx = Regexp.new(params[:rx].to_s, true)
+ cfs = []
+ @bot.config.items.each do |k, v|
+ cfs << v if k.to_s.match(rx) or (v.desc.match(rx) rescue false)
+ end
+ if cfs.empty?
+ m.reply _("no config key found matching %{r}") % { :r => params[:rx].to_s}
+ else
+ m.reply _("possible keys: %{kl}") % { :kl => cfs.map { |c| c.key}.join(', ') }
+ m.reply cfs.map { |c| [c.key, c.desc].join(': ') }.join("\n")
+ end
+ end
+
def handle_unset(m, params)
key = params[:key].to_s.intern
unless @bot.config.items.has_key?(key)
@@ -252,6 +266,9 @@ conf.map 'config desc :key',
conf.map 'config describe :key',
:action => 'handle_desc',
:auth_path => 'show'
+conf.map 'config search *rx',
+ :action => 'handle_search',
+ :autho_path => 'show'
conf.map "save",
:action => 'bot_save'