diff --git a/Shitpost.py b/Shitpost.py index c22215f..891bdf2 100644 --- a/Shitpost.py +++ b/Shitpost.py @@ -805,3 +805,22 @@ class Shitpost(commands.Cog): topic = " ".join(args) message = self.get_review_string(topic) await ctx.channel.send(message) + + def get_zaagmans(self): + zaagman_url = "http://iszaagmansallangsgeweest.nl/" + zreq = requests.get(zaagman_url) + if zreq: + return zreq.text.partition("

")[2].partition("

")[0] + else: + return None + + @commands.command(pass_context=True) + async def zaagmans(self, ctx): + """Is zaagmans al langsgeweest? Is de week al doormidden. Wie weet.""" + gezaagd = self.get_zaagmans() + message = ctx.author.mention + ": " + if gezaagd: + message += gezaagd + else: + message += "De waarheid over zaagmans is niet te doorgronden." + await ctx.channel.send(message) \ No newline at end of file diff --git a/tests/shitpost.py b/tests/shitpost.py index 0d560e7..0064b72 100644 --- a/tests/shitpost.py +++ b/tests/shitpost.py @@ -3,6 +3,7 @@ import dotenv import os import discord import requests +from datetime import datetime from discord.ext import commands import Shitpost @@ -169,3 +170,10 @@ class TestShitpost(unittest.TestCase): message = self.cog.zalgofy(inmsg) self.assertIsInstance(message, str) self.assertEqual(len(message), len(inmsg)*5) + + def test_zaagmans(self): + zaag = self.cog.get_zaagmans() + if zaag is None: + self.skipTest(f"Server at iszaagmansallangsgeweest.nl has an error, or is unavailable") + else: + self.assertIsInstance(zaag, str)