add auto update the reserve base

This commit is contained in:
2024-06-09 18:15:47 +07:00
parent 9661bbe43a
commit 0aa14b1c0e
4 changed files with 385 additions and 385 deletions
+20 -2
View File
@@ -1,5 +1,5 @@
import asyncio
from datetime import datetime
from datetime import datetime, timedelta
from aiogram import Dispatcher, Bot, F
from aiogram.client.default import DefaultBotProperties
@@ -8,7 +8,9 @@ from aiogram.filters import Command
from aiogram.types import Message
from DB import UseDB
from additional_functions import on_notification, set_group, timetable_for_day, timetable_day
from additional_functions import (on_notification, set_group, timetable_for_day,
timetable_day)
from use_database import detect_group_to_update
TOKEN = "7171391557:AAGickIyKK-kCAWUO4V_5X3m1_6F4Cmgmdw"
dp = Dispatcher()
@@ -81,9 +83,25 @@ async def send_notification(bot):
await asyncio.sleep(59)
async def update_data():
while True:
now = datetime.now()
next_midnight = (
now + timedelta(days=1)
).replace(
hour=0,
minute=0,
second=0,
microsecond=0
)
await asyncio.sleep((next_midnight - now).total_seconds())
detect_group_to_update()
async def main() -> None:
bot = Bot(TOKEN, default=DefaultBotProperties(parse_mode=ParseMode.HTML))
_ = asyncio.create_task(send_notification(bot))
_ = asyncio.create_task(update_data())
await dp.start_polling(bot)
if __name__ == "__main__":