X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fscript.rb;h=ff45df0bfd91100caec9d8da8bd8822822237adf;hb=ec6916f0d4c6b4b6e63b39e44daa136fe6614d1d;hp=8234442c840ca71186280c9887cc958638eac942;hpb=05917e75de2cbd14071ef335f4c3129a33f30cf6;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/script.rb b/data/rbot/plugins/script.rb index 8234442c..ff45df0b 100644 --- a/data/rbot/plugins/script.rb +++ b/data/rbot/plugins/script.rb @@ -18,7 +18,9 @@ class ScriptPlugin < Plugin super if @registry.has_key?(:commands) @commands = @registry[:commands] - else + end + + if @commands.nil? @commands = Hash.new end @@ -77,7 +79,7 @@ class ScriptPlugin < Plugin return end - code = params[:code].join( " " ) + code = params[:code].to_s nick = m.sourcenick created = Time.new.strftime '%Y/%m/%d %H:%m' channel = m.target @@ -112,7 +114,7 @@ class ScriptPlugin < Plugin cmds_per_page = 30 cmds = @commands.keys.sort - num_pages = cmds.length / cmds_per_page + num_pages = cmds.length / cmds_per_page + 1 page = params[:page].to_i page = [page, 1].max page = [page, num_pages].min @@ -137,10 +139,11 @@ end plugin = ScriptPlugin.new plugin.register( "script" ) +plugin.default_auth( 'edit', false ) -plugin.map 'script add -f :name *code', :action => 'handle_add_force', :auth => 'scriptedit' -plugin.map 'script add :name *code', :action => 'handle_add', :auth => 'scriptedit' -plugin.map 'script del :name', :action => 'handle_del', :auth => 'scriptedit' +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 list :page', :action => 'handle_list', :defaults => { :page => '1' } plugin.map 'script show :name', :action => 'handle_show'