From c38aeec342d7eb8a7cef3379bb4e839b45c49b3a Mon Sep 17 00:00:00 2001 From: Nick80835 Date: Wed, 17 Jun 2020 13:24:29 -0400 Subject: [PATCH] add random useless facts --- ubot/modules/memes.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ubot/modules/memes.py b/ubot/modules/memes.py index 2c576bd..8156066 100644 --- a/ubot/modules/memes.py +++ b/ubot/modules/memes.py @@ -136,6 +136,18 @@ async def dadjoke(event): await event.reply(dad_joke) +@ldr.add("fact") +async def randomfact(event): + async with ldr.aioclient.get("https://uselessfacts.jsph.pl/random.json", params={"language": "en"}) as response: + if response.status == 200: + random_fact = (await response.json())["text"].replace("`", "'") + else: + await event.reply(f"An error occured: **{response.status}**") + return + + await event.reply(random_fact) + + async def shitpostify(text): text = text.replace("dick", "peepee") text = text.replace("ck", "cc")