clash-telegram-bot/utils/updater.py
2022-03-18 23:58:59 +02:00

25 lines
537 B
Python

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)