{"id":50735370,"url":"https://github.com/kao273183/notifykit","last_synced_at":"2026-06-10T13:01:18.846Z","repository":{"id":362397448,"uuid":"1258868426","full_name":"kao273183/notifykit","owner":"kao273183","description":"通用多通道通知器 — 把任何資料源的摘要發到 Slack / Telegram / LINE。零依賴、純 Python stdlib、可當 CLI 或 import 模組。","archived":false,"fork":false,"pushed_at":"2026-06-04T02:50:24.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-04T04:23:14.091Z","etag":null,"topics":["cli","jira","line","notifications","notifier","python","rss","slack","telegram","webhook","zero-dependency"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kao273183.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-04T01:59:40.000Z","updated_at":"2026-06-04T02:50:35.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/kao273183/notifykit","commit_stats":null,"previous_names":["kao273183/notifykit"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/kao273183/notifykit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kao273183%2Fnotifykit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kao273183%2Fnotifykit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kao273183%2Fnotifykit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kao273183%2Fnotifykit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kao273183","download_url":"https://codeload.github.com/kao273183/notifykit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kao273183%2Fnotifykit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34153483,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","jira","line","notifications","notifier","python","rss","slack","telegram","webhook","zero-dependency"],"created_at":"2026-06-10T13:01:18.244Z","updated_at":"2026-06-10T13:01:18.839Z","avatar_url":"https://github.com/kao273183.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# notifykit\n\n通用多通道通知器 — 把任何資料源的摘要，發到 **Slack / Telegram / LINE / Lark（飛書）**。\n零依賴（只用 Python 3 stdlib）、專案無關、可當 CLI 或 import 模組。\n\n## 設計\n\n```\n資料源(Source) → 中性 Message(title + sections + [文字](url)) → 各通道 render + 送出\n  ├ static / command（內建）          ├ Slack    (mrkdwn, webhook)\n  └ 自訂(jira/github/rss…)            ├ Telegram (HTML, Bot API)\n                                      ├ LINE     (純文字, Messaging API push)\n                                      └ Lark     (lark_md 互動卡片, 自訂機器人 webhook)\n```\n\n訊息用中性模型表達，連結寫 `[文字](url)`，各通道自動轉成該平台格式。\n\n## 安裝\n\n零執行期依賴、跨平台（macOS / Linux / Windows）。免安裝可直接 `python3 -m notifykit ...`；想要 `notifykit` 指令就裝起來。\n\n**一鍵安裝腳本**（建 venv → editable 安裝 → 備好 config.json）：\n\n```bash\n# macOS / Linux\n./install.sh                 # 加 --yaml 連 PyYAML 一起裝\n```\n```powershell\n# Windows（PowerShell）\n.\\install.ps1                # 加 -Yaml 連 PyYAML 一起裝\n# 若被執行原則擋下：Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass\n```\n\n**或手動**：\n\n```bash\n# macOS / Linux\npython3 -m venv .venv\n.venv/bin/pip install -e .            # .yaml 設定檔：.venv/bin/pip install -e '.[yaml]'\n.venv/bin/notifykit --help\n```\n```powershell\n# Windows（PowerShell）\npy -3 -m venv .venv\n.venv\\Scripts\\pip install -e .        # .yaml 設定檔：.venv\\Scripts\\pip install -e '.[yaml]'\n.venv\\Scripts\\notifykit --help\n```\n\n或用 **pipx** 當全域 CLI 工具（兩平台皆可）：`pipx install .`\n\n裝好後下面的 `python3 -m notifykit` 都可改成 `notifykit`（Windows venv 執行檔在 `.venv\\Scripts\\`）。\n\n## 快速開始\n\n```bash\n# 1. 複製設定\ncp config.example.json config.json   # 填入各通道 token/webhook\n\n# 2. 免 token 先 dry-run 看各平台 render 長怎樣\npython3 -m notifykit --config config.json --dry-run run\n\n# 3. 手動發一則（body 支援 [文字](url)；'-' 讀 stdin）\n#    多行：bash/zsh 用 $'...\\n...'；PowerShell 用 \"...`n...\"（雙引號內反引號 n）\npython3 -m notifykit --config config.json send --title \"部署完成\" --body $'v1.2.3 上線\\n- [release](https://x/r/1.2.3)'\necho \"管線也行\" | python3 -m notifykit --config config.json send --title \"Build\"\n\n# 4. 跑設定裡的 source（例：command source 包你的腳本）\npython3 -m notifykit --config config.json run\n```\n\n放進排程（cron / launchd）即每日通知。任何腳本只要 `python3 -m notifykit ... run` 或 `send` 就能多通道發送。\n\n## 通道設定\n\n### Slack（最簡單）\nSlack App → Incoming Webhooks → 開啟 → Add New Webhook → 複製 URL 填 `webhook_url`。\n\n### Telegram（簡單、免費）\n1. 跟 **@BotFather** 對話 → `/newbot` → 拿 **bot token**。\n2. 把 bot 加進你的群／私訊它，發一則訊息。\n3. 取 **chat_id**：開 `https://api.telegram.org/bot\u003cTOKEN\u003e/getUpdates`，看 `chat.id`。\n4. 填 `token` + `chat_id`。\n\n### LINE（較麻煩；LINE Notify 已於 2025 停用）\n走 **Messaging API**：\n1. [LINE Developers](https://developers.line.biz) 建 Provider + Messaging API channel（會有一個 LINE 官方帳號）。\n2. 取 **Channel access token**（長期）填 `token`。\n3. 取收訊者 **userId / groupId**（加好友後從 webhook event 拿，或用自己的 userId）填 `to`。\n4. 免費方案 push 訊息有額度限制。\n\n### Lark / 飛書（自訂機器人，最快）\n1. 群組 → 設定 → 群機器人 → 新增「自訂機器人 / Custom Bot」→ 複製 **webhook URL** 填 `webhook_url`。\n2. （選填）若機器人安全設定選了「簽名校驗」，把簽名密鑰填 `secret`，會自動帶 `timestamp + sign`。\n   - 也可改用「關鍵字」或「IP 白名單」驗證，那種就不用填 `secret`。\n3. 國際版網域為 `open.larksuite.com`、中國飛書為 `open.feishu.cn`，直接貼完整 URL 即可，不用區分。\n\n## 設定檔\n\n`config.json`（或裝了 `pyyaml` 後用 `.yaml`）：\n```json\n{\n  \"source\": { \"type\": \"command\", \"title\": \"每日摘要\", \"command\": \"your-script.sh\" },\n  \"channels\": [\n    { \"type\": \"slack\",    \"enabled\": true,  \"webhook_url\": \"...\" },\n    { \"type\": \"telegram\", \"enabled\": true,  \"token\": \"...\", \"chat_id\": \"...\" },\n    { \"type\": \"line\",     \"enabled\": false, \"token\": \"...\", \"to\": \"...\" },\n    { \"type\": \"lark\",     \"enabled\": true,  \"webhook_url\": \"...\", \"secret\": \"（選填）\" }\n  ]\n}\n```\n`enabled:false` 的通道會跳過。**token/webhook 是機密，config.json 勿進 git**（用 `.gitignore`）。\n`command` source 的指令會經 shell 執行（`shell=True`），**勿放不可信內容**。\n\n## 資料源（source.type）\n\n全部零依賴（`urllib` / `xml.etree` / `base64`），`run` 時會 `fetch()` 成 Message：\n\n| type | 用途 | 必填 | 可選 |\n|------|------|------|------|\n| `static` | 固定文字 | — | `title`, `body` |\n| `command` | 跑 shell 指令、stdout 當 body（可包任何腳本） | `command` | `title`, `timeout` |\n| `rss` | RSS / Atom feed 最新 N 則標題+連結 | `url` | `title`, `limit`(10) |\n| `github` | repo 最新 releases / commits / pulls | `repo`(`owner/name`) | `kind`(releases), `token`, `limit`(10), `title` |\n| `http_json` | GET 任意 JSON API，用 dot path 抽欄位 | `url` | `headers`, `list_path`, `title_key`(title), `url_key`, `limit`(10), `title` |\n| `jira` | JQL 撈 issues（Atlassian API token，Basic auth） | `base_url`, `jql` | `email`, `token`, `limit`(20), `title` |\n\n```jsonc\n{ \"type\": \"rss\",    \"url\": \"https://github.com/python/cpython/releases.atom\", \"limit\": 5 }\n{ \"type\": \"github\", \"repo\": \"pallets/flask\", \"kind\": \"releases\", \"token\": \"ghp_...\" }\n{ \"type\": \"http_json\", \"url\": \"https://api.example.com/news\",\n  \"list_path\": \"data.items\", \"title_key\": \"headline\", \"url_key\": \"link\" }\n{ \"type\": \"jira\", \"base_url\": \"https://you.atlassian.net\",\n  \"jql\": \"assignee=currentUser() AND statusCategory!=Done ORDER BY updated DESC\",\n  \"email\": \"you@x.com\", \"token\": \"ATATT...\" }\n```\n`http_json` 的 `list_path` / `title_key` / `url_key` 支援 dot path（含數字索引，如 `data.items.0.title`）；省略 `list_path` 則整個 response 當單筆/陣列。\n\n## 擴充\n\n- **新通道**：在 `channels.py` 加一個 `Channel` 子類（實作 `render` + `_send`）並註冊到 `REGISTRY`。\n- **新資料源**：在 `sources.py` 加 `Source` 子類（實作 `fetch()-\u003eMessage`）並註冊到 `REGISTRY`。\n\n## 模組用法\n```python\nfrom notifykit.message import Message, Section\nfrom notifykit.channels import build_channel\nmsg = Message(title=\"X\", sections=[Section(heading=\"變化\", lines=[\"- [PR](url)\"])])\nbuild_channel({\"type\":\"telegram\",\"token\":\"...\",\"chat_id\":\"...\"}).deliver(msg)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkao273183%2Fnotifykit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkao273183%2Fnotifykit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkao273183%2Fnotifykit/lists"}