From 7666932ff1ea629b7928ba1156427210ef752141 Mon Sep 17 00:00:00 2001 From: Mark Hoekveen Date: Wed, 7 Apr 2021 22:15:56 +0200 Subject: [PATCH] Nieuwe coronastats --- Shitpost.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Shitpost.py b/Shitpost.py index 3dfc603..df81175 100644 --- a/Shitpost.py +++ b/Shitpost.py @@ -122,7 +122,7 @@ class Shitpost(commands.Cog): @commands.command(pass_context=True, hidden=False) @asyncio.coroutine - def corona(self, ctx): + def coronaold(self, ctx): try: yield from ctx.message.delete() except: @@ -141,6 +141,30 @@ class Shitpost(commands.Cog): message += "Ook liggen er " + str(answer[0]["critical"]) + " mensen op de IC 🏥" yield from ctx.channel.send(ctx.author.mention + ' ' + str(message)) + @commands.command(pass_context=True, hidden=False) + @asyncio.coroutine + def corona(self, ctx): + try: + yield from ctx.message.delete() + except: + print("No permission to delete message") + params = ( + ('minimal/', 'true'), + ('format/', 'json') + ) + response = requests.get('https://covid.ourworldindata.org/data/latest/owid-covid-latest.json') + answer = json.loads(response.content.decode('utf-8')) + d = answer["NLD"] + message = f"Dit is mijn informatie van **{d['last_updated_date']}**: \n\n" + message += f"Er zijn in Nederland {d['total_cases']:.0f} bevestigde gevallen 😷" + message += f" dat is 🔺{d['new_cases']:.0f}🔺 meer dan de dag er voor! \n" + message += f"Er zijn ondertussen {d['total_deaths']:.0f} mensen dood 💀" + message += f" waarvan {d['new_deaths']:.0f} ☠️ in de meest recente 24 uur. \n" + message += f"Er zijn ondertussen {d['people_vaccinated']:.0f} mensen gevaccineerd! 💉 " + message += f"En het r-getal is {d['reproduction_rate']}!\n\n" + message += "*Data van https://ourworldindata.org/coronavirus*" + yield from ctx.channel.send(ctx.author.mention + ' ' + str(message)) + @commands.command(pass_context=True, hidden=False) @asyncio.coroutine def viertwintig(self, ctx):