X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fscript.rb;h=11aed3968d006ad81bee53c235285fc61c92a430;hb=6cf365c49ce5fbe24c0a4ff0663550390b501fea;hp=849783b8917ba5742fd71c955d5099da259dbe1c;hpb=51c35168127e0faed56bceb3f5103f92ed31478c;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/script.rb b/data/rbot/plugins/script.rb index 849783b8..11aed396 100644 --- a/data/rbot/plugins/script.rb +++ b/data/rbot/plugins/script.rb @@ -11,7 +11,7 @@ # # Scripts are little Ruby programs that run in the context of the script # plugin. You can create them directly in an IRC channel, and invoke them just -# like normal rbot plugins. +# like normal rbot plugins. define_structure :Command, :code, :nick, :created, :channel @@ -60,17 +60,14 @@ class ScriptPlugin < Plugin auth_path = "script::run::#{name}".intern return unless @bot.auth.allow?(auth_path, m.source, m.replyto) - code = @commands[name].code.dup.untaint + code = @commands[name].code.dup # Convenience variables, can be accessed by scripts: args = m.message.split - args.delete_at( 0 ) - user = args.empty? ? m.sourcenick : args.first + args.delete_at( 0 ) + user = args.empty? ? m.sourcenick : args.first Thread.start { - # TODO allow different safe levels for different botusers - $SAFE = 3 - begin eval( code ) rescue Exception => e @@ -103,9 +100,8 @@ class ScriptPlugin < Plugin def handle_eval( m, params ) - code = params[:code].to_s.dup.untaint + code = params[:code].to_s.dup Thread.start { - # TODO allow different safe levels for different botusers begin eval( code ) rescue Exception => e @@ -117,9 +113,8 @@ class ScriptPlugin < Plugin def handle_echo( m, params ) - code = params[:code].to_s.dup.untaint + code = params[:code].to_s.dup Thread.start { - # TODO allow different safe levels for different botusers begin m.reply eval( code ).to_s rescue Exception => e @@ -152,7 +147,7 @@ class ScriptPlugin < Plugin def handle_add_force( m, params ) handle_add( m, params, true ) end - + def handle_del( m, params ) name = params[:name] @@ -176,9 +171,9 @@ class ScriptPlugin < Plugin page = params[:page].to_i page = [page, 1].max page = [page, num_pages].min - str = cmds[(page-1)*cmds_per_page, cmds_per_page].join(', ') + str = cmds[(page-1)*cmds_per_page, cmds_per_page].join(', ') - m.reply "Available scripts (page #{page}/#{num_pages}): #{str}" + m.reply "Available scripts (page #{page}/#{num_pages}): #{str}" end @@ -200,6 +195,7 @@ plugin = ScriptPlugin.new plugin.default_auth( 'edit', false ) plugin.default_auth( 'eval', false ) plugin.default_auth( 'echo', false ) +plugin.default_auth( 'show', false ) plugin.default_auth( 'run', true ) plugin.map 'script add -f :name *code', :action => 'handle_add_force', :auth_path => 'edit'