]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Fix rm methods in bans plugin
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Fri, 2 Feb 2007 14:26:07 +0000 (14:26 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Fri, 2 Feb 2007 14:26:07 +0000 (14:26 +0000)
data/rbot/plugins/bans.rb

index 4972b41a5aa07f686366168fe50271b09bec39f6..39f50b0065b1da926ae87325067a0bc7bebfd31e 100644 (file)
@@ -219,7 +219,8 @@ class BansPlugin < Plugin
     autos = @registry[:onjoin]\r
     count = autos.length\r
 \r
-    idx = params[:idx].to_i\r
+    idx = nil\r
+    idx = params[:idx].to_i if params[:idx]\r
 \r
     if idx\r
       if idx > count\r
@@ -242,7 +243,11 @@ class BansPlugin < Plugin
       end\r
     end\r
     @registry[:onjoin] = autos\r
-    m.okay if count > autos.length\r
+    if count > autos.length\r
+      m.okay\r
+    else\r
+      m.reply "No matching onjoin rule for #{host} found"\r
+    end\r
   end\r
 \r
   def add_badword(m, params=nil)\r
@@ -268,7 +273,8 @@ class BansPlugin < Plugin
     badwords = @registry[:badwords]\r
     count = badwords.length\r
 \r
-    idx = params[:idx].to_i\r
+    idx = nil\r
+    idx = params[:idx].to_i if params[:idx]\r
 \r
     if idx\r
       if idx > count\r
@@ -284,12 +290,17 @@ class BansPlugin < Plugin
 \r
       badwords.each { |badword|\r
         next unless ['all', badword.channel].include?(channel)\r
+       debug "Removing #{badword.inspect}" if badword == regexp\r
         badwords.delete(badword) if badword == regexp\r
       }\r
     end\r
 \r
     @registry[:badwords] = badwords\r
-    m.okay if count > badwords.length\r
+    if count > badwords.length\r
+      m.okay\r
+    else\r
+      m.reply "No matching badword #{regexp} found"\r
+    end\r
   end\r
 \r
   def add_whitelist(m, params=nil)\r
@@ -319,7 +330,8 @@ class BansPlugin < Plugin
     wl = @registry[:whitelist]\r
     count = wl.length\r
 \r
-    idx = params[:idx].to_i\r
+    idx = nil\r
+    idx = params[:idx].to_i if params[:idx]\r
 \r
     if idx\r
       if idx > count\r
@@ -342,7 +354,11 @@ class BansPlugin < Plugin
       end\r
     end\r
     @registry[:whitelist] = wl\r
-    m.okay if count > whitelist.length\r
+    if count > whitelist.length\r
+      m.okay\r
+    else\r
+      m.reply "No host matching #{host}"\r
+    end\r
   end\r
 \r
   private\r