根本原因: 原本的「今日羽球報名」bot 寫在 Node-RED 的 function 節點裡,不易測試與擴充; 羽球團又需要在 Telegram 群組內直接記分、看發球者,並把戰績寫進 web 版共用的 DB。 影響: 同一個 bot(@JianMiauBadmintonBot)改由本專案服務:報名指令、按鈕、暱稱、 週一 10:00 排程、白名單行為與訊息格式皆與 Node-RED 版相同,舊訊息按鈕仍可用; 另新增 /記分(/score、/new)記分板,並在結束/再一局時寫入共用的 history 表。 修法: - signup.js:逐句移植 Node-RED bd_sm 狀態機(attendance / tg_poll / tg_members) - scoreboard.js + match.js + render.js:羽球規則(發球區、換位、Deuce、30 分封頂)、 上排 1 2/下排 4 3 版面、從今日出席選人開局、⏱ 結算、兩段式結束確認、 開局者/管理員權限、scoreList(web 版格式) - history.js:寫入 history 表,欄位與 web 版 ensureHistoryTable 相同 - scripts/nodered-switch.mjs:透過 admin API 暫停/恢復 Node-RED 舊流程 - 單元測試 23 項(規則、報名、選人、結算、權限、歷史寫入),Dockerfile / compose Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
26 lines
762 B
Bash
26 lines
762 B
Bash
# 從 @BotFather 取得的 Bot Token
|
|
BOT_TOKEN=123456789:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
|
|
# 白名單聊天(逗號分隔 chat_id);不在名單的聊天指令與按鈕都會被擋
|
|
ALLOWED_CHAT_IDS=-1002488036686,-4679836160
|
|
|
|
# 每週自動發報名(cron 語法,時區 Asia/Taipei);留空則不排程
|
|
SIGNUP_CRON=0 10 * * 1
|
|
SIGNUP_CRON_CHAT_ID=-4679836160
|
|
|
|
# 記分板預設目標分數
|
|
TARGET_SCORE=21
|
|
# 記分板狀態持久化檔案
|
|
DATA_FILE=./data/matches.json
|
|
|
|
# MariaDB / MySQL(與 badminton-scoreboard 共用)
|
|
DB_HOST=127.0.0.1
|
|
DB_PORT=3306
|
|
DB_USER=root
|
|
DB_PASSWORD=your_password
|
|
DB_DATABASE=badminton
|
|
DB_HISTORY_TABLE=history
|
|
|
|
# Node-RED(舊版報名流程切換用)
|
|
NODERED_URL=http://192.168.5.45:1880
|