aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2021-05-05 11:49:59 +0100
committerGravatar GitHub <[email protected]>2021-05-05 11:49:59 +0100
commitdf11cd19833d73b2bdc444c7bdf87f5e8d83106a (patch)
tree8788b5bd1c541a98ce2af22ff52bb619d0e1f400
parentMerge pull request #1517 from python-discord/is-vs-== (diff)
parentMerge branch 'main' into master (diff)
Merge pull request #1441 from asleep-cult/master
Unescape html escape characters in reddit text and titles
-rw-r--r--bot/exts/info/reddit.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/bot/exts/info/reddit.py b/bot/exts/info/reddit.py
index 6790be762..e1f0c5f9f 100644
--- a/bot/exts/info/reddit.py
+++ b/bot/exts/info/reddit.py
@@ -4,6 +4,7 @@ import random
import textwrap
from collections import namedtuple
from datetime import datetime, timedelta
+from html import unescape
from typing import List
from aiohttp import BasicAuth, ClientError
@@ -179,8 +180,7 @@ class Reddit(Cog):
for post in posts:
data = post["data"]
- text = data["selftext"]
- if text:
+ if text := unescape(data["selftext"]):
text = textwrap.shorten(text, width=128, placeholder="...")
text += "\n" # Add newline to separate embed info
@@ -188,7 +188,7 @@ class Reddit(Cog):
comments = data["num_comments"]
author = data["author"]
- title = textwrap.shorten(data["title"], width=64, placeholder="...")
+ title = textwrap.shorten(unescape(data["title"]), width=64, placeholder="...")
# Normal brackets interfere with Markdown.
title = escape_markdown(title).replace("[", "⦋").replace("]", "⦌")
link = self.URL + data["permalink"]