diff --git a/sopel/modules/reddit.py b/sopel/modules/reddit.py index 6825c53ed5..1fa120d4e4 100644 --- a/sopel/modules/reddit.py +++ b/sopel/modules/reddit.py @@ -34,7 +34,7 @@ ) short_post_url = r'https?://(redd\.it|reddit\.com)/(?P[\w-]+)/?$' user_url = r'%s/u(?:ser)?/([\w-]+)' % domain -image_url = r'https?://i\.redd\.it/\S+' +image_url = r'https?://(?Pi|preview)\.redd\.it/(?P[^?\s]+)' video_url = r'https?://v\.redd\.it/([\w-]+)' gallery_url = r'https?://(?:www\.)?reddit\.com/gallery/([\w-]+)' @@ -88,6 +88,9 @@ def get_is_cakeday(entrytime): @plugin.output_prefix(PLUGIN_OUTPUT_PREFIX) def image_info(bot, trigger, match): url = match.group(0) + preview = match.group("subdomain") == "preview" + if preview: + url = "https://i.redd.it/{}".format(match.group("image")) results = list( bot.memory['reddit_praw'] .subreddit('all') @@ -98,7 +101,7 @@ def image_info(bot, trigger, match): except IndexError: # Fail silently if the image link can't be mapped to a submission return plugin.NOLIMIT - return say_post_info(bot, trigger, oldest.id, False, True) + return say_post_info(bot, trigger, oldest.id, preview, True) @plugin.url(video_url)