From 734c112ee4ccc0e5b22af9ca2443f3e79ab3d18d Mon Sep 17 00:00:00 2001 From: K2cr2O1 <2221577113@qq.com> Date: Sun, 1 Mar 2026 11:14:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=97=A5=E5=BF=97=E7=94=9F=E6=88=90=E5=99=A8=E5=B9=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=BD=E4=BB=A4=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加完整的更新日志生成器工具,包括Python脚本和HTML模板 将bot命令前缀从"/"改为"。"以符合中文用户习惯 --- config.toml | 2 +- web_static/changelog_generator/generate.py | 71 +++++++ web_static/changelog_generator/template.html | 187 +++++++++++++++++++ 3 files changed, 259 insertions(+), 1 deletion(-) create mode 100644 web_static/changelog_generator/generate.py create mode 100644 web_static/changelog_generator/template.html diff --git a/config.toml b/config.toml index cb60f44..25c55be 100644 --- a/config.toml +++ b/config.toml @@ -19,7 +19,7 @@ token = "" # Bot 基础配置 [bot] # 命令前缀列表 -command = ["/"] +command = ["。"] # 是否忽略自己的消息 ignore_self_message = true # 权限不足时的消息 diff --git a/web_static/changelog_generator/generate.py b/web_static/changelog_generator/generate.py new file mode 100644 index 0000000..3403880 --- /dev/null +++ b/web_static/changelog_generator/generate.py @@ -0,0 +1,71 @@ +import os +import sys +from datetime import datetime +from jinja2 import Environment, FileSystemLoader + +# ========================================== +# 配置区域 +# ========================================== + +# 输出文件路径 (相对于当前脚本或绝对路径) +OUTPUT_FILE = "../changelog.html" + +# 更新日志数据 +# 格式说明: +# version: 版本号 +# date: 日期 (YYYY-MM-DD) +# description: 版本描述 (可选) +# changes: 变更列表 +# - type: 类型 (add, update, fix) +# - content: 变更内容 +changelogs = [ + { + "version": "v1.0.0", + "date": "2026-3-1", + "description": "引入了更多有趣的互动功能,并优化了系统稳定性。", + "changes": [ + {"type": "add", "content": "新增了天气查询功能,支持全国主要城市"}, + {"type": "update", "content": "优化了 Web Parser 的解析速度,不过b站的视频解析等待重做中"}, + {"type": "fix", "content": "修复了在某些特定网络环境下图片加载失败的问题"}, + {"type": "update", "content": "支持多实现端连接(反向WS),此功能并不完善,等待重做"} + + + ] + } +] + +# ========================================== +# 生成逻辑 (通常不需要修改) +# ========================================== + +def generate_changelog(): + # 获取当前脚本所在目录 + base_dir = os.path.dirname(os.path.abspath(__file__)) + + # 设置 Jinja2 环境 + env = Environment(loader=FileSystemLoader(base_dir)) + template = env.get_template("template.html") + + # 获取最新版本号 + latest_version = changelogs[0]["version"] if changelogs else "v0.0.0" + + # 渲染模板 + html_content = template.render( + log=changelogs[0] if changelogs else None, + latest_version=latest_version, + generated_at=datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ) + + # 确定输出路径 + output_path = os.path.join(base_dir, OUTPUT_FILE) + + # 写入文件 + try: + with open(output_path, "w", encoding="utf-8") as f: + f.write(html_content) + print(f"✅ 成功生成更新日志: {os.path.abspath(output_path)}") + except Exception as e: + print(f"❌ 生成失败: {e}") + +if __name__ == "__main__": + generate_changelog() diff --git a/web_static/changelog_generator/template.html b/web_static/changelog_generator/template.html new file mode 100644 index 0000000..e0d3eac --- /dev/null +++ b/web_static/changelog_generator/template.html @@ -0,0 +1,187 @@ + + + + + + NEOBOT | Changelog + + + + + + + + + + + + + +
+
+ + +
+
PROJECT HISTORY
+

+ System
+ Evolution +

+

+ 记录每一次微小的改变,见证成长的轨迹。 +

+
+ + +
+
+ +
+ + +
+
+
+

{{ log.version }}

+ LATEST +
+
{{ log.date }}
+
+ {% if log.description %} +
+

+ "{{ log.description }}" +

+
+ {% endif %} +
+ + +
+
    + {% for change in log.changes %} +
  • + {% if change.type == 'add' %} + ADD + {% elif change.type == 'update' %} + UPD + {% elif change.type == 'fix' %} + FIX + {% else %} + MSC + {% endif %} + + {{ change.content }} +
  • + {% endfor %} +
+
+
+
+ +
+
+ + + + + From 898c9e7a381207761472147fb3be5cb1d8bf5156 Mon Sep 17 00:00:00 2001 From: baby20162016 <2185823427@qq.com> Date: Sun, 1 Mar 2026 11:25:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(plugins):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=A4=A9=E6=B0=94=E6=8F=92=E4=BB=B6html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/weather.py | 2 +- templates/weather.html | 543 +++++++++++++++++++++++------------------ 2 files changed, 309 insertions(+), 236 deletions(-) diff --git a/plugins/weather.py b/plugins/weather.py index 445b1f6..ded39b0 100644 --- a/plugins/weather.py +++ b/plugins/weather.py @@ -186,7 +186,7 @@ async def handle_weather(bot, event: MessageEvent, args: List[str]): try: # 渲染HTML模板为图片 base64_image = await image_manager.render_template_to_base64( - "weather.html", weather_info, output_name="weather.png", width=1080 + "weather.html", weather_info, output_name="weather.png", width=400, height=500 ) if base64_image: diff --git a/templates/weather.html b/templates/weather.html index 6576f55..8ef9578 100644 --- a/templates/weather.html +++ b/templates/weather.html @@ -4,23 +4,16 @@ 天气查询结果 + + + -
-
-
-
-
-
+
+ +
+
{{ city_name }}
+ + {% set first_day = weather_data[0] %} +
+ {{ first_day.temperature.split(' / ')[0].replace('℃', '') if ' / ' in first_day.temperature else first_day.temperature.replace('℃', '') }} + °C +
+ +
+ {{ first_day.weather }} +
+ 风力 {{ first_day.wind_power }}
-
天气查询
-
-
-

天气查询结果

-

{{ timestamp }}

-
- -
-
{{ city_name }}
-
查询时间: {{ query_time }}
-
- -
- {% for day_weather in weather_data %} -
-
-
{{ day_weather.day }}
-
{{ day_weather.weather }}
-
-
-
{{ day_weather.temperature }}
-
-
-
-
风力
-
{{ day_weather.wind_power }}
-
-
-
风向
-
{{ day_weather.wind_direction }}
-
+ +
+
+ {% set month = query_time.split('年')[1].split('月')[0] if '年' in query_time else '3' %} + {# 星期名称映射 #} + {% set week_names = ['日', '一', '二', '三', '四', '五', '六'] %} + {# 从第一天数据中提取今天是星期几 #} + {% set first_day_text = weather_data[0].day %} + {% set today_week_text = first_day_text.split('(')[1].replace(')', '') if '(' in first_day_text else '今天' %} + {# 将文字星期转换为数字:今天=0, 明天=1, 后天=2, 周一=1, 周二=2... #} + {% if today_week_text == '今天' %} + {% set today_week_num = 0 %} + {% elif today_week_text == '明天' %} + {% set today_week_num = 1 %} + {% elif today_week_text == '后天' %} + {% set today_week_num = 2 %} + {% elif '周' in today_week_text %} + {% set week_day_char = today_week_text.replace('周', '').replace('星期', '') %} + {% set week_map = {'日': 0, '一': 1, '二': 2, '三': 3, '四': 4, '五': 5, '六': 6} %} + {% set today_week_num = week_map[week_day_char] if week_day_char in week_map else 0 %} + {% else %} + {% set today_week_num = 0 %} + {% endif %} + {% for day_weather in weather_data[:5] %} +
+
+ {% set day_text = day_weather.day %} + {% set day_num = day_text.split('日')[0] %} + {% if loop.index0 == 0 %} + 今日 + {% elif loop.index0 == 1 %} + 明日 + {% elif loop.index0 == 2 %} + 后日 + {% else %} + {# 计算这一天的星期:今天 + 天数偏移 #} + {% set target_week_num = (today_week_num + loop.index0) % 7 %} + 星期{{ week_names[target_week_num] }} + {% endif %} + {{ month }}/{{ day_num }}
+
{% endfor %}
- + +
+ + - + +