intra_max_chatbot/bot/setup.py
2026-04-03 00:30:24 +03:00

28 lines
868 B
Python

from maxapi.bot import Bot
from maxapi.context import MemoryContext
from maxapi.dispatcher import Dispatcher, Router
import config
from bot.bot_instance import set_bot
from bot.middleware import AuthMiddleware
from bot.handlers import start, menu, create_ticket, view_tickets, quick_reply
def create_bot_and_dispatcher() -> tuple[Bot, Dispatcher]:
bot = Bot(token=config.BOT_TOKEN)
bot.headers["Accept-Encoding"] = "gzip, deflate"
set_bot(bot)
dp = Dispatcher(router_id="main", storage=MemoryContext)
dp.outer_middleware(AuthMiddleware())
# Подключаем роутеры
dp.include_routers(
start.router,
menu.router,
create_ticket.router,
view_tickets.router,
quick_reply.router, # последним — catch-all для свободных сообщений
)
return bot, dp