]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/script.rb
script plugin: script allow/deny high level UI
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / script.rb
index 762613d42e85b6052fa50f9554537798181153c0..16f39648d0ebf48acb27d3d4c63ac9b2bfbe913e 100644 (file)
@@ -76,6 +76,26 @@ class ScriptPlugin < Plugin
     end
   end
 
+  def handle_allow_deny(m, p)
+    name = p[:stuff]
+    if @commands.has_key?( name )
+      @bot.plugins['auth'].auth_allow_deny(m, p.merge(
+        :auth_path => "script::run::#{name}".intern
+      ))
+    else
+      m.reply(_("%{stuff} is not a script I know of") % p)
+    end
+  end
+
+  def handle_allow(m, p)
+    handle_allow_deny(m, p.merge(:allow => true))
+  end
+
+  def handle_deny(m, p)
+    handle_allow_deny(m, p.merge(:allow => false))
+  end
+
+
 
   def handle_eval( m, params )
     code = params[:code].to_s.dup.untaint
@@ -185,4 +205,12 @@ plugin.map 'script echo *code',         :action => 'handle_echo'
 plugin.map 'script list :page',         :action => 'handle_list',      :defaults => { :page => '1' }
 plugin.map 'script show :name',         :action => 'handle_show'
 
+plugin.map 'script allow :stuff for :user [*where]',
+  :action => 'handle_allow',
+  :requirements => {:where => /^(?:anywhere|everywhere|[io]n \S+)$/},
+  :auth_path => 'edit'
+plugin.map 'script deny :stuff for :user [*where]',
+  :action => 'handle_deny',
+  :requirements => {:where => /^(?:anywhere|everywhere|[io]n \S+)$/},
+  :auth_path => 'edit'