intra_max_chatbot/bot/bot_instance.py
2026-03-26 00:54:10 +03:00

20 lines
473 B
Python

"""Глобальное хранилище экземпляра бота для доступа из admin-панели."""
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from maxapi.bot import Bot
_bot: "Bot | None" = None
def set_bot(bot: "Bot") -> None:
global _bot
_bot = bot
def get_bot() -> "Bot":
if _bot is None:
raise RuntimeError("Bot not initialized — call set_bot() first")
return _bot