add auto update the reserve base
This commit is contained in:
@@ -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__":
|
||||
|
||||
Reference in New Issue
Block a user