Skip to content

Commit 377cbd6

Browse files
authored
Merge pull request #2209 from sopel-irc/reddit-flair
reddit: add flair text to link/submission output
2 parents 831f797 + 7847f4a commit 377cbd6

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
@@ -143,10 +143,14 @@ def say_post_info(bot, trigger, id_, show_link=True, show_comments_link=False):
143143
s = bot.memory['reddit_praw'].submission(id=id_)
144144

145145
message = (
146-
'{title} {link}{nsfw} | {points} {points_text} ({percent}) | '
147-
'{comments} {comments_text} | Posted by {author} | '
146+
'{title}{flair} {link}{nsfw} | {points} {points_text} ({percent}) '
147+
'| {comments} {comments_text} | Posted by {author} | '
148148
'Created at {created}{comments_link}')
149149

150+
flair = ''
151+
if s.link_flair_text:
152+
flair = " ('{}' flair)".format(s.link_flair_text)
153+
150154
subreddit = s.subreddit.display_name
151155
if not show_link:
152156
link = 'to r/{}'.format(subreddit)
@@ -205,9 +209,10 @@ def say_post_info(bot, trigger, id_, show_link=True, show_comments_link=False):
205209

206210
title = html.unescape(s.title)
207211
message = message.format(
208-
title=title, link=link, nsfw=nsfw, points=s.score, points_text=points_text,
209-
percent=percent, comments=s.num_comments, comments_text=comments_text,
210-
author=author, created=created, comments_link=comments_link)
212+
title=title, flair=flair, link=link, nsfw=nsfw, points=s.score,
213+
points_text=points_text, percent=percent, comments=s.num_comments,
214+
comments_text=comments_text, author=author, created=created,
215+
comments_link=comments_link)
211216

212217
bot.say(message)
213218
except prawcore.exceptions.NotFound:

0 commit comments

Comments
 (0)