mirror of
https://github.com/snoups/remnashop.git
synced 2026-04-20 18:03:11 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
@@ -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",
|
||||
#
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user