This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
covid-19-discord-bot/lib/covid_report_lib.py
2020-03-26 00:08:46 -05:00

24 lines
916 B
Python

#!/bin/python
try:
from parse_data import update_data, get_covid_data
except:
from lib.parse_data import update_data, get_covid_data
from datetime import datetime
from pytz import timezone
from asyncio import sleep
async def background_task(client):
await client.wait_until_ready()
with open('.keys/report_channel_id') as cid:
channel = client.get_channel(int(cid.readline().strip()))
while not client.is_closed():
current_hour_and_minute = [int(t) for t in str(
datetime.now(timezone('US/Central')).time()).split(':')[:-1]]
if(current_hour_and_minute[0] == 12 and (current_hour_and_minute[1] == 0)):
update_data()
await channel.send('Daily report from: https://www.worldometers.info/coronavirus/')
await channel.send(get_covid_data('USA'))
await channel.send(get_covid_data('TOTAL'))
await sleep(60)