import asyncio from aiogram import Dispatcher, F from aiogram.filters import Command from app.callbacks.callback_docker import ContainerCallback, ActionCallback from app.callbacks.callback_favorites import AddFavoriteCallback, DelFavoriteCallback from app.handlers.docker_commands import get_containers, container_actions, do_container_action from app.handlers.events import start_bot, stop_bot from app.handlers.favorites import favorites_command, add_favorite_callback, add_favorite_state, del_favorite_callback, \ del_favorite_state from app.handlers.multiply_commands import multiply_commands, execute_commands from app.handlers.simple import start_command from app.handlers.single_command import execute_command from app.middlewares.admin_middleware import AdminMiddleware from app.settings import bot from app.utils.statesform import ExecuteCommandsSteps, FavoritesCommandsSteps async def start(): dp = Dispatcher() dp.update.middleware(AdminMiddleware()) dp.startup.register(start_bot) dp.shutdown.register(stop_bot) dp.message.register(start_command, Command(commands="start")) dp.message.register(execute_command, Command(commands="command")) dp.message.register(multiply_commands, Command(commands="multiply_commands")) dp.message.register(get_containers, Command(commands="docker_list")) dp.message.register(favorites_command, Command(commands="favorites")) dp.callback_query.register(container_actions, ContainerCallback.filter()) dp.callback_query.register(do_container_action, ActionCallback.filter()) dp.callback_query.register(add_favorite_callback, AddFavoriteCallback.filter()) dp.callback_query.register(del_favorite_callback, DelFavoriteCallback.filter()) dp.message.register(execute_commands, ExecuteCommandsSteps.EXECUTE) dp.message.register(add_favorite_state, FavoritesCommandsSteps.ADD) dp.message.register(del_favorite_state, FavoritesCommandsSteps.DEL) try: await dp.start_polling(bot) finally: await bot.session.close() if __name__ == "__main__": asyncio.run(start())