X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=data%2Frbot%2Fplugins%2Fscript.rb;h=431b52463d4b04313e03a7a750a6bc9535ab3005;hb=b565bf81cbe456205b9f9fcf9e3960109c5b7de6;hp=e2669088c1c6062928d0ca8f4c2c85247504e8a5;hpb=83bfc1d808e63691b2f3081f903aa05684c379b6;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/script.rb b/data/rbot/plugins/script.rb index e2669088..431b5246 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 ).to_s + 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 ) @@ -156,11 +170,13 @@ plugin = ScriptPlugin.new plugin.register( "script" ) plugin.default_auth( 'edit', false ) plugin.default_auth( 'eval', false ) +plugin.default_auth( 'echo', false ) 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' 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'