]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
maskdb: be case insenstive
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Fri, 14 Dec 2007 11:18:54 +0000 (11:18 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Fri, 14 Dec 2007 11:18:54 +0000 (11:18 +0000)
lib/rbot/irc.rb
lib/rbot/maskdb.rb

index 78c154ec13ca23922b09d6ac7a6605cd8ccae5d2..f3a904e744e8b2c4d636db9a7cee788bd078a885 100644 (file)
@@ -671,6 +671,12 @@ module Irc
       self.full_irc_downcase\r
     end\r
 \r
+    # This method returns a new Netmask which is the fully downcased version\r
+    # of the receiver\r
+    def downcased\r
+      return self.full_downcase.to_irc_netmask(server_and_casemap)\r
+    end\r
+\r
     # Converts the receiver into a Netmask with the given (optional)\r
     # server/casemap association. We return self unless a conversion\r
     # is needed (different casemap/server)\r
index 435693ec00b8400a2bf7d3b848fcafc1396e32f4..55dc983942d403e71a52464d9b4e5171986a5ee9 100644 (file)
@@ -119,7 +119,8 @@ module Irc
     end
 
     def mask2keys(m)
-      [m.host, m.user, m.nick].map { |c| cook_component(c) }
+      md = m.downcased
+      [md.host, md.user, md.nick].map { |c| cook_component(c) }
     end
 
     def add(user, *masks)
@@ -147,7 +148,8 @@ module Irc
 
     def find(iu)
       debug "find(#{iu.fullform})"
-      matches = @tree.find(iu.host, iu.user, iu.nick).uniq.map do |val|
+      iud = iu.downcased
+      matches = @tree.find(iud.host, iud.user, iud.nick).uniq.map do |val|
         m = metric(iu, *val)
         m ? [val[0], m] : nil
       end.compact.sort { |a, b| a[1] <=> a[1] }