]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/script.rb
lastfm plugin: overlong artisti descriptions are truncated; artist events can be...
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / script.rb
index f8e2c67fce03c263af276ff6ffdba0a8e13abce3..1b69586816c06a53365da5299a8f27ddc796cf07 100644 (file)
@@ -1,12 +1,17 @@
-# Plugin for the Ruby IRC bot (http://linuxbrit.co.uk/rbot/)
+#-- vim:sw=2:et
+#++
 #
-# Create mini plugins on IRC.
+# :title: Script plugin for rbot
+#
+# Author:: Mark Kretschmann <markey@web.de>
+# Copyright:: (C) 2006 Mark Kretschmann
+# License:: GPL v2
 #
-# 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. 
+# Create mini plugins on IRC.
 #
-# (c) 2006 Mark Kretschmann <markey@web.de>
-# Licensed under GPL V2.
+# 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. 
 
 
 Command = Struct.new( "Command", :code, :nick, :created, :channel )
@@ -18,18 +23,9 @@ class ScriptPlugin < Plugin
     super
     if @registry.has_key?(:commands)
       @commands = @registry[:commands]
-    end
-    
-    if @commands.nil?
+    else
       @commands = Hash.new
     end
-
-    # Migrate old Hash to new:
-    @commands.each_pair do |name, cmd|
-      unless cmd.instance_of?( Command )
-        @commands[name] = Command.new( cmd, 'unknown hacker', 'somedate', '#somechan' )
-      end
-    end
   end
 
 
@@ -40,9 +36,9 @@ class ScriptPlugin < Plugin
 
   def help( plugin, topic="" )
     if topic == "add"
-      "Scripts are little Ruby programs that run in the context of the script plugin. You can access @bot (class IrcBot), m (class PrivMessage), user (class String, either the first argument, or if missing the sourcenick), and args (class Array, an array of arguments). Example: 'script add greet m.reply( 'Hello ' + user )'. Invoke the script just like a plugin: '<botnick>: greet'."
+      "Scripts are little Ruby programs that run in the context of the script plugin. You can access @bot (class Irc::Bot), m (class Irc::PrivMessage), user (class String, either the first argument, or if missing the sourcenick), and args (class Array, an array of arguments). Example: 'script add greet m.reply( 'Hello ' + user )'. Invoke the script just like a plugin: '<botnick>: greet'."
     else  
-      "Create mini plugins on IRC. 'script add <name> <code>' => Create script named <name> with the code <source>. 'script list' => Show a list of all known scripts. 'script show <name>' => Show the source code for <name>. 'script del <name>' => Delete the script <name>."
+      "Create mini plugins on IRC. 'script add <name> <code>' => Create script named <name> with the Ruby program <code>. 'script list' => Show a list of all known scripts. 'script show <name>' => Show the source code for <name>. 'script del <name>' => Delete the script <name>."
     end
   end
 
@@ -167,9 +163,10 @@ end
 
 
 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'