Skip to content

Commit

Permalink
reddit: add flair text to link/submission output
Browse files Browse the repository at this point in the history
  • Loading branch information
dgw committed Nov 9, 2021
1 parent 4a97936 commit 7847f4a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions sopel/modules/reddit.py
Expand Up @@ -143,10 +143,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)
Expand Down Expand Up @@ -205,9 +209,10 @@ def say_post_info(bot, trigger, id_, show_link=True, show_comments_link=False):

title = html.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:
Expand Down

0 comments on commit 7847f4a

Please sign in to comment.