Skip to content

Commit f48fbb1

Browse files
committed
Backport pull request #2209
reddit: add flair text to link/submission output
1 parent ff366f5 commit f48fbb1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

sopel/modules/reddit.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,14 @@ def say_post_info(bot, trigger, id_, show_link=True, show_comments_link=False):
155155
s = bot.memory['reddit_praw'].submission(id=id_)
156156

157157
message = (
158-
'{title} {link}{nsfw} | {points} {points_text} ({percent}) | '
159-
'{comments} {comments_text} | Posted by {author} | '
158+
'{title}{flair} {link}{nsfw} | {points} {points_text} ({percent}) '
159+
'| {comments} {comments_text} | Posted by {author} | '
160160
'Created at {created}{comments_link}')
161161

162+
flair = ''
163+
if s.link_flair_text:
164+
flair = " ('{}' flair)".format(s.link_flair_text)
165+
162166
subreddit = s.subreddit.display_name
163167
if not show_link:
164168
link = 'to r/{}'.format(subreddit)
@@ -217,9 +221,10 @@ def say_post_info(bot, trigger, id_, show_link=True, show_comments_link=False):
217221

218222
title = unescape(s.title)
219223
message = message.format(
220-
title=title, link=link, nsfw=nsfw, points=s.score, points_text=points_text,
221-
percent=percent, comments=s.num_comments, comments_text=comments_text,
222-
author=author, created=created, comments_link=comments_link)
224+
title=title, flair=flair, link=link, nsfw=nsfw, points=s.score,
225+
points_text=points_text, percent=percent, comments=s.num_comments,
226+
comments_text=comments_text, author=author, created=created,
227+
comments_link=comments_link)
223228

224229
bot.say(message)
225230
except prawcore.exceptions.NotFound:

0 commit comments

Comments
 (0)