From cc3d67d5176a2f64ce80467b2b134fc434af28e1 Mon Sep 17 00:00:00 2001 From: Matthew Vernon Date: Fri, 1 Apr 2011 22:56:40 +0100 Subject: [PATCH] support nsfw urls Servus should now understand nsfw:// and nsfws:// urls, and understand that these are the same as the relevant http:// and https:// URL --- commands.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commands.py b/commands.py index db8ace6..e6eb80c 100644 --- a/commands.py +++ b/commands.py @@ -324,8 +324,9 @@ class UrlLog: def urltype(self): z=min(len(urlcomplaints)-1, self.count-1) return urlcomplaints[z] - -urlre = re.compile("(https?://[^ ]+)( |$)") + +#(?:) is a regexp that doesn't group +urlre = re.compile("((?:(?:http)|(?:nsfw))s?://[^ ]+)( |$)") urlcomplaints = ["a contemporary","an interesting","a fascinating","an overused","a vastly overused"] ### Deal with /msg bot url or ~url in channel @@ -380,6 +381,8 @@ def urlexpire(urldb,expire): # canonicalise BBC URLs (internal use only) def canonical_url(urlstring): + if "nsfw://" in urlstring or "nsfws://" in urlstring: + urlstring=urlstring.replace("nsfw","http",1) if (urlstring.find("news.bbc.co.uk") != -1): for middle in ("/low/","/mobile/"): x = urlstring.find(middle) -- 2.30.2