diff --git a/_conf_schema.json b/_conf_schema.json index a479c64..af4ff20 100644 --- a/_conf_schema.json +++ b/_conf_schema.json @@ -143,6 +143,12 @@ "description": "发送文本/表情回复", "default": false, "hint": "开启后,/群分析 将通过发送文本消息提示进度;关闭(默认)则使用表情回应。" + }, + "show_report_caption": { + "type": "bool", + "description": "发送报告时附带 \"📊 每日群聊分析报告已生成\" 前缀", + "default": true, + "hint": "关闭后,发送图片/HTML 报告时将只发送文件本身,不附带 \"📊 每日群聊分析报告已生成\" 等文字前缀。" } } }, diff --git a/main.py b/main.py index 0748fe9..fe83af2 100644 --- a/main.py +++ b/main.py @@ -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) diff --git a/src/infrastructure/config/config_manager.py b/src/infrastructure/config/config_manager.py index 96d993e..9fe96da 100644 --- a/src/infrastructure/config/config_manager.py +++ b/src/infrastructure/config/config_manager.py @@ -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() diff --git a/src/infrastructure/reporting/dispatcher.py b/src/infrastructure/reporting/dispatcher.py index 150e841..556aaa1 100644 --- a/src/infrastructure/reporting/dispatcher.py +++ b/src/infrastructure/reporting/dispatcher.py @@ -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, diff --git a/src/infrastructure/reporting/generators.py b/src/infrastructure/reporting/generators.py index bd01977..018f5c8 100644 --- a/src/infrastructure/reporting/generators.py +++ b/src/infrastructure/reporting/generators.py @@ -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()