From: Matthew Vernon Date: Wed, 7 Nov 2018 19:35:54 +0000 (+0000) Subject: Don't remark on URLs that are repeated after a short period X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~matthewv/git?p=irc.git;a=commitdiff_plain;h=81cc28847cc46cc2971c35ec5c54b2022e5929ca Don't remark on URLs that are repeated after a short period If a URL has been mentioned in the recent past, then it'll be obviously visible in-channel, and it was probably a mistake (e.g. mentioning a URL you meant to ~twit), so no need to comment on it. --- diff --git a/commands.py b/commands.py index 6f5a4fb..488711a 100755 --- a/commands.py +++ b/commands.py @@ -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