]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/script.rb
uno plugin: fix check for card presence
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / script.rb
index 38bb3134828002cf0e356f9532e70e7f734f1e35..8a3e1e847a0876416906a8b86186ba9a91c95e6a 100644 (file)
@@ -21,6 +21,7 @@ class ScriptPlugin < Plugin
     super
     if @registry.has_key?(:commands)
       @commands = @registry[:commands]
+      raise unless @commands
     else
       @commands = Hash.new
     end
@@ -63,35 +64,38 @@ class ScriptPlugin < Plugin
           m.reply( e.inspect )
         end
       }
+      m.replied = true
     end
   end
 
 
   def handle_eval( m, params )
     code = params[:code].to_s.dup.untaint
-      Thread.start {
-        # TODO allow different safe levels for different botusers
-        begin
-          eval( code )
-        rescue Exception => e
-          m.reply( "Script '#{name}' crapped out :(" )
-          m.reply( e.inspect )
-        end
-      }
+    Thread.start {
+      # TODO allow different safe levels for different botusers
+      begin
+        eval( code )
+      rescue Exception => e
+        m.reply( "Script '#{name}' crapped out :(" )
+        m.reply( e.inspect )
+      end
+    }
+    m.replied = true
   end
 
 
   def handle_echo( m, params )
     code = params[:code].to_s.dup.untaint
-      Thread.start {
-        # TODO allow different safe levels for different botusers
-        begin
-          m.reply eval( code ).to_s
-        rescue Exception => e
-          m.reply( "Script '#{name}' crapped out :(" )
-          m.reply( e.inspect )
-        end
-      }
+    Thread.start {
+      # TODO allow different safe levels for different botusers
+      begin
+        m.reply eval( code ).to_s
+      rescue Exception => e
+        m.reply( "Script '#{name}' crapped out :(" )
+        m.reply( e.inspect )
+      end
+    }
+    m.replied = true
   end
 
 
@@ -110,7 +114,7 @@ class ScriptPlugin < Plugin
     command = Command.new( code, nick, created, channel )
     @commands[name] = command
 
-    m.reply( "done" )
+    m.okay
   end
 
 
@@ -126,7 +130,7 @@ class ScriptPlugin < Plugin
     end
 
     @commands.delete( name )
-    m.reply( "done" )
+    m.okay
   end