From e0d3b54527ad84d57a7af6f7312a20e01c392e17 Mon Sep 17 00:00:00 2001 From: ogt Date: Mon, 20 Apr 2026 06:14:39 +0800 Subject: [PATCH] feat: add PPT shortcut buttons after sales & trend query results MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously after querying sales or trend data, there were no direct PPT generation buttons — users had to navigate back to 簡報報表 menu. Changes: 1. sales_quick_kb(date_str): + [📊 產出日報 PPT] → cmd:ppt:daily + [📄 策略簡報] → cmd:ppt:strategy 2. trend ≤35 days (weekly/monthly view): + [📊 產出趨勢簡報] → cmd:ppt:strategy + [📅 產出日報 PPT] → cmd:ppt:daily + [← 返回業績查詢] → menu:sales 3. trend >35 days (quarterly/half-year/yearly view): + [📊 產出趨勢簡報] → cmd:ppt:strategy + [📅 月報 PPT] → cmd:ppt:monthly + [← 返回業績查詢] → menu:sales --- routes/openclaw_bot_routes.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/routes/openclaw_bot_routes.py b/routes/openclaw_bot_routes.py index 71458aed6..54bb68d1e 100644 --- a/routes/openclaw_bot_routes.py +++ b/routes/openclaw_bot_routes.py @@ -3169,6 +3169,8 @@ def sales_quick_kb(date_str): return [ [{'text': '⬅️ 昨日業績', 'callback_data': f'cmd:sales:{yesterday}'}, {'text': '🏆 熱銷商品', 'callback_data': f'cmd:top:{date_str}'}], + [{'text': '📊 產出日報 PPT', 'callback_data': f'cmd:ppt:daily {date_str}'}, + {'text': '📄 策略簡報', 'callback_data': f'cmd:ppt:strategy {date_str}'}], [{'text': '📋 完整報表', 'callback_data': f'cmd:report:{date_str}'}], ] except Exception: @@ -4311,7 +4313,13 @@ def handle_cmd(cmd, arg, chat_id, reply_to): if days_count <= 35: # 週/月:逐日文字 + 折線圖 - send_message(chat_id, fmt_trend(data, period_label), reply_to, _submenu_trend()) + _trend_kb_short = [ + [{'text': '📊 產出趨勢簡報', 'callback_data': f'cmd:ppt:strategy {start_str}'}, + {'text': '📅 產出日報 PPT', 'callback_data': f'cmd:ppt:daily {end_str}'}], + [{'text': '🔄 加載新趨勢', 'callback_data': f'cmd:trend:{sub}'}, + {'text': '← 返回業績查詢', 'callback_data': 'menu:sales'}], + ] + send_message(chat_id, fmt_trend(data, period_label), reply_to, _trend_kb_short) try: png = gen_trend_chart(data_points=data, title=chart_title) if png: @@ -4323,7 +4331,21 @@ def handle_cmd(cmd, arg, chat_id, reply_to): else: # 季/半年/年:摘要 + 聚合柱狀圖(不洗版面) granularity = 'monthly' if days_count > 100 else 'weekly' - send_message(chat_id, fmt_trend_summary(data, period_label), reply_to, _submenu_trend()) + # 決定働用 strategy 簡報的期間標籤 + if sub in ('quarter', 'quarterly', '季'): + ppt_sub = 'quarterly' + elif sub in ('half', '半年'): + ppt_sub = 'half' + elif sub in ('year', 'yearly', '年'): + ppt_sub = 'yearly' + else: + ppt_sub = 'weekly' + _trend_kb_long = [ + [{'text': '📊 產出趨勢簡報', 'callback_data': f'cmd:ppt:strategy {ppt_sub}'}, + {'text': '📅 月報 PPT', 'callback_data': f'cmd:ppt:monthly {start_str[:7].replace("/","/")}'}], + [{'text': '← 返回業績查詢', 'callback_data': 'menu:sales'}], + ] + send_message(chat_id, fmt_trend_summary(data, period_label), reply_to, _trend_kb_long) try: png = gen_aggregated_chart(data, chart_title, granularity=granularity) if png: