diff options
-rw-r--r-- | lib/rbot/irc.rb | 20 |
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
|