]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/irc.rb
Previous attempt at cleaning up the prefix matcher were too restrictive, try using...
[user/henk/code/ruby/rbot.git] / lib / rbot / irc.rb
index 1c9d4dcd5a9186054aa0a8ecbe81c080860ff84f..c2c1e82fdd518c30889a1eed9cad0830857ea9de 100644 (file)
@@ -533,19 +533,40 @@ class Regexp
 \r
     GEN_HOST = /#{HOSTNAME}|#{HOSTADDR}/\r
 \r
-    # FreeNode network replaces the host of affiliated users with\r
-    # 'virtual hosts' \r
-    # FIXME we need the true syntax to match it properly ...\r
-    PDPC_HOST_PART = /[0-9A-Za-z.-]+/\r
-    PDPC_HOST = /#{PDPC_HOST_PART}(?:\/#{PDPC_HOST_PART})+/\r
-\r
-    # NOTE: the final optional and non-greedy dot is needed because some\r
-    # servers (e.g. FreeNode) send the hostname of the services as "services."\r
-    # which is not RFC compliant, but sadly done.\r
-    GEN_MASK_HOST = /#{PDPC_HOST}|#{GEN_HOST}\.??/ \r
-\r
-    # Netmask-matching Regexp\r
-    GEN_MASK = /(#{GEN_NICK})(?:(?:!(#{GEN_USER}))?@(#{GEN_MASK_HOST}))?/\r
+    # # FreeNode network replaces the host of affiliated users with\r
+    # # 'virtual hosts' \r
+    # # FIXME we need the true syntax to match it properly ...\r
+    # PDPC_HOST_PART = /[0-9A-Za-z.-]+/\r
+    # PDPC_HOST = /#{PDPC_HOST_PART}(?:\/#{PDPC_HOST_PART})+/\r
+\r
+    # # NOTE: the final optional and non-greedy dot is needed because some\r
+    # # servers (e.g. FreeNode) send the hostname of the services as "services."\r
+    # # which is not RFC compliant, but sadly done.\r
+    # GEN_HOST_EXT = /#{PDPC_HOST}|#{GEN_HOST}\.??/ \r
+\r
+    # Sadly, different networks have different, RFC-breaking ways of cloaking\r
+    # the actualy host address: see above for an example to handle FreeNode.\r
+    # Another example would be Azzurra, wich also inserts a "=" in the\r
+    # cloacked host. So let's just not care about this and go with the simplest\r
+    # thing:\r
+    GEN_HOST_EXT = /\S+/\r
+\r
+    # User-matching Regexp\r
+    GEN_USER_ID = /(#{GEN_NICK})(?:(?:!(#{GEN_USER}))?@(#{GEN_HOST_EXT}))?/\r
+\r
+    # Things such has the BIP proxy send invalid nicks in a complete netmask,\r
+    # so we want to match this, rather: this matches either a compliant nick\r
+    # or a a string with a very generic nick, a very generic hostname after an\r
+    # @ sign, and an optional user after a !\r
+    BANG_AT = /#{GEN_NICK}|\S+?(?:!\S+?)?@\S+?/\r
+\r
+    # # For Netmask, we want to allow wildcards * and ? in the nick\r
+    # # (they are already allowed in the user and host part\r
+    # GEN_NICK_MASK = /(?:#{NICK_FIRST}|[?*])?(?:#{NICK_ANY}|[?*])+/\r
+\r
+    # # Netmask-matching Regexp\r
+    # GEN_MASK = /(#{GEN_NICK_MASK})(?:(?:!(#{GEN_USER}))?@(#{GEN_HOST_EXT}))?/\r
+\r
   end\r
 \r
 end\r
@@ -593,7 +614,9 @@ module Irc
       # Now we can see if the given string _str_ is an actual Netmask\r
       if str.respond_to?(:to_str)\r
         case str.to_str\r
-        when /^(?:#{Regexp::Irc::GEN_MASK})?$/\r
+          # We match a pretty generic string, to work around non-compliant\r
+          # servers\r
+        when /^(?:(\S+?)(?:(?:!(\S+?))?@(\S+))?)?$/\r
           # We do assignment using our internal methods\r
           self.nick = $1\r
           self.user = $2\r