Files
NeoBot/web_static/changelog_generator/generate.py
K2cr2O1 734c112ee4 feat: 添加更新日志生成器并修改命令前缀
添加完整的更新日志生成器工具,包括Python脚本和HTML模板
将bot命令前缀从"/"改为"。"以符合中文用户习惯
2026-03-01 11:14:10 +08:00

72 lines
2.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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()