]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/script.rb
lart plugin: replace "me" with sourcenick
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / script.rb
index 1b69586816c06a53365da5299a8f27ddc796cf07..5e2f1e58e1b9140eac4cfabae9a2e17384dfde70 100644 (file)
@@ -13,9 +13,7 @@
 # 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 )
-
+define_structure :Command, :code, :nick, :created, :channel
 
 class ScriptPlugin < Plugin
 
@@ -23,6 +21,7 @@ class ScriptPlugin < Plugin
     super
     if @registry.has_key?(:commands)
       @commands = @registry[:commands]
+      raise unless @commands
     else
       @commands = Hash.new
     end
@@ -60,7 +59,7 @@ class ScriptPlugin < Plugin
 
         begin
           eval( code )
-        rescue => e
+        rescue Exception => e
           m.reply( "Script '#{name}' crapped out :(" )
           m.reply( e.inspect )
         end
@@ -75,7 +74,7 @@ class ScriptPlugin < Plugin
         # TODO allow different safe levels for different botusers
         begin
           eval( code )
-        rescue => e
+        rescue Exception => e
           m.reply( "Script '#{name}' crapped out :(" )
           m.reply( e.inspect )
         end
@@ -89,7 +88,7 @@ class ScriptPlugin < Plugin
         # TODO allow different safe levels for different botusers
         begin
           m.reply eval( code ).to_s
-        rescue => e
+        rescue Exception => e
           m.reply( "Script '#{name}' crapped out :(" )
           m.reply( e.inspect )
         end