clash-telegram-bot/utils/updater.py

25 lines
537 B
Python
Raw Permalink Normal View History

2022-03-19 00:58:59 +03:00
import asyncio
import aioschedule as schedule
from load import coc_api
from database.worker import get_users, register
async def check_update():
users = get_users()
if users is None:
return
for user in users:
user_id = user["user_id"]
tag = user['tag']
data = coc_api.get_player(tag)
register(user_id, data, task_update=True)
async def updater():
schedule.every(1).hour.do(check_update)
while True:
await schedule.run_pending()
await asyncio.sleep(5)