Allow matching in middle of sentence
Diff
dave/modules/reddit.py | 8 ++++++--
dave/modules/speedtest.py | 2 +-
dave/modules/youtube.py | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
@@ -7,8 +7,8 @@
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.dont_always_run_if_run()
def post(bot, args, sender, source):
"""Ran whenever a reddit post is sent"""
@@ -43,7 +43,7 @@
]
))
@dave.module.match(r'(?:https?://(?:www\.)?reddit.com)?/?r/(([^\s/]+))/?(?: |$)')
@dave.module.match(r'.*(?:https?://(?:www\.)?reddit.com)?/?r/(([^\s/]+))/?(?: |$).*')
@dave.module.dont_always_run_if_run()
def subreddit(bot, args, sender, source):
"""Ran whenever a subreddit is mentioned"""
@@ -82,7 +82,7 @@
))
@dave.module.match(r'(?:https?://(?:www\.)?reddit.com)?/?(?:u|user)/(([^\s]+)/?)(?: |$)')
@dave.module.match(r'.*(?:https?://(?:www\.)?reddit.com)?/?(?:u|user)/(([^\s]+)/?)(?: |$).*')
@dave.module.dont_always_run_if_run()
def user(bot, args, sender, source):
if not dave.config.redis.exists("reddit:user:{}".format(args[0])):
@@ -1,10 +1,10 @@
"""Read details from a speedtest test and print them to the channel."""
from requests import get
from bs4 import BeautifulSoup
import dave.module
from twisted.words.protocols.irc import assembleFormattedText, attributes as A
@dave.module.match(r'https?://(?:www\.|beta\.)?speedtest\.net/(?:my-)?result/([0-9]+)(?:.png)?')
@dave.module.match(r'.*https?://(?:www\.|beta\.)?speedtest\.net/(?:my-)?result/([0-9]+)(?:.png)?.*')
@dave.module.dont_always_run_if_run()
def speedtest(bot, args, sender, source):
res = get("http://www.speedtest.net/result/{}".format(args[0]), timeout=3)
@@ -11,7 +11,7 @@
BASE_URL = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet," \
"statistics&key={}".format(dave.config.config["api_keys"]["youtube"])
@dave.module.match(r'http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?')
@dave.module.match(r'.*https?://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)([\w\-\_]*)(&(amp;)?[\w\=]*)?.*')
@dave.module.dont_always_run_if_run()
def youtubevideo(bot, args, sender, source):
"""Ran whenever a YouTube video is sent"""