refactor(schemas): 统一 message/notification 命名边界,旧名收敛至兼容映射表

- notification 域:渠道能力(MessageChannel→NotificationChannel、ChannelCapability* 迁入 notification.py)
- message 域:消息收发(Notification→Message、NotificationType→MessageType、CommingMessage→IncomingMessage、NotificationHistoryItem→MessageHistoryItem、NotificationClear*→MessageClear*)
- Agent 工具契约:send_notification_message→send_message、notification_callback→message_callback
- 源码不保留旧名物理别名,旧导入经 app/runtime/compat/manifest.py SYMBOL_ALIASES 惰性解析
- API 路径与持久化键冻结不变,前端零改动
- 新增兼容守护测试与 docs/rules/07 命名边界规范
This commit is contained in:
jxxghp
2026-08-16 19:32:20 +08:00
parent 98276a68a8
commit 240a4dffe6
96 changed files with 1975 additions and 1751 deletions
+5 -5
View File
@@ -5,7 +5,7 @@ from queue import Queue
from threading import Lock
from typing import Callable, Dict, Iterable, List, Optional, Tuple, Union
from app.schemas.types import MessageChannel
from app.schemas.types import NotificationChannel
# Agent 选择按钮回调前缀(新旧两种格式都必须继续兼容)
AGENT_CHOICE_PREFIX = "agent_interaction:choice:"
@@ -180,7 +180,7 @@ _CHANNEL_ADMIN_RESOLVERS: dict[str, _ChannelAdminResolver] = {}
def register_channel_admin_resolver(
channel: Union[MessageChannel, str],
channel: Union[NotificationChannel, str],
resolver: _ChannelAdminResolver,
) -> None:
"""
@@ -189,7 +189,7 @@ def register_channel_admin_resolver(
:param channel: 消息渠道
:param resolver: 由渠道配置解析全部管理员主体 ID 的函数
"""
channel_value = channel.value if isinstance(channel, MessageChannel) else str(channel)
channel_value = channel.value if isinstance(channel, NotificationChannel) else str(channel)
_CHANNEL_ADMIN_RESOLVERS[channel_value] = resolver
@@ -215,7 +215,7 @@ def resolve_config_principal_ids(
def matches_channel_admin(
channel: Union[MessageChannel, str],
channel: Union[NotificationChannel, str],
config: Optional[dict],
*principal_ids: Optional[Union[str, int]],
) -> bool:
@@ -227,7 +227,7 @@ def matches_channel_admin(
:param principal_ids: 消息渠道提供的稳定用户主体 ID
:return: 任一用户主体 ID 命中渠道注册的管理员集合时返回 True
"""
channel_value = channel.value if isinstance(channel, MessageChannel) else str(channel)
channel_value = channel.value if isinstance(channel, NotificationChannel) else str(channel)
resolver = _CHANNEL_ADMIN_RESOLVERS.get(channel_value)
if not resolver:
return False
+12 -12
View File
@@ -5,9 +5,9 @@ from datetime import datetime, timedelta
from threading import Lock
from typing import Any, Dict, List, Optional, Protocol, Sequence, Tuple, Union
from app.schemas import Notification
from app.schemas.message import ChannelCapabilityManager
from app.schemas.types import MessageChannel
from app.schemas import Message
from app.schemas.notification import ChannelCapabilityManager
from app.schemas.types import NotificationChannel
@dataclass
@@ -18,7 +18,7 @@ class PendingSlashInteraction:
request_id: str
user_id: str
channel: Optional[MessageChannel]
channel: Optional[NotificationChannel]
source: Optional[str]
username: Optional[str]
command: str
@@ -57,7 +57,7 @@ class SlashInteractionManager:
self,
user_id: Union[str, int],
command: str,
channel: Optional[MessageChannel],
channel: Optional[NotificationChannel],
source: Optional[str],
username: Optional[str],
) -> PendingSlashInteraction:
@@ -120,7 +120,7 @@ class SlashInteractionManager:
class InteractionContext:
"""描述一次与渠道无关的用户交互上下文。"""
channel: MessageChannel
channel: NotificationChannel
source: Optional[str]
user_id: Union[str, int]
username: Optional[str]
@@ -140,12 +140,12 @@ class InteractionDispatch:
class MessageGateway(Protocol):
"""声明交互控制器使用的消息发送和编辑能力。"""
def post_message(self, message: Notification): ...
def post_message(self, message: Message): ...
def edit_message(self, **kwargs) -> bool: ...
def supports_interaction_buttons(channel: Optional[MessageChannel]) -> bool:
def supports_interaction_buttons(channel: Optional[NotificationChannel]) -> bool:
"""
渠道同时支持按钮和回调时,优先使用按钮交互。
"""
@@ -156,7 +156,7 @@ def supports_interaction_buttons(channel: Optional[MessageChannel]) -> bool:
)
def supports_markdown(channel: Optional[MessageChannel]) -> bool:
def supports_markdown(channel: Optional[NotificationChannel]) -> bool:
"""
仅在支持 Markdown 的渠道上输出 Markdown 内容。
"""
@@ -213,7 +213,7 @@ def build_navigation_buttons(
def update_or_post_message(
chain,
channel: MessageChannel,
channel: NotificationChannel,
source: Optional[str],
userid: Union[str, int],
username: Optional[str],
@@ -232,7 +232,7 @@ def update_or_post_message(
and ChannelCapabilityManager.supports_editing(channel)
):
edit_kwargs = {}
if channel == MessageChannel.WebAgent:
if channel == NotificationChannel.WebAgent:
edit_kwargs["metadata"] = {"userid": userid}
edited = chain.edit_message(
channel=channel,
@@ -248,7 +248,7 @@ def update_or_post_message(
return
chain.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
+3 -3
View File
@@ -6,7 +6,7 @@ from typing import Any, Dict, List, Optional, Union
from app.domain.context import MediaInfo
from app.domain.meta.metabase import MetaBase
from app.schemas.types import MessageChannel
from app.schemas.types import NotificationChannel
@dataclass
@@ -17,7 +17,7 @@ class PendingMediaInteraction:
request_id: str
user_id: str
channel: Optional[MessageChannel]
channel: Optional[NotificationChannel]
source: Optional[str]
username: Optional[str]
action: str
@@ -69,7 +69,7 @@ class MediaInteractionManager:
def create_or_replace(
self,
user_id: Union[str, int],
channel: Optional[MessageChannel],
channel: Optional[NotificationChannel],
source: Optional[str],
username: Optional[str],
action: str,
+8 -8
View File
@@ -20,7 +20,7 @@ from app.domain.meta.metabase import MetaBase
from app.domain.meta.metamusic import MetaMusic
from app.db.oper.systemconfig import SystemConfigOper
from app.runtime.log import logger
from app.schemas.message import Notification
from app.schemas.message import Message
from app.schemas.tmdb import TmdbEpisode
from app.schemas.transfer import TransferInfo
from app.schemas.types import MUSIC_ENTITY_ALBUM, SystemConfigKey
@@ -657,7 +657,7 @@ class MessageTemplateHelper:
"""
@staticmethod
def render(message: Notification, *args, **kwargs) -> Optional[Notification]:
def render(message: Message, *args, **kwargs) -> Optional[Message]:
"""
渲染消息模板
"""
@@ -668,16 +668,16 @@ class MessageTemplateHelper:
return message
@staticmethod
def is_instance_valid(message: Notification) -> bool:
def is_instance_valid(message: Message) -> bool:
"""
检查消息是否有效
"""
if isinstance(message, Notification):
if isinstance(message, Message):
return bool(message.title or message.text)
return False
@staticmethod
def meets_update_conditions(message: Notification, *args, **kwargs) -> bool:
def meets_update_conditions(message: Message, *args, **kwargs) -> bool:
"""
判断是否满足消息实例更新条件
@@ -686,12 +686,12 @@ class MessageTemplateHelper:
2. 消息指定了模板类型(ctype)
3. 存在待渲染的模板变量数据
"""
if isinstance(message, Notification):
if isinstance(message, Message):
return True if message.ctype and (args or kwargs) else False
return False
@staticmethod
def _apply_template_data(message: Notification, *args, **kwargs) -> Optional[Notification]:
def _apply_template_data(message: Message, *args, **kwargs) -> Optional[Message]:
"""
更新消息实例
"""
@@ -717,7 +717,7 @@ class MessageTemplateHelper:
return message
@staticmethod
def _get_template(message: Notification) -> Optional[str]:
def _get_template(message: Message) -> Optional[str]:
"""
获取消息模板
"""
+23 -23
View File
@@ -6,8 +6,8 @@ from typing import Any, Dict, List, Optional, Tuple, Union
from app.application.messaging.interaction import InteractionContext, MessageGateway
from app.runtime.events import EventManager
from app.schemas import Notification
from app.schemas.types import EventType, MessageChannel
from app.schemas import Message
from app.schemas.types import EventType, NotificationChannel
@dataclass
@@ -19,7 +19,7 @@ class PendingPluginInputInteraction:
request_id: str
user_id: str
plugin_id: str
channel: Optional[MessageChannel]
channel: Optional[NotificationChannel]
source: Optional[str]
username: Optional[str]
chat_id: Optional[str] = None
@@ -48,9 +48,9 @@ class PluginInputInteractionManager:
def __init__(self):
"""初始化活动输入会话、用户渠道索引和过期墓碑。"""
self._by_id: Dict[str, PendingPluginInputInteraction] = {}
self._by_user_channel: Dict[Tuple[str, Optional[MessageChannel], Optional[str], Optional[str]], str] = {}
self._by_user_channel: Dict[Tuple[str, Optional[NotificationChannel], Optional[str], Optional[str]], str] = {}
self._expired_by_user_channel: Dict[
Tuple[str, Optional[MessageChannel], Optional[str], Optional[str]],
Tuple[str, Optional[NotificationChannel], Optional[str], Optional[str]],
PendingPluginInputInteraction,
] = {}
self._lock = Lock()
@@ -58,18 +58,18 @@ class PluginInputInteractionManager:
@staticmethod
def _user_channel_source_key(
user_id: Union[str, int],
channel: Optional[MessageChannel],
channel: Optional[NotificationChannel],
source: Optional[str] = None,
chat_id: Optional[Union[str, int]] = None,
) -> Tuple[str, Optional[MessageChannel], Optional[str], Optional[str]]:
) -> Tuple[str, Optional[NotificationChannel], Optional[str], Optional[str]]:
"""归一化用户、渠道、来源和会话 ID 的联合索引键。"""
return str(user_id), channel, source, str(chat_id) if chat_id not in (None, "") else None
@classmethod
def _keys_overlap(
cls,
left: Tuple[str, Optional[MessageChannel], Optional[str], Optional[str]],
right: Tuple[str, Optional[MessageChannel], Optional[str], Optional[str]],
left: Tuple[str, Optional[NotificationChannel], Optional[str], Optional[str]],
right: Tuple[str, Optional[NotificationChannel], Optional[str], Optional[str]],
) -> bool:
"""判断两个输入会话键是否会争用同一条用户回复。"""
left_user, left_channel, left_source, left_chat_id = left
@@ -116,7 +116,7 @@ class PluginInputInteractionManager:
self,
user_id: Union[str, int],
plugin_id: str,
channel: Optional[MessageChannel],
channel: Optional[NotificationChannel],
source: Optional[str],
username: Optional[str],
chat_id: Optional[Union[str, int]] = None,
@@ -151,7 +151,7 @@ class PluginInputInteractionManager:
normalized_chat_id = str(chat_id) if chat_id not in (None, "") else None
normalized_prompt_message_id = (
str(prompt_message_id)
if channel == MessageChannel.Telegram and normalized_chat_id and prompt_message_id not in (None, "")
if channel == NotificationChannel.Telegram and normalized_chat_id and prompt_message_id not in (None, "")
else None
)
@@ -175,7 +175,7 @@ class PluginInputInteractionManager:
def get_by_user(
self,
user_id: Union[str, int],
channel: Optional[MessageChannel] = None,
channel: Optional[NotificationChannel] = None,
source: Optional[str] = None,
chat_id: Optional[Union[str, int]] = None,
) -> Optional[PendingPluginInputInteraction]:
@@ -190,7 +190,7 @@ class PluginInputInteractionManager:
def pop_by_user(
self,
user_id: Union[str, int],
channel: Optional[MessageChannel] = None,
channel: Optional[NotificationChannel] = None,
source: Optional[str] = None,
chat_id: Optional[Union[str, int]] = None,
) -> Optional[PendingPluginInputInteraction]:
@@ -209,7 +209,7 @@ class PluginInputInteractionManager:
def consume_by_user(
self,
user_id: Union[str, int],
channel: Optional[MessageChannel] = None,
channel: Optional[NotificationChannel] = None,
source: Optional[str] = None,
chat_id: Optional[Union[str, int]] = None,
*,
@@ -275,7 +275,7 @@ class PluginInputInteractionManager:
def _find_request_id_locked(
self,
user_id: Union[str, int],
channel: Optional[MessageChannel],
channel: Optional[NotificationChannel],
source: Optional[str],
chat_id: Optional[Union[str, int]] = None,
) -> Optional[str]:
@@ -286,10 +286,10 @@ class PluginInputInteractionManager:
def _find_key_and_request_id_locked(
self,
user_id: Union[str, int],
channel: Optional[MessageChannel],
channel: Optional[NotificationChannel],
source: Optional[str],
chat_id: Optional[Union[str, int]] = None,
) -> Tuple[Optional[Tuple[str, Optional[MessageChannel], Optional[str], Optional[str]]], Optional[str]]:
) -> Tuple[Optional[Tuple[str, Optional[NotificationChannel], Optional[str], Optional[str]]], Optional[str]]:
"""返回首个候选键及其活动请求 ID。"""
for key in self._candidate_keys(user_id, channel, source, chat_id):
request_id = self._by_user_channel.get(key)
@@ -300,10 +300,10 @@ class PluginInputInteractionManager:
def _find_expired_key_and_request_locked(
self,
user_id: Union[str, int],
channel: Optional[MessageChannel],
channel: Optional[NotificationChannel],
source: Optional[str],
chat_id: Optional[Union[str, int]] = None,
) -> Tuple[Optional[Tuple[str, Optional[MessageChannel], Optional[str], Optional[str]]],
) -> Tuple[Optional[Tuple[str, Optional[NotificationChannel], Optional[str], Optional[str]]],
Optional[PendingPluginInputInteraction]]:
"""返回仍在宽限期内的过期会话及其索引键。"""
now = datetime.now()
@@ -320,10 +320,10 @@ class PluginInputInteractionManager:
def _candidate_keys(
self,
user_id: Union[str, int],
channel: Optional[MessageChannel],
channel: Optional[NotificationChannel],
source: Optional[str],
chat_id: Optional[Union[str, int]] = None,
) -> List[Tuple[str, Optional[MessageChannel], Optional[str], Optional[str]]]:
) -> List[Tuple[str, Optional[NotificationChannel], Optional[str], Optional[str]]]:
"""按精确到宽松顺序生成输入会话候选键。"""
chat_key = str(chat_id) if chat_id not in (None, "") else None
candidates = [
@@ -430,7 +430,7 @@ class PluginInputInteractionHandler:
},
)
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -461,7 +461,7 @@ class PluginInputInteractionHandler:
},
)
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
+16 -16
View File
@@ -15,8 +15,8 @@ from app.application.messaging.interaction import (
update_or_post_message,
)
from app.runtime.log import logger
from app.schemas import Notification
from app.schemas.types import MessageChannel
from app.schemas import Message
from app.schemas.types import NotificationChannel
site_interaction_manager = SlashInteractionManager()
@@ -44,7 +44,7 @@ class SiteInteractionHandler:
def remote_list(
self,
arg_str: str = "",
channel: MessageChannel = None,
channel: NotificationChannel = None,
userid: Union[str, int] = None,
source: Optional[str] = None,
):
@@ -90,7 +90,7 @@ class SiteInteractionHandler:
def handle_callback_interaction(
self,
callback_data: str,
channel: MessageChannel,
channel: NotificationChannel,
source: str,
userid: Union[str, int],
username: str,
@@ -108,7 +108,7 @@ class SiteInteractionHandler:
request = site_interaction_manager.get_by_id(request_id, userid)
if not request:
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -161,7 +161,7 @@ class SiteInteractionHandler:
def handle_text_interaction(
self,
channel: MessageChannel,
channel: NotificationChannel,
source: str,
userid: Union[str, int],
username: str,
@@ -184,7 +184,7 @@ class SiteInteractionHandler:
if lowered in {"退出", "关闭", "q", "quit", "exit"}:
site_interaction_manager.remove(request.request_id)
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -255,7 +255,7 @@ class SiteInteractionHandler:
success, message = self._update_site_cookie_from_input(normalized)
request.awaiting_input = None
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -276,7 +276,7 @@ class SiteInteractionHandler:
success, message = self._set_sites_enabled(normalized, enabled=True)
request.awaiting_input = None
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -297,7 +297,7 @@ class SiteInteractionHandler:
success, message = self._set_sites_enabled(normalized, enabled=False)
request.awaiting_input = None
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -317,7 +317,7 @@ class SiteInteractionHandler:
if cookie_match:
success, message = self._update_site_cookie_from_input(cookie_match.group(1))
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -337,7 +337,7 @@ class SiteInteractionHandler:
if enable_match:
success, message = self._set_sites_enabled(enable_match.group(1), enabled=True)
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -359,7 +359,7 @@ class SiteInteractionHandler:
disable_match.group(1), enabled=False
)
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -377,7 +377,7 @@ class SiteInteractionHandler:
return True
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -390,7 +390,7 @@ class SiteInteractionHandler:
def _render_site_interaction(
self,
request,
channel: MessageChannel,
channel: NotificationChannel,
source: Optional[str],
userid: Union[str, int],
username: Optional[str],
@@ -463,7 +463,7 @@ class SiteInteractionHandler:
@staticmethod
def _format_site_list(
site_list: List[Site], channel: Optional[MessageChannel]
site_list: List[Site], channel: Optional[NotificationChannel]
) -> str:
"""
根据渠道能力格式化站点列表。
+24 -24
View File
@@ -13,8 +13,8 @@ from app.application.messaging.interaction import (
supports_interaction_buttons,
update_or_post_message,
)
from app.schemas import Notification
from app.schemas.types import MessageChannel
from app.schemas import Message
from app.schemas.types import NotificationChannel
@dataclass
@@ -25,7 +25,7 @@ class PendingSkillInteraction:
request_id: str
user_id: str
channel: Optional[MessageChannel]
channel: Optional[NotificationChannel]
source: Optional[str]
username: Optional[str]
view: str = "root"
@@ -69,7 +69,7 @@ class SkillInteractionManager:
def create_or_replace(
self,
user_id: Union[str, int],
channel: Optional[MessageChannel],
channel: Optional[NotificationChannel],
source: Optional[str],
username: Optional[str],
) -> PendingSkillInteraction:
@@ -161,7 +161,7 @@ class SkillInteractionHandler:
def remote_manage(
self,
arg_str: str,
channel: MessageChannel,
channel: NotificationChannel,
userid: Union[str, int],
source: Optional[str] = None,
):
@@ -213,7 +213,7 @@ class SkillInteractionHandler:
def handle_callback_interaction(
self,
callback_data: str,
channel: MessageChannel,
channel: NotificationChannel,
source: str,
userid: Union[str, int],
username: str,
@@ -231,7 +231,7 @@ class SkillInteractionHandler:
request = skill_interaction_manager.get_by_id(request_id, userid)
if not request:
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -311,7 +311,7 @@ class SkillInteractionHandler:
success, message = self._install_market_skill(request, index)
if success:
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -321,7 +321,7 @@ class SkillInteractionHandler:
)
else:
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -333,7 +333,7 @@ class SkillInteractionHandler:
request.awaiting_input = None
success, message = self._remove_local_skill(request, index)
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -349,7 +349,7 @@ class SkillInteractionHandler:
request.awaiting_input = None
success, message = self._remove_market_source(index)
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -371,7 +371,7 @@ class SkillInteractionHandler:
def handle_text_interaction(
self,
channel: MessageChannel,
channel: NotificationChannel,
source: str,
userid: Union[str, int],
username: str,
@@ -393,7 +393,7 @@ class SkillInteractionHandler:
if lowered in {"退出", "关闭", "q", "quit", "exit"}:
skill_interaction_manager.remove(request.request_id)
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -428,7 +428,7 @@ class SkillInteractionHandler:
request.awaiting_input = None
_, message = self.skillhelper.add_custom_market_source(add_source)
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -452,7 +452,7 @@ class SkillInteractionHandler:
page_index=int(remove_source_match.group(1))
)
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -525,7 +525,7 @@ class SkillInteractionHandler:
)
else:
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -550,7 +550,7 @@ class SkillInteractionHandler:
_, message = self.skillhelper.add_custom_market_source(normalized)
request.awaiting_input = None
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -615,7 +615,7 @@ class SkillInteractionHandler:
page_index=int(install_match.group(1)),
)
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -638,7 +638,7 @@ class SkillInteractionHandler:
page_index=int(remove_match.group(1)),
)
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -656,7 +656,7 @@ class SkillInteractionHandler:
return True
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -722,7 +722,7 @@ class SkillInteractionHandler:
def _render_interaction(
self,
request: PendingSkillInteraction,
channel: MessageChannel,
channel: NotificationChannel,
source: Optional[str],
userid: Union[str, int],
username: Optional[str],
@@ -1068,7 +1068,7 @@ class SkillInteractionHandler:
"""
return page_items(items=items, page=page, page_size=page_size)
def _page_size(self, channel: Optional[MessageChannel]) -> int:
def _page_size(self, channel: Optional[NotificationChannel]) -> int:
"""
按渠道能力选择分页大小,按钮渠道单页更短,便于直接操作。
"""
@@ -1079,7 +1079,7 @@ class SkillInteractionHandler:
)
@staticmethod
def _supports_interactive_buttons(channel: Optional[MessageChannel]) -> bool:
def _supports_interactive_buttons(channel: Optional[NotificationChannel]) -> bool:
"""
判断当前渠道是否同时支持按钮展示和回调。
"""
@@ -1103,7 +1103,7 @@ class SkillInteractionHandler:
def _update_or_post_message(
self,
channel: MessageChannel,
channel: NotificationChannel,
source: Optional[str],
userid: Union[str, int],
username: Optional[str],
+23 -23
View File
@@ -14,8 +14,8 @@ from app.application.messaging.interaction import (
)
from app.db.models.subscribe import Subscribe
from app.db.oper.subscribe import SubscribeOper
from app.schemas import Notification
from app.schemas.types import MessageChannel, MediaType
from app.schemas import Message
from app.schemas.types import NotificationChannel, MediaType
subscribe_interaction_manager = SlashInteractionManager()
@@ -61,7 +61,7 @@ class SubscribeInteractionHandler:
def remote_list(
self,
arg_str: str = "",
channel: MessageChannel = None,
channel: NotificationChannel = None,
userid: Union[str, int] = None,
source: Optional[str] = None,
):
@@ -107,7 +107,7 @@ class SubscribeInteractionHandler:
def handle_callback_interaction(
self,
callback_data: str,
channel: MessageChannel,
channel: NotificationChannel,
source: str,
userid: Union[str, int],
username: str,
@@ -125,7 +125,7 @@ class SubscribeInteractionHandler:
request = subscribe_interaction_manager.get_by_id(request_id, userid)
if not request:
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -184,7 +184,7 @@ class SubscribeInteractionHandler:
def handle_text_interaction(
self,
channel: MessageChannel,
channel: NotificationChannel,
source: str,
userid: Union[str, int],
username: str,
@@ -207,7 +207,7 @@ class SubscribeInteractionHandler:
if lowered in {"退出", "关闭", "q", "quit", "exit"}:
subscribe_interaction_manager.remove(request.request_id)
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -297,7 +297,7 @@ class SubscribeInteractionHandler:
)
request.awaiting_input = None
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -318,7 +318,7 @@ class SubscribeInteractionHandler:
success, message = self._delete_subscribes(normalized)
request.awaiting_input = None
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -340,7 +340,7 @@ class SubscribeInteractionHandler:
search_match.group(1), channel, source, userid, username
)
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -360,7 +360,7 @@ class SubscribeInteractionHandler:
if delete_match:
success, message = self._delete_subscribes(delete_match.group(1))
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -378,7 +378,7 @@ class SubscribeInteractionHandler:
return True
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -391,7 +391,7 @@ class SubscribeInteractionHandler:
def _render_subscribe_interaction(
self,
request,
channel: MessageChannel,
channel: NotificationChannel,
source: Optional[str],
userid: Union[str, int],
username: Optional[str],
@@ -475,7 +475,7 @@ class SubscribeInteractionHandler:
)
def _format_subscribe_list(
self, subscribes: List[Subscribe], channel: Optional[MessageChannel]
self, subscribes: List[Subscribe], channel: Optional[NotificationChannel]
) -> str:
"""
根据渠道能力格式化订阅列表。
@@ -564,7 +564,7 @@ class SubscribeInteractionHandler:
def _run_refresh_action(
self,
channel: MessageChannel,
channel: NotificationChannel,
source: str,
userid: Union[str, int],
username: str,
@@ -573,7 +573,7 @@ class SubscribeInteractionHandler:
执行订阅刷新。
"""
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -583,7 +583,7 @@ class SubscribeInteractionHandler:
)
self._actions.refresh()
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -594,7 +594,7 @@ class SubscribeInteractionHandler:
def _run_metadata_refresh_action(
self,
channel: MessageChannel,
channel: NotificationChannel,
source: str,
userid: Union[str, int],
username: str,
@@ -603,7 +603,7 @@ class SubscribeInteractionHandler:
执行订阅元数据刷新。
"""
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -613,7 +613,7 @@ class SubscribeInteractionHandler:
)
self._actions.check()
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -632,7 +632,7 @@ class SubscribeInteractionHandler:
def _run_search_action(
self,
arg_str: str,
channel: MessageChannel,
channel: NotificationChannel,
source: str,
userid: Union[str, int],
username: str,
@@ -643,7 +643,7 @@ class SubscribeInteractionHandler:
normalized = (arg_str or "").strip()
if not normalized or normalized.lower() in {"all", "全部", "所有"}:
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,
@@ -667,7 +667,7 @@ class SubscribeInteractionHandler:
missing.append(str(subscribe_id))
continue
self._messenger.post_message(
Notification(
Message(
channel=channel,
source=source,
userid=userid,