X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~matthewv/git?a=blobdiff_plain;ds=sidebyside;f=commands.py;h=e6eb80cee6c728f2dbf19ab2e9a7cf04910be0ca;hb=cc3d67d5176a2f64ce80467b2b134fc434af28e1;hp=db8ace677d2c1a16ebb519d4fd508cdd8fc12dd3;hpb=f735103642de01dab16d0a3bc846d701edda7a64;p=irc.git 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)