]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
script plugin: per-script permissions
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 3 Nov 2008 21:33:19 +0000 (22:33 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 3 Nov 2008 21:33:19 +0000 (22:33 +0100)
data/rbot/plugins/script.rb

index e3e718a70546350808ec410c4eb2abe1b17e09e8..762613d42e85b6052fa50f9554537798181153c0 100644 (file)
@@ -52,6 +52,9 @@ class ScriptPlugin < Plugin
     name = m.message.split.first
 
     if m.address? and @commands.has_key?( name )
+      auth_path = "script::run::#{name}".intern
+      return unless @bot.auth.allow?(auth_path, m.source, m.replyto)
+
       code = @commands[name].code.dup.untaint
 
       # Convenience variables, can be accessed by scripts:
@@ -172,6 +175,7 @@ plugin = ScriptPlugin.new
 plugin.default_auth( 'edit', false )
 plugin.default_auth( 'eval', false )
 plugin.default_auth( 'echo', false )
+plugin.default_auth( 'run', true )
 
 plugin.map 'script add -f :name *code', :action => 'handle_add_force', :auth_path => 'edit'
 plugin.map 'script add :name *code',    :action => 'handle_add',       :auth_path => 'edit'