From f48fbb1d4f85a5ce761a690b7f895cdff8fb3832 Mon Sep 17 00:00:00 2001 From: dgw Date: Tue, 7 Dec 2021 13:33:38 -0600 Subject: [PATCH] Backport pull request #2209 reddit: add flair text to link/submission output --- sopel/modules/reddit.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sopel/modules/reddit.py b/sopel/modules/reddit.py index 526548c389..806d135a43 100644 --- a/sopel/modules/reddit.py +++ b/sopel/modules/reddit.py @@ -155,10 +155,14 @@ def say_post_info(bot, trigger, id_, show_link=True, show_comments_link=False): s = bot.memory['reddit_praw'].submission(id=id_) message = ( - '{title} {link}{nsfw} | {points} {points_text} ({percent}) | ' - '{comments} {comments_text} | Posted by {author} | ' + '{title}{flair} {link}{nsfw} | {points} {points_text} ({percent}) ' + '| {comments} {comments_text} | Posted by {author} | ' 'Created at {created}{comments_link}') + flair = '' + if s.link_flair_text: + flair = " ('{}' flair)".format(s.link_flair_text) + subreddit = s.subreddit.display_name if not show_link: link = 'to r/{}'.format(subreddit) @@ -217,9 +221,10 @@ def say_post_info(bot, trigger, id_, show_link=True, show_comments_link=False): title = unescape(s.title) message = message.format( - title=title, link=link, nsfw=nsfw, points=s.score, points_text=points_text, - percent=percent, comments=s.num_comments, comments_text=comments_text, - author=author, created=created, comments_link=comments_link) + title=title, flair=flair, link=link, nsfw=nsfw, points=s.score, + points_text=points_text, percent=percent, comments=s.num_comments, + comments_text=comments_text, author=author, created=created, + comments_link=comments_link) bot.say(message) except prawcore.exceptions.NotFound: