From 6a4cf06518b72dfe5438e31b9db89df7b7d0866d Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Mon, 31 Jul 2017 16:49:58 +0100 Subject: [PATCH] Don't match r/something in the middle of a sentence --- dave/modules/reddit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dave/modules/reddit.py b/dave/modules/reddit.py index 629b897..e3520bc 100644 --- a/dave/modules/reddit.py +++ b/dave/modules/reddit.py @@ -7,8 +7,8 @@ from twisted.words.protocols.irc import assembleFormattedText, attributes as A from requests import get from humanize import naturaltime, naturaldelta, intcomma -@dave.module.match(r'.*(?:https?://(?:www\.)?reddit.com)?(/r/(.+)/comments/([^\s]+)).*') -@dave.module.match(r'.*https?://(?:www\.)?redd.it/([^\s]+).*') +@dave.module.match(r'.*(?:^| )(?:https?://(?:www\.)?reddit.com)?(/r/(.+)/comments/([^\s]+))(?: |$).*') +@dave.module.match(r'.*(?:^| )https?://(?:www\.)?redd.it/([^\s]+)(?: |$).*') @dave.module.ratelimit(1, 1) @dave.module.dont_always_run_if_run() def post(bot, args, sender, source): @@ -44,7 +44,7 @@ def post(bot, args, sender, source): ] )) -@dave.module.match(r'.*(?:https?://(?:www\.)?reddit.com)?/?r/(([^\s/]+))/?(?: |$).*') +@dave.module.match(r'.*(?:^| )(?:https?://(?:www\.)?reddit.com)?/?r/(([^\s/]+))/?(?: |$).*') @dave.module.ratelimit(1, 1) @dave.module.dont_always_run_if_run() def subreddit(bot, args, sender, source): @@ -84,7 +84,7 @@ def subreddit(bot, args, sender, source): )) -@dave.module.match(r'.*(?:https?://(?:www\.)?reddit.com)?/?(?:u|user)/(([^\s]+)/?)(?: |$).*') +@dave.module.match(r'.*(?:^| )(?:https?://(?:www\.)?reddit.com)?/?(?:u|user)/(([^\s]+)/?)(?: |$).*') @dave.module.ratelimit(1, 1) @dave.module.dont_always_run_if_run() def user(bot, args, sender, source): -- libgit2 1.7.2