MozTW Space 工寮管理工具 — Telegram Bots + 活動查詢系統
- PHP 98.7%
- HTML 1.3%
The PHP port had many behavioral differences from the original moztw-space-bot (Kotlin). This re-port fixes: - Add admin chat restriction (only SPACE_ADMIN_CHATS can open/close) - Add FRONTIER_CHAT_ID (-1001060092077) to config - Send #工寮開門/#工寮關門 broadcast to general chat with operator link - Cross-group notifications to other admin groups - Fix reply messages (open=instructions, close=checklist) - Restore 8-item checklist in 2-column layout (was 6 items, 1-column) - Use hex encoding for checklist callback data - Add "hide" callback to collapse checklist - Add answerCallbackQuery to dismiss loading indicator Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| deploy | ||
| src | ||
| webroot | ||
| .gitignore | ||
| README.md | ||
moztw-space.mingtsay.tw
MozTW Space 工寮管理工具 — 兩個 Telegram Bot + 活動查詢系統
架構
src/ # 後端邏輯(webroot 外)
├── config.php # 共用設定
├── config.local.php.example # 設定範本
├── telegram.php # Telegram API helper
├── google-sheets.php # Google Sheets JWT auth(零依賴)
├── co2.php # ThingSpeak CO₂ 抓取
├── activities.php # 活動資料 helper
├── fetch.php # [Cron] 從 Google Sheets 抓活動
├── reminder.php # [Cron] 發送待處理活動提醒
└── setup.php # CLI 工具:註冊/刪除 webhook
webroot/ # Nginx document root
├── index.html # 首頁
└── bots/
├── space.php # @MozTWSpaceBot webhook
└── activity.php # @MozTWSpaceActivityQueryBot webhook
Bots
@MozTWSpaceBot
/open— 開放工寮(修改群組標題 + 顯示關門檢查清單)/close— 關閉工寮/co2— 查詢工寮 CO₂ 濃度
@MozTWSpaceActivityQueryBot
/pending— 查詢待處理活動申請/scheduled— 查詢即將舉行的活動/spreadsheets— Google Sheets 連結
Cron Jobs
# 每 15 分鐘抓活動資料
*/15 * * * * php /path/to/src/fetch.php
# 每天 10:01 和 18:01 發提醒
1 10,18 * * * php /path/to/src/reminder.php
部署
- 複製
src/config.local.php.example→src/config.local.php - 填入 bot tokens 和 webhook token
- 放置 Google Service Account JSON 到
src/service-account.json - Nginx 設定 document root 指向
webroot/ php src/setup.php set https://moztw-space.mingtsay.tw
零依賴
不需要 Composer。Google Sheets 用 JWT + REST API 直接呼叫。 PHP 8.1+ 即可運行。