73 lines
1.6 KiB
Python
73 lines
1.6 KiB
Python
import asyncio
|
|
import logging
|
|
import sys
|
|
|
|
from aiogram import Bot, Dispatcher
|
|
from aiogram.client.default import DefaultBotProperties
|
|
from aiogram.enums import ParseMode
|
|
from aiogram.types import ErrorEvent
|
|
from aiogram_dialog import setup_dialogs
|
|
from environs import Env
|
|
|
|
from bot.commands import command_router
|
|
from bot.database import initialize_database
|
|
from bot.dialogs import (
|
|
admin_dialog,
|
|
distribution_dialog,
|
|
gift_balance_dialog,
|
|
history_dialog,
|
|
profile_dialog,
|
|
purchase_accounts_dialog,
|
|
start_dialog,
|
|
take_balance_dialog,
|
|
up_balance_cryptobot_dialog,
|
|
up_balance_dialog,
|
|
up_balance_lolz_dialog,
|
|
)
|
|
|
|
|
|
async def on_error(event: ErrorEvent, bot: Bot):
|
|
logging.error(f"An error occurred: {event.exception}", exc_info=True)
|
|
|
|
|
|
async def main():
|
|
env = Env()
|
|
env.read_env()
|
|
|
|
bot = Bot(
|
|
token=env("BOT_TOKEN"), default=DefaultBotProperties(parse_mode=ParseMode.HTML)
|
|
)
|
|
dp = Dispatcher()
|
|
|
|
await initialize_database()
|
|
|
|
ROUTERS = [
|
|
command_router,
|
|
admin_dialog,
|
|
distribution_dialog,
|
|
gift_balance_dialog,
|
|
take_balance_dialog,
|
|
start_dialog,
|
|
purchase_accounts_dialog,
|
|
history_dialog,
|
|
profile_dialog,
|
|
up_balance_dialog,
|
|
up_balance_cryptobot_dialog,
|
|
up_balance_lolz_dialog,
|
|
]
|
|
|
|
for router in ROUTERS:
|
|
dp.include_router(router)
|
|
|
|
dp.error.register(on_error)
|
|
setup_dialogs(dp)
|
|
try:
|
|
await dp.start_polling(bot)
|
|
finally:
|
|
await bot.session.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
|
|
asyncio.run(main())
|