summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-12-13 10:34:49 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-12-13 10:34:49 +0000
commite9c6f14aef48ce01e802a15ee6bea520b38227f9 (patch)
tree090220325e613f91fcec7cdd9e97955226bf9145 /lib
parentd06b96bf95563cea4ebf31e2e324536d812efdbd (diff)
auth: 'permission search' command to look up the full_auth_path of commands
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/core/auth.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/rbot/core/auth.rb b/lib/rbot/core/auth.rb
index b9a39767..175d2153 100644
--- a/lib/rbot/core/auth.rb
+++ b/lib/rbot/core/auth.rb
@@ -191,6 +191,24 @@ class AuthModule < CoreBotModule
end
end
+ def auth_search_perm(m, p)
+ pattern = Regexp.new(p[:pattern].to_s)
+ results = @bot.plugins.maps.select { |k, v| k.match(pattern) }
+ count = results.length
+ max = @bot.config['send.max_lines']
+ extra = (count > max ? _(". only %{max} will be shown") : "") % { :max => max }
+ m.reply _("%{count} commands found matching %{pattern}%{extra}") % {
+ :count => count, :pattern => pattern, :extra => extra
+ }
+ return if count == 0
+ results[0,max].each { |cmd, hash|
+ m.reply _("%{cmd}: %{perms}") % {
+ :cmd => cmd,
+ :perms => hash[:auth].join(", ")
+ }
+ }
+ end
+
def get_botuser_for(user)
@bot.auth.irc_to_botuser(user)
end
@@ -273,8 +291,10 @@ class AuthModule < CoreBotModule
return _("permissions [re]set <permission> [in <channel>] for <user>: sets or resets the permissions for botuser <user> in channel <channel> (use ? to change the permissions for private addressing)")
when "view"
return _("permissions view [for <user>]: display the permissions for user <user>")
+ when "searc"
+ return _("permissions search <pattern>: display the permissions associated with the commands matching <pattern>")
else
- return _("permission topics: syntax, (re)set, view")
+ return _("permission topics: syntax, (re)set, view, search")
end
when "user"
case topic
@@ -940,5 +960,8 @@ auth.map "permissions view [for :user]",
:action => 'auth_view_perm',
:auth_path => '::'
+auth.map "permissions search *pattern",
+ :action => 'auth_search_perm'
+
auth.default_auth('*', false)