X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fscript.rb;h=11aed3968d006ad81bee53c235285fc61c92a430;hb=6cf365c49ce5fbe24c0a4ff0663550390b501fea;hp=c994d4da91c95a0a663d72473b1ac896b4d921a5;hpb=a51ae05ee0252576a10a77c9f92c0ce096be73aa;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/script.rb b/data/rbot/plugins/script.rb index c994d4da..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 @@ -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 @@ -34,49 +34,78 @@ class ScriptPlugin < Plugin def help( plugin, topic="" ) - if topic == "add" + case topic + when "add" "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: ': greet'." - else - "Create mini plugins on IRC. 'script add ' => Create script named with the Ruby program . 'script list' => Show a list of all known scripts. 'script show ' => Show the source code for . 'script del ' => Delete the script ." + when "allow" + "script allow