feat: add BotInlineModeDisabledEvent notification on startup

- added BotInlineModeDisabledEvent with admin notification and setup instructions
- publish BotInlineModeDisabledEvent on startup if inline mode is not enabled in BotFather
- updated warning log message to mention BotFather
This commit is contained in:
Ilay
2026-04-10 17:44:00 +05:00
parent 053ada0796
commit a39304b66c
4 changed files with 35 additions and 1 deletions

View File

@@ -106,6 +106,17 @@ event-bot =
}
</blockquote>
.inline-mode-disabled =
#BotInlineModeDisabledEvent
<b>⚠️ Событие: Inline-режим отключён в BotFather!</b>
<blockquote>
Бот не настроен для работы в inline-режиме. Некоторые функции бота могут работать некорректно.
Включите Inline Mode в BotFather: <b>@BotFather → /mybots → Bot Settings → Inline Mode → Enable</b>
</blockquote>
.shutdown =
#BotShutdownEvent

View File

@@ -1,5 +1,6 @@
from .base import BaseEvent, SystemEvent, UserEvent
from .system import (
BotInlineModeDisabledEvent,
BotShutdownEvent,
BotStartupEvent,
BotUpdateEvent,
@@ -36,6 +37,7 @@ __all__ = [
"ErrorEvent",
"NotificationErrorEvent",
"WebhookErrorEvent",
"BotInlineModeDisabledEvent",
"RemnawaveErrorEvent",
"RemnawaveVersionWarningEvent",
#

View File

@@ -122,6 +122,25 @@ class RemnawaveVersionWarningEvent(SystemEvent, BuildInfoDto):
)
@dataclass(frozen=True, kw_only=True)
class BotInlineModeDisabledEvent(SystemEvent):
notification_type: NotificationType = field(
default=SystemNotificationType.SYSTEM,
init=False,
)
@property
def event_key(self) -> str:
return "event-bot.inline-mode-disabled"
def as_payload(self) -> "MessagePayloadDto":
return MessagePayloadDto(
i18n_key=self.event_key,
disable_default_markup=False,
delete_after=None,
)
@dataclass(frozen=True, kw_only=True)
class WebhookErrorEvent(SystemEvent):
notification_type: NotificationType = field(

View File

@@ -13,6 +13,7 @@ from redis.asyncio import Redis
from src.application.common import Remnawave
from src.application.common.dao import SettingsDao
from src.application.events import (
BotInlineModeDisabledEvent,
BotShutdownEvent,
BotStartupEvent,
RemnawaveErrorEvent,
@@ -55,8 +56,9 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
if not await bot_service.is_inline_enabled():
logger.warning(
"Bot is not enabled for inline mode. "
"Please set BOT_INLINE_MODE to True for correct work of some features"
"Please enable Inline Mode in BotFather for correct work of some features"
)
await event_bus.publish(BotInlineModeDisabledEvent())
states = await bot_service.get_bot_states()
await create_default_payment_gateway.system()