diff options
| author | 2021-03-01 09:51:49 -0500 | |
|---|---|---|
| committer | 2021-03-01 09:51:49 -0500 | |
| commit | fcf0a82296ddf1c46623b14ca0bfca6d50514242 (patch) | |
| tree | f69fa30c6f4c574fde12bdb54ed517c1bd83c35f | |
| parent | Merge pull request #1440 from bast0006/master (diff) | |
Unescape html escape characters in reddit text and titles
| -rw-r--r-- | bot/exts/info/reddit.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bot/exts/info/reddit.py b/bot/exts/info/reddit.py index 6790be762..3630a02ee 100644 --- a/bot/exts/info/reddit.py +++ b/bot/exts/info/reddit.py @@ -2,6 +2,7 @@ import asyncio import logging import random import textwrap +import html from collections import namedtuple from datetime import datetime, timedelta from typing import List @@ -179,7 +180,7 @@ class Reddit(Cog): for post in posts: data = post["data"] - text = data["selftext"] + text = html.unescape(data["selftext"]) if text: text = textwrap.shorten(text, width=128, placeholder="...") text += "\n" # Add newline to separate embed info @@ -188,7 +189,8 @@ class Reddit(Cog): comments = data["num_comments"] author = data["author"] - title = textwrap.shorten(data["title"], width=64, placeholder="...") + title = html.unescape(data["title"]) + title = textwrap.shorten(title, width=64, placeholder="...") # Normal brackets interfere with Markdown. title = escape_markdown(title).replace("[", "⦋").replace("]", "⦌") link = self.URL + data["permalink"] |