aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/evergreen/cheatsheet.py
diff options
context:
space:
mode:
authorGravatar Xithrius <[email protected]>2021-02-11 23:09:08 -0800
committerGravatar GitHub <[email protected]>2021-02-11 23:09:08 -0800
commite748bc968eff3e3671d82e1a904f8e94463935e4 (patch)
treee61cfb617b90a11ddd5d3b306328a835e7453b9e /bot/exts/evergreen/cheatsheet.py
parentAdds Category Channels To Error Message (diff)
parentMerge pull request #582 from python-discord/wolfram-mock-locations (diff)
Merge branch 'master' into upgrade-override
Diffstat (limited to 'bot/exts/evergreen/cheatsheet.py')
-rw-r--r--bot/exts/evergreen/cheatsheet.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/bot/exts/evergreen/cheatsheet.py b/bot/exts/evergreen/cheatsheet.py
index 8e61f63e..3fe709d5 100644
--- a/bot/exts/evergreen/cheatsheet.py
+++ b/bot/exts/evergreen/cheatsheet.py
@@ -26,6 +26,8 @@ If the problem persists send a message in <#{Channels.dev_contrib}>
URL = 'https://cheat.sh/python/{search}'
ESCAPE_TT = str.maketrans({"`": "\\`"})
ANSI_RE = re.compile(r"\x1b\[.*?m")
+# We need to pass headers as curl otherwise it would default to aiohttp which would return raw html.
+HEADERS = {'User-Agent': 'curl/7.68.0'}
class CheatSheet(commands.Cog):
@@ -86,7 +88,7 @@ class CheatSheet(commands.Cog):
search_string = quote_plus(" ".join(search_terms))
async with self.bot.http_session.get(
- URL.format(search=search_string)
+ URL.format(search=search_string), headers=HEADERS
) as response:
result = ANSI_RE.sub("", await response.text()).translate(ESCAPE_TT)