summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorDmitry Kim <dmitry point kim at gmail point com>2007-09-22 13:31:20 +0000
committerDmitry Kim <dmitry point kim at gmail point com>2007-09-22 13:31:20 +0000
commit0aa0919fdbfa148dfbb5961f14f27e41085959b4 (patch)
tree3bcd4d503185e802fcdc1866ac600b8765ce1350 /lib/rbot
parent290656ebffce720540f5a767066d914840e583c8 (diff)
+ (irc) generalize() method for Netmask class
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/irc.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/rbot/irc.rb b/lib/rbot/irc.rb
index 371762cb..2a4642a2 100644
--- a/lib/rbot/irc.rb
+++ b/lib/rbot/irc.rb
@@ -751,6 +751,26 @@ module Irc
return @nick.has_irc_glob? || @user.has_irc_glob? || @host.has_irc_glob?
end
+ def generalize
+ u = user.dup
+ unless u.has_irc_glob?
+ u.sub!(/^[in]=/, '=') or u.sub!(/^\W(\w+)/, '\1')
+ u = '*' + u
+ end
+
+ h = host.dup
+ unless h.has_irc_glob?
+ if h.include? '/'
+ h.sub!(/x-\w+$/, 'x-*')
+ else
+ h.match(/^[^\.]+\.[^\.]+$/) or
+ h.sub!(/^(\d+\.\d+\.\d+\.)\d+$/, '\1*') or
+ h.sub!(/^[^\.]+\./, '*.')
+ end
+ end
+ return Netmask.new("*!#{u}@#{h}", server_and_casemap)
+ end
+
# This method is used to match the current Netmask against another one
#
# The method returns true if each component of the receiver matches the