-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (23 loc) · 824 Bytes
/
main.py
File metadata and controls
30 lines (23 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import asyncio
import logging
from datetime import datetime, timedelta
from aiogram import Bot, Dispatcher
from config_reader import config
from handlers import basic_handlers, work_handlers
from parsing_bd.DB_func import check
logging.basicConfig(level=logging.INFO)
async def timer():
while True:
now = datetime.now()
next_day = (now + timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0)
wait_time = (next_day - now).total_seconds()
check()
await asyncio.sleep(wait_time)
async def main():
bot = Bot(token=config.bot_token.get_secret_value())
dp = Dispatcher()
dp.include_routers(basic_handlers.router, work_handlers.router)
asyncio.create_task(timer())
await dp.start_polling(bot)
if __name__ == "__main__":
asyncio.run(main())