zov-tech/bot/main.py
wasrusgen e5c51a844b bot: CRM на меню-кнопке + новый текст приветствия
Менюшная кнопка слева от ввода: «Кабинет» → «CRM».

Welcome /start:
  Здравствуйте, Добрый человек 🙂
  Я CRM @wasrusgen1!
  Вы кто?
2026-05-13 22:44:49 +03:00

52 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import asyncio
import logging
from aiogram import Bot, Dispatcher
from aiogram.client.default import DefaultBotProperties
from aiogram.enums import ParseMode
from aiogram.types import MenuButtonWebApp, WebAppInfo
from config import load_config
from handlers import start
async def main() -> None:
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
)
config = load_config()
bot = Bot(
token=config.bot_token,
default=DefaultBotProperties(parse_mode=ParseMode.HTML),
)
dp = Dispatcher()
dp["config"] = config
dp.include_router(start.router)
if config.use_webhook:
raise NotImplementedError("Webhook mode будет добавлен после MVP")
# Универсальная меню-кнопка — открывает MiniApp одним тапом.
# Внутри MiniApp пользователь выбирает роль (менеджер/клиент/сотрудник).
try:
await bot.set_chat_menu_button(
menu_button=MenuButtonWebApp(
text="CRM",
web_app=WebAppInfo(url=config.miniapp_url),
),
)
logging.info("Установлена меню-кнопка MiniApp: %s", config.miniapp_url)
except Exception as e:
logging.warning("Не удалось установить меню-кнопку: %s", e)
logging.info("Запуск в режиме polling")
await bot.delete_webhook(drop_pending_updates=True)
await dp.start_polling(bot)
if __name__ == "__main__":
asyncio.run(main())