修正 Telegram 分類按鈕預設 callback
All checks were successful
CD Pipeline / deploy (push) Successful in 55s

This commit is contained in:
OoO
2026-05-13 09:27:34 +08:00
parent f398f97293
commit 2068a3719d
2 changed files with 16 additions and 1 deletions

View File

@@ -164,7 +164,7 @@ class TrendTelegramBot:
]
return InlineKeyboardMarkup(keyboard)
def _get_category_keyboard(self, callback_prefix: str = "cat"):
def _get_category_keyboard(self, callback_prefix: str = "trend"):
"""建立分類選擇按鈕"""
# 每行 3 個按鈕
keyboard = []

View File

@@ -50,6 +50,21 @@ def _run(coro):
return asyncio.run(coro)
def test_default_category_keyboard_uses_handled_trend_prefix():
from services.telegram_bot_service import CATEGORIES, TrendTelegramBot
bot = TrendTelegramBot(token="dummy")
keyboard = bot._get_category_keyboard()
callback_values = [
button.callback_data
for row in keyboard.inline_keyboard
for button in row
]
assert f"trend_{CATEGORIES[0]}" in callback_values
assert not any(value.startswith("cat_") for value in callback_values)
def test_polling_callback_dedup_without_update_id(monkeypatch):
from services.telegram_bot_service import TrendTelegramBot