feat: 新增 show_report_caption 选项,可关闭报告发送时的文字前缀

This commit is contained in:
SXP-Simon
2026-07-21 16:22:20 +08:00
parent eb8da860d5
commit 938ae5ddaf
5 changed files with 19 additions and 4 deletions
+6
View File
@@ -143,6 +143,12 @@
"description": "发送文本/表情回复",
"default": false,
"hint": "开启后,/群分析 将通过发送文本消息提示进度;关闭(默认)则使用表情回应。"
},
"show_report_caption": {
"type": "bool",
"description": "发送报告时附带 \"📊 每日群聊分析报告已生成\" 前缀",
"default": true,
"hint": "关闭后,发送图片/HTML 报告时将只发送文件本身,不附带 \"📊 每日群聊分析报告已生成\" 等文字前缀。"
}
}
},
+1 -1
View File
@@ -649,7 +649,7 @@ class GroupDailyAnalysis(Star):
)
if image_url:
caption = TraceContext.make_report_caption()
caption = TraceContext.make_report_caption() if self.config_manager.get_show_report_caption() else ""
sent = await adapter.send_image(group_id, image_url, caption=caption)
if sent:
await self._try_upload_image(group_id, image_url, platform_id)
@@ -680,6 +680,15 @@ class ConfigManager:
self._ensure_group("basic")["enable_analysis_reply"] = enabled
self.config.save_config()
def get_show_report_caption(self) -> bool:
"""获取是否发送 \"📊 每日群聊分析报告已生成\" 前缀文字。"""
return self._get_group("basic").get("show_report_caption", True)
def set_show_report_caption(self, enabled: bool):
"""设置是否发送 \"📊 每日群聊分析报告已生成\" 前缀文字。"""
self._ensure_group("basic")["show_report_caption"] = enabled
self.config.save_config()
def get_profile_display_mode(self) -> str:
"""获取人格标签展示模式。"""
mode = str(self._get_group("basic").get("profile_display_mode", "mbti")).lower()
+2 -2
View File
@@ -100,7 +100,7 @@ class ReportDispatcher:
# 4. 发送图片
sent = False
if image_url:
caption = TraceContext.make_report_caption()
caption = TraceContext.make_report_caption() if self.config_manager.get_show_report_caption() else ""
sent = await self.message_sender.send_image_smart(
group_id, image_url, caption, platform_id
)
@@ -180,7 +180,7 @@ class ReportDispatcher:
f"[{trace_id}] 群 {group_id} 开启了仅发送外链,但未配置 html_base_url,已进行降级,回退至发送 HTML 文件。"
)
caption = self.report_generator.build_html_caption(html_path)
caption = self.report_generator.build_html_caption(html_path) if self.config_manager.get_show_report_caption() else ""
sent = await self.message_sender.send_file(
group_id,
+1 -1
View File
@@ -647,7 +647,7 @@ class ReportGenerator(IReportGenerator):
return None, None
def build_html_caption(self, html_path: str) -> str:
"""根据 html_base_url 生成 HTML 报告链接 caption"""
"""根据 html_base_url 生成 HTML 报告链接 caption。由调用方决定是否发送。"""
caption = "📊 每日群聊分析报告已生成"
base_url = self.config_manager.get_html_base_url()