chiark / gitweb /
Add shibboleth support
[irc.git] / commands.py
index 0075272c54d7f585291e3619217644f7744baf8c..20d207c2fae4a10029aac694f2c2b93264ceb785 100644 (file)
@@ -326,8 +326,10 @@ class UrlLog:
         return urlcomplaints[z]
 
 #(?:) is a regexp that doesn't group        
-urlre = re.compile("((?:(?:http)|(?:nsfw))s?://[^ ]+)( |$)")
-hturlre= re.compile("(http)(s?://[^ ]+)( |$)")
+urlre = re.compile(r"((?:(?:http)|(?:nsfw))s?://[^ ]+)( |$)")
+hturlre= re.compile(r"(http)(s?://[^ ]+)( |$)")
+#matches \bre\:?\s+ before a regexp; (?i)==case insensitive match
+shibboleth = re.compile(r"(?i)\bre\:?\s+((?:(?:http)|(?:nsfw))s?://[^ ]+)( |$)")
 urlcomplaints = ["a contemporary","an interesting","a fascinating","an overused","a vastly overused"]
 
 ### Deal with /msg bot url or ~url in channel
@@ -372,7 +374,8 @@ def dourl(bot,conn,nick,command,urldb):
     T=urldb[urlstring]
     message="observes %s URL, first mentioned %s by %s" % \
              (T.urltype(),T.firstmen(),T.nick)
-    conn.action(bot.channel, message)
+    if shibbloleth.search(command)==None:
+        conn.action(bot.channel, message)
     T.lastseen=time.time()
     T.count+=1
   else: