Auto-updater player info
This commit is contained in:
24
utils/updater.py
Normal file
24
utils/updater.py
Normal file
@@ -0,0 +1,24 @@
|
||||
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)
|
Reference in New Issue
Block a user