新增通用HTML模板渲染器并将机器人菜单改为模板驱动输出

This commit is contained in:
liuwei
2026-04-20 13:12:44 +08:00
parent cfb8af334b
commit f1a6f6d565
5 changed files with 327 additions and 245 deletions

View File

@@ -87,12 +87,21 @@ class RobotMenuPlugin(MessagePluginInterface):
self.image_render_retries = int(
self._config.get("RobotMenu", {}).get("image_render_retries", 1)
)
# 菜单图片模板文件路径(相对仓库根目录):
# 调整样式和布局时只改模板,不改 Python 逻辑。
self.image_template_path = str(
self._config.get("RobotMenu", {}).get(
"image_template_path",
"plugins/robot_menu/templates/menu_cards.html",
)
).strip() or "plugins/robot_menu/templates/menu_cards.html"
# 初始化“菜单渲染工具”,后续菜单图片与文本发送统一由该工具负责。
self.menu_renderer = RobotMenuRenderTool(
output_mode=output_mode,
image_fallback_to_text=self.image_fallback_to_text,
image_render_timeout_seconds=self.image_render_timeout_seconds,
image_render_retries=self.image_render_retries,
image_template_path=self.image_template_path,
log=self.LOG,
)