From 0ca5b13d18e80c6fba5b7e51377469df555a09f5 Mon Sep 17 00:00:00 2001 From: Matthew Vernon Date: Tue, 19 Apr 2011 15:23:16 +0100 Subject: [PATCH] Add shibboleth support You can now say "re url" or "re: url" without Servus nagging you --- commands.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/commands.py b/commands.py index 0075272..20d207c 100644 --- a/commands.py +++ b/commands.py @@ -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: -- 2.30.2