23 lines
1 KiB
Python
23 lines
1 KiB
Python
#!/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
|
|
from math import floor
|
|
|
|
|
|
async def background_task(client, config_dict):
|
|
await client.wait_until_ready()
|
|
update_data()
|
|
channel = client.get_channel(config_dict['report_channel_id'])
|
|
while not client.is_closed():
|
|
current_hour_and_minute = [int(t) for t in str(
|
|
datetime.now(timezone(config_dict['report_timezones'])).time()).split(':')[:-1]]
|
|
for rt in config_dict['report_times']:
|
|
if(current_hour_and_minute[0] == floor(rt/100) and (current_hour_and_minute[1] == rt % 100)):
|
|
update_data()
|
|
await channel.send('Daily report from: https://www.worldometers.info/coronavirus/')
|
|
for selection in config_dict['report_selections']:
|
|
await channel.send(get_covid_data(selection))
|
|
await channel.send(get_top_data(config_dict['report_top_number']))
|
|
await sleep(60)
|