Skip to content

feat: 多平台通知架構(Discord Bot + LINE + Telegram)#13

Merged
cablate merged 4 commits intomasterfrom
feat/multi-notifier
Apr 11, 2026
Merged

feat: 多平台通知架構(Discord Bot + LINE + Telegram)#13
cablate merged 4 commits intomasterfrom
feat/multi-notifier

Conversation

@cablate
Copy link
Copy Markdown
Owner

@cablate cablate commented Apr 11, 2026

Summary

  • 新增 src/notifiers/ 模組化通知架構,支援 Telegram / Discord Bot / LINE
  • 每個 notifier 各自負責格式化(TG=HTML、DC=Markdown、LINE=純文字)與字數切割
  • createNotifiers() 讀取環境變數,只建立有設定的 channel
  • Promise.allSettled 平行發送,單一 channel 失敗不影響其他
  • 啟動時偵測半配對設定(如有 token 但缺 channel ID)並 console.warn
  • 預檢 LLM_API_KEY / GROQ_API_KEY 設定,避免跑完抓取才發現沒設定
  • 零新依賴,全部使用原生 fetch

Closes #6

Test plan

  • 只設定 TG 環境變數 → 確認只有 Telegram 收到通知
  • 設定 Discord Bot Token + Channel ID → 確認 Discord 收到通知
  • 設定 LINE Channel Access Token + To → 確認 LINE 收到通知
  • 只設定 TG_BOT_TOKEN 但不設 TG_CHANNEL_ID → 確認 console 噴出半配對警告
  • 不設 LLM_API_KEY 且非 dry run → 確認啟動時噴預檢警告
  • tsc --noEmit 零錯誤

🤖 Generated with Claude Code

cablate and others added 4 commits April 11, 2026 22:50
新增 notifiers/ 抽象層:
- types.ts: Notifier 介面 + 共用型別(ReportData, PostSummary)
- format.ts: splitMessage + escapeHtml 共用工具
- telegram.ts: 從舊 telegram.ts 重構,實作 Notifier 介面
- discord.ts: Discord Bot REST API(無需 discord.js)
- line.ts: LINE Push Message API
- index.ts: createNotifiers() dispatcher,讀 env 自動偵測啟用的 channel

重構 index.ts step 7 通知段落,改用 Promise.allSettled 並行發送。
CLI push 指令改用 sendTelegramDirect(從 notifiers re-export)。
零新增 npm 依賴。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- notifiers: 偵測 env var 只填一半(如有 TG_BOT_TOKEN 但缺 TG_CHANNEL_ID)時 console.warn
- index.ts: 非 dry run 時預檢 LLM_API_KEY、TRANSCRIBER+GROQ_API_KEY
- config.ts: loadConfig() 偵測 telegram botToken/channelId 半配對

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 描述、常駐排程、.env 範例、費用估算均反映 Discord/LINE 支援

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
LINE Messaging API Free plan 200 則/月,非完全免費

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cablate cablate merged commit dfe6be9 into master Apr 11, 2026
3 checks passed
@cablate cablate deleted the feat/multi-notifier branch April 11, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

支援 linebot

1 participant