X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fscript.rb;h=0923dd5dc15eeb59c40e770d15008c4fa241e7db;hb=f506b9a3752b20ad045a7c852113f133e0bf382e;hp=793064bd20faa97723cd1db92796b4f1baf58fbb;hpb=7c57d4bfc7e178147f6790cb257366266e639ef5;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/script.rb b/data/rbot/plugins/script.rb index 793064bd..0923dd5d 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 @@ -21,7 +21,7 @@ class ScriptPlugin < Plugin super if @registry.has_key?(:commands) @commands = @registry[:commands] - raise unless @commands + raise LoadError, "corrupted script database" unless @commands else @commands = Hash.new end @@ -64,8 +64,8 @@ class ScriptPlugin < Plugin # 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 @@ -152,7 +152,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 +176,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