#!/bin/python
from lib.parse_data import update_data, get_covid_data, get_top_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 channel.send(get_top_data(5))
await sleep(60)