feat:可开启原生at功能

This commit is contained in:
SengokuCola
2026-04-23 15:56:27 +08:00
parent 2255592bd2
commit 35ff91d134
20 changed files with 258 additions and 404 deletions

View File

@@ -230,8 +230,10 @@ class SessionMessage(MaiMessage):
Returns:
str: 图片组件对应的文本表示。
"""
if component.content: # 先检查是否处理过
return component.content
normalized_content = component.content.strip()
if normalized_content: # 先检查是否处理过
component.content = normalized_content
return normalized_content
from src.chat.image_system.image_manager import image_manager
# 获取描述
@@ -263,8 +265,10 @@ class SessionMessage(MaiMessage):
Returns:
str: 表情包组件对应的文本表示。
"""
if component.content: # 先检查是否处理过
return component.content
normalized_content = component.content.strip()
if normalized_content: # 先检查是否处理过
component.content = normalized_content
return normalized_content
from src.emoji_system.emoji_manager import emoji_manager
# 获取表情包描述
@@ -323,8 +327,10 @@ class SessionMessage(MaiMessage):
Returns:
str: 语音组件对应的文本表示。
"""
if component.content: # 先检查是否处理过
return component.content
normalized_content = component.content.strip()
if normalized_content: # 先检查是否处理过
component.content = normalized_content
return normalized_content
if not enable_voice_transcription:
component.content = "[语音消息]"
return component.content

View File

@@ -201,6 +201,18 @@ class BaseMaisakaReplyGenerator:
return "在该聊天中的注意事项:\n" + "\n\n".join(prompt_lines) + "\n"
@staticmethod
def _build_replyer_at_block() -> str:
"""构建 replyer 模式下的 at 标记说明。"""
if not global_config.chat.enable_at:
return ""
return (
"如果需要提及某人、让某人关注你的回复,可以在回复中加入 `at[msg_id]` 标记,"
"其中 msg_id 应使用聊天记录中该用户发过的消息编号;"
"消息发送时会检查这种标记并转换为真正的 at 消息。\n"
)
def _build_system_prompt(
self,
reply_message: Optional[SessionMessage],
@@ -218,6 +230,7 @@ class BaseMaisakaReplyGenerator:
"maisaka_replyer",
bot_name=global_config.bot.nickname,
group_chat_attention_block=self._build_group_chat_attention_block(session_id),
replyer_at_block=self._build_replyer_at_block(),
time_block=f"当前时间:{current_time}",
identity=self._personality_prompt,
reply_style=global_config.personality.reply_style,