2024-02-12 10:55:14 +03:00
|
|
|
from src.core.routers import include_routers
|
|
|
|
from src.modules.standard.config.config import get_telegram_token
|
|
|
|
from src.modules.standard.database.api import connect_database, create_tables
|
2023-11-30 16:23:37 +03:00
|
|
|
|
|
|
|
from asyncio import run
|
|
|
|
from aiogram import Bot, Dispatcher
|
|
|
|
|
2024-02-05 15:51:50 +03:00
|
|
|
|
2024-02-12 10:55:14 +03:00
|
|
|
async def main(bot: Bot):
|
2023-11-30 16:23:37 +03:00
|
|
|
try:
|
2024-02-12 10:55:14 +03:00
|
|
|
database, path = connect_database()
|
|
|
|
database.connect()
|
|
|
|
create_tables(database)
|
2023-12-10 19:04:17 +03:00
|
|
|
|
2023-11-30 16:23:37 +03:00
|
|
|
dp = Dispatcher()
|
2024-02-12 10:55:14 +03:00
|
|
|
await include_routers(dp)
|
2023-11-30 16:23:37 +03:00
|
|
|
await dp.start_polling(bot)
|
|
|
|
|
|
|
|
finally:
|
|
|
|
await bot.session.close()
|
2023-12-10 19:04:17 +03:00
|
|
|
database.close()
|
2023-11-30 16:23:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2024-02-12 10:55:14 +03:00
|
|
|
bot = Bot(token=get_telegram_token())
|
|
|
|
run(main(bot))
|