summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-08-29 07:23:22 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-08-29 07:23:22 +0000
commit57c3d49ee623a09ffdd4ea270efdf3f237b74f1a (patch)
tree5e1cf58478c1a8c8ba624c891db30ac312e390fd /data
parent7aa8bc3cc941f2e05026a034406d34ce1f5e4b3c (diff)
script plugin: echo function. like eval, but implies an m.reply
Diffstat (limited to 'data')
-rw-r--r--data/rbot/plugins/script.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/data/rbot/plugins/script.rb b/data/rbot/plugins/script.rb
index e2669088..60c0e973 100644
--- a/data/rbot/plugins/script.rb
+++ b/data/rbot/plugins/script.rb
@@ -87,6 +87,20 @@ class ScriptPlugin < Plugin
end
+ def handle_echo( m, params )
+ code = params[:code].to_s.dup.untaint
+ Thread.start {
+ # TODO allow different safe levels for different botusers
+ begin
+ m.reply eval( code )
+ rescue => e
+ m.reply( "Script '#{name}' crapped out :(" )
+ m.reply( e.inspect )
+ end
+ }
+ end
+
+
def handle_add( m, params, force = false )
name = params[:name]
if !force and @commands.has_key?( name )
@@ -161,6 +175,7 @@ plugin.map 'script add -f :name *code', :action => 'handle_add_force', :auth_pat
plugin.map 'script add :name *code', :action => 'handle_add', :auth_path => 'edit'
plugin.map 'script del :name', :action => 'handle_del', :auth_path => 'edit'
plugin.map 'script eval *code', :action => 'handle_eval'
+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'