chiark / gitweb /
Don't remark on URLs that are repeated after a short period
[irc.git] / commands.py
index 6f5a4fb0fb659bfec794348f7f93444306ad9671..488711a254f67b03ff84f2410ce3d1574d8290ba 100755 (executable)
@@ -409,6 +409,8 @@ 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?://[^ ]+)( |$)")
+#How long (in s) to wait since the most recent mention before commenting
+url_repeat_time = 300
 urlinfos = ["a new",
             "a fascinating",
             "an interesting",
@@ -455,7 +457,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)
-    if shibboleth.search(command)==None:
+    if shibboleth.search(command)==None and \
+       time.time() - T.lastseen > url_repeat_time:
         conn.action(bot.channel, message)
     T.lastseen=time.time()
     T.count+=1