From d942a5a2eb1ae3b74515c5fafd5f1e4685aa58ff Mon Sep 17 00:00:00 2001 From: SXP-Simon Date: Tue, 25 Nov 2025 20:44:14 +0800 Subject: [PATCH] =?UTF-8?q?docs(templates-customization):=20=E6=AC=A2?= =?UTF-8?q?=E8=BF=8E=E4=B8=BA=E6=8F=92=E4=BB=B6=E8=B4=A1=E7=8C=AE=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E6=8A=A5=E5=91=8A=E6=A8=A1=E6=9D=BF!!!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 60 +++++++++++++++++- .../templates/simple/activity_chart.html | 11 ++++ .../templates/simple/image_template.html | 60 ++++++++++++++++++ .../templates/simple/pdf_template.html | 61 +++++++++++++++++++ src/reports/templates/simple/quote_item.html | 9 +++ src/reports/templates/simple/topic_item.html | 5 ++ .../templates/simple/user_title_item.html | 9 +++ 7 files changed, 212 insertions(+), 3 deletions(-) create mode 100644 src/reports/templates/simple/activity_chart.html create mode 100644 src/reports/templates/simple/image_template.html create mode 100644 src/reports/templates/simple/pdf_template.html create mode 100644 src/reports/templates/simple/quote_item.html create mode 100644 src/reports/templates/simple/topic_item.html create mode 100644 src/reports/templates/simple/user_title_item.html diff --git a/README.md b/README.md index ba78115..a083603 100644 --- a/README.md +++ b/README.md @@ -225,9 +225,6 @@ _✨ 一个基于AstrBot的智能群聊分析插件,能够生成精美的群 **忽略**:如果只是偶尔出现(如回复久远消息),不影响机器人核心功能(收发消息),可以直接忽略。 -## 许可证 - -MIT License ## 贡献 @@ -247,4 +244,61 @@ MIT License +### 模板贡献指南 + +
+🎨 点击展开查看如何贡献你的自定义模板给更多人玩 + +如果您想为插件贡献新的报告模板,请按照以下步骤操作: + +#### 1. 创建模板目录 +在 `src/reports/templates/` 目录下创建一个新的文件夹,例如 `my_theme`。 + +#### 2. 必需文件结构 +您的模板目录需要包含以下文件: + +```text +src/reports/templates/your_theme_name/ +├── image_template.html # 图片报告主模板 +├── pdf_template.html # PDF报告主模板 +├── activity_chart.html # 活跃度图表组件 +├── topic_item.html # 话题列表项组件 +├── user_title_item.html # 用户称号项组件 +└── quote_item.html # 金句项组件 +``` + +#### 3. 模板变量说明 + +**主模板 (`image_template.html` / `pdf_template.html`) 可用变量:** +- `current_date`: 当前日期 (YYYY-MM-DD) +- `current_datetime`: 当前时间 (YYYY-MM-DD HH:MM:SS) +- `message_count`: 消息总数 +- `participant_count`: 参与人数 +- `total_characters`: 总字符数 +- `emoji_count`: 表情数量 +- `most_active_period`: 最活跃时段 +- `hourly_chart_html`: 渲染后的活跃度图表 HTML +- `topics_html`: 渲染后的热门话题 HTML +- `titles_html`: 渲染后的用户称号 HTML +- `quotes_html`: 渲染后的金句 HTML +- `total_tokens`: Token 消耗统计 +- `prompt_tokens`: 提示词 Token 消耗 +- `completion_tokens`: 生成内容 Token 消耗 + +**组件模板可用变量:** +- `activity_chart.html`: `chart_data` (包含 `hour`, `count`, `percentage` 的列表) +- `topic_item.html`: `topic` (包含 `keyword`, `count`, `summary` 的对象), `loop.index` (序号) +- `user_title_item.html`: `user` (包含 `nickname`, `user_id`, `titles` (列表), `description` 的对象) +- `quote_item.html`: `quote` (包含 `content`, `sender_nickname`, `reason` 的对象) + +#### 4. 参考示例 +您可以参考 `src/reports/templates/simple/` 目录下的文件,这是一个最简化的模板实现,包含了所有必需的基本结构。 + +
+ +## 许可证 + +MIT License + + 欢迎提交Issue和Pull Request来改进这个插件! diff --git a/src/reports/templates/simple/activity_chart.html b/src/reports/templates/simple/activity_chart.html new file mode 100644 index 0000000..eed5951 --- /dev/null +++ b/src/reports/templates/simple/activity_chart.html @@ -0,0 +1,11 @@ +
+ {% for item in chart_data %} +
+ {{ "%02d" | format(item.hour) }}:00 +
+
+
+ {{ item.count }} +
+ {% endfor %} +
\ No newline at end of file diff --git a/src/reports/templates/simple/image_template.html b/src/reports/templates/simple/image_template.html new file mode 100644 index 0000000..1de3f53 --- /dev/null +++ b/src/reports/templates/simple/image_template.html @@ -0,0 +1,60 @@ + + + + + + Simple Report + + + + +

群聊日报 - {{ current_date }}

+ +
+

基础统计

+

消息数: {{ message_count }}

+

参与人数: {{ participant_count }}

+
+ +
+

活跃度图表

+ {{ hourly_chart_html }} +
+ +
+

热门话题

+ {{ topics_html }} +
+ +
+

群友称号

+ {{ titles_html }} +
+ +
+

群圣经

+ {{ quotes_html }} +
+ + + + + \ No newline at end of file diff --git a/src/reports/templates/simple/pdf_template.html b/src/reports/templates/simple/pdf_template.html new file mode 100644 index 0000000..c44f05c --- /dev/null +++ b/src/reports/templates/simple/pdf_template.html @@ -0,0 +1,61 @@ + + + + + + Simple PDF Report + + + + +

群聊日报 (PDF) - {{ current_date }}

+ +
+

基础统计

+

消息数: {{ message_count }}

+

参与人数: {{ participant_count }}

+
+ +
+

活跃度图表

+ {{ hourly_chart_html }} +
+ +
+

热门话题

+ {{ topics_html }} +
+ +
+

群友称号

+ {{ titles_html }} +
+ +
+

群圣经

+ {{ quotes_html }} +
+ + + + + \ No newline at end of file diff --git a/src/reports/templates/simple/quote_item.html b/src/reports/templates/simple/quote_item.html new file mode 100644 index 0000000..63cd99f --- /dev/null +++ b/src/reports/templates/simple/quote_item.html @@ -0,0 +1,9 @@ +
+

"{{ quote.content }}"

+
+ — {{ quote.sender_nickname }} +
+
+ 入选理由: {{ quote.reason }} +
+
\ No newline at end of file diff --git a/src/reports/templates/simple/topic_item.html b/src/reports/templates/simple/topic_item.html new file mode 100644 index 0000000..5006353 --- /dev/null +++ b/src/reports/templates/simple/topic_item.html @@ -0,0 +1,5 @@ +
+ #{{ loop.index }} {{ topic.keyword }} + (热度: {{ topic.count }}) +

{{ topic.summary }}

+
\ No newline at end of file diff --git a/src/reports/templates/simple/user_title_item.html b/src/reports/templates/simple/user_title_item.html new file mode 100644 index 0000000..3a68265 --- /dev/null +++ b/src/reports/templates/simple/user_title_item.html @@ -0,0 +1,9 @@ +
+
{{ user.nickname }} ({{ user.user_id }})
+
称号: + {% for title in user.titles %} + {{ title }} + {% endfor %} +
+
{{ user.description }}
+
\ No newline at end of file