Communitygithub.com

設定通知

透過自然語言設定 OMC 的通知整合(Telegram、Discord、Slack),在工作階段結束、需要輸入或完成背景任務時即時收到通知。

設定通知 是什麼?

此技能讓使用者能輕鬆透過自然語言指令,為 OMC(Oh My Claude Code)設定 Telegram、Discord 和 Slack 等通知服務。它會自動偵測現有設定,並逐步引導使用者完成各服務的配置,包括驗證 Token、選擇觸發事件(如工作階段結束、需要輸入等),以及測試通知。支援設定檔與環境變數兩種方式,並且會自動將配置寫入 `~/.claude/.omc-config.json` 中。主要用於 Claude Code 環境,讓開發者不再錯過重要事件。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Yeachan-Heo/oh-my-claudecode/tree/main/skills/configure-notifications

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

設定通知 是做什麼的?

設定 OMC 通知整合,讓你在工作階段結束、需要輸入或完成背景任務時收到通知。

路由

根據使用者的請求或引數,判斷要設定哪個提供者:

  • 如果觸發詞或引數包含「telegram」→ 請參考 Telegram 段落
  • 如果觸發詞或引數包含「discord」→ 請參考 Discord 段落
  • 如果觸發詞或引數包含「slack」→ 請參考 Slack 段落
  • 如果未指定提供者,請使用 AskUserQuestion:

問題:「您想設定哪個通知服務?」

選項:

  1. Telegram - Bot Token + 聊天室 ID。支援手機和電腦。
  2. Discord - Webhook 或 Bot Token + 頻道 ID。
  3. Slack - 傳入 Webhook 網址。

Telegram 設定

設定 Telegram 通知,讓 OMC 在工作階段結束、需要輸入或完成背景任務時發送訊息給你。

此技能如何運作

這是一個互動式的自然語言設定技能。透過 AskUserQuestion 逐步引導使用者完成設定,並將結果寫入 ${CLAUDE_CONFIG_DIR:-~/.claude}/.omc-config.json。

步驟 1:偵測現有設定

CONFIG_FILE="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/.omc-config.json"

if [ -f "$CONFIG_FILE" ]; then
  HAS_TELEGRAM=$(jq -r '.notifications.telegram.enabled // false' "$CONFIG_FILE" 2>/dev/null)
  CHAT_ID=$(jq -r '.notifications.telegram.chatId // empty' "$CONFIG_FILE" 2>/dev/null)
  PARSE_MODE=$(jq -r '.notifications.telegram.parseMode // "Markdown"' "$CONFIG_FILE" 2>/dev/null)

  if [ "$HAS_TELEGRAM" = "true" ]; then
    echo "EXISTING_CONFIG=true"
    echo "CHAT_ID=$CHAT_ID"
    echo "PARSE_MODE=$PARSE_MODE"
  else
    echo "EXISTING_CONFIG=false"
  fi
else
  echo "NO_CONFIG_FILE"
fi

如果找到現有設定,請向使用者顯示目前的設定內容,並詢問是否要更新或重新設定。

步驟 2:建立 Telegram Bot

如果使用者還沒有 Bot,請引導他們建立:

要設定 Telegram 通知,你需要一個 Telegram Bot Token 和你的聊天室 ID。

建立 BOT(如果你還沒有的話):
1. 打開 Telegram 搜尋 @BotFather
2. 發送 /newbot
3. 選擇一個名稱(例如「My OMC Notifier」)
4. 選擇一個使用者名稱(例如「my_omc_bot」)
5. BotFather 會給你一個類似這樣的 Token:123456789:ABCdefGHIjklMNOpqrsTUVwxyz

取得你的聊天室 ID:
1. 與你的新 Bot 開始對話(發送 /start)
2. 前往:https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
3. 尋找 "chat":{"id":YOUR_CHAT_ID}
   - 個人聊天室 ID 是正數(例如 123456789)
   - 群組聊天室 ID 是負數(例如 -1001234567890)

步驟 3:收集 Bot Token

使用 AskUserQuestion:

問題:「請貼上你的 Telegram Bot Token(來自 @BotFather)」

使用者在「其他」欄位中輸入他們的 Token。

驗證 Token:

  • 必須符合模式:數字:字母數字(例如 123456789:ABCdefGHI...)
  • 如果無效,請說明格式並再次詢問

步驟 4:收集聊天室 ID

使用 AskUserQuestion:

問題:「請貼上你的 Telegram 聊天室 ID(來自 getUpdates API 的數字)」

使用者在「其他」欄位中輸入他們的聊天室 ID。

驗證 聊天室 ID:

  • 必須是數字(個人為正數,群組為負數)
  • 如果無效,提供協助尋找它的功能:
# 協助使用者找到他們的聊天室 ID
BOT_TOKEN="USER_PROVIDED_TOKEN"
echo "正在擷取最近的訊息以尋找你的聊天室 ID..."
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/getUpdates" | jq '.result[-1].message.chat.id // .result[-1].message.from.id // "No messages found - send /start to your bot first"'

步驟 5:選擇解析模式

使用 AskUserQuestion:

問題:「你偏好哪種訊息格式?」

選項:

  1. Markdown(建議) - 使用 Markdown 語法的粗體、斜體、程式碼區塊
  2. HTML - 使用 HTML 標籤的粗體、斜體、程式碼

步驟 6:設定觸發事件

使用 AddUserQuestion 搭配 multiSelect:

問題:「哪些事件應該觸發 Telegram 通知?」

選項(multiSelect: true):

  1. 工作階段結束(建議) - 當 Claude 工作階段結束時
  2. 需要輸入 - 當 Claude 正在等待你的回覆(適合長時間執行的任務)
  3. 工作階段開始 - 當新工作階段開始時
  4. 工作階段持續中 - 當持續模式保持工作階段活躍時

預設選取:session-end + ask-user-question。

步驟 7:寫入設定

讀取現有設定,合併新的 Telegram 設定,然後寫回:

CONFIG_FILE="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/.omc-config.json"
mkdir -p "$(dirname "$CONFIG_FILE")"

if [ -f "$CONFIG_FILE" ]; then
  EXISTING=$(cat "$CONFIG_FILE")
else
  EXISTING='{}'
fi

# BOT_TOKEN, CHAT_ID, PARSE_MODE 是從使用者收集的
echo "$EXISTING" | jq \
  --arg token "$BOT_TOKEN" \
  --arg chatId "$CHAT_ID" \
  --arg parseMode "$PARSE_MODE" \
  '.notifications = (.notifications // {enabled: true}) |
   .notifications.enabled = true |
   .notifications.telegram = {
     enabled: true,
     botToken: $token,
     chatId: $chatId,
     parseMode: $parseMode
   }' > "$CONFIG_FILE"

如果使用者未選取所有事件,則加入事件特定設定:

針對每個未選取的事件,將其停用:

# 範例:如果未選取 session-start,則停用它
echo "$(cat "$CONFIG_FILE")" | jq \
  '.notifications.events = (.notifications.events // {}) |
   .notifications.events["session-start"] = {enabled: false}' > "$CONFIG_FILE"

步驟 8:測試設定

寫入設定後,提供傳送測試通知的選項:

使用 AskUserQuestion:

問題:「要傳送測試通知來驗證設定嗎?」

選項:

  1. 是,立即測試(建議) - 傳送測試訊息到你的 Telegram 聊天室
  2. 不用,我稍後再測試 - 跳過測試

如果要測試:

BOT_TOKEN="USER_PROVIDED_TOKEN"
CHAT_ID="USER_PROVIDED_CHAT_ID"
PARSE_MODE="Markdown"

RESPONSE=$(curl -s -w "\n%{http_code}" \
  "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
  -d "chat_id=${CHAT_ID}" \
  -d "parse_mode=${PARSE_MODE}" \
  -d "text=OMC test notification - Telegram is configured!")

HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | head -1)

if [ "$HTTP_CODE" = "200" ]; then
  echo "測試通知已成功傳送!"
else
  echo "失敗(HTTP $HTTP_CODE):"
  echo "$BODY" | jq -r '.description // "Unknown error"' 2>/dev/null || echo "$BODY"
fi

回報成功或失敗。常見問題:

  • 401 Unauthorized:Bot Token 無效
  • 400 Bad Request: chat not found:聊天室 ID 錯誤,或使用者尚未向 Bot 發送 /start
  • 網路錯誤:檢查與 api.telegram.org 的連線

步驟 9:確認

顯示最終設定摘要:

Telegram 通知已設定完成!

  Bot:        @your_bot_username
  聊天室 ID:    123456789
  格式:        Markdown
  事件:        session-end, ask-user-question

設定已儲存至:~/.claude/.omc-config.json

你也可以透過環境變數來設定:
  OMC_TELEGRAM_BOT_TOKEN=123456789:ABCdefGHI...
  OMC_TELEGRAM_CHAT_ID=123456789

要重新設定:/oh-my-claudecode:configure-notifications telegram
要設定 Discord:/oh-my-claudecode:configure-notifications discord
要設定 Slack:/oh-my-claudecode:configure-notifications slack

環境變數替代方案

使用者可以直接在 shell 設定檔中設定環境變數,完全跳過此精靈:

export OMC_TELEGRAM_BOT_TOKEN="123456789:ABCdefGHIjklMNOpqrsTUVwxyz"
export OMC_TELEGRAM_CHAT_ID="123456789"

環境變數會由通知系統自動偵測,無需 .omc-config.json。


Discord 設定

設定 Discord 通知,讓 OMC 在工作階段結束、需要輸入或完成背景任務時發送訊息給你。

此技能如何運作

這是一個互動式的自然語言設定技能。透過 AskUserQuestion 逐步引導使用者完成設定,並將結果寫入 ${CLAUDE_CONFIG_DIR:-~/.claude}/.omc-config.json。

步驟 1:偵測現有設定

CONFIG_FILE="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/.omc-config.json"

if [ -f "$CONFIG_FILE" ]; then
  # 檢查現有的 discord 設定
  HAS_DISCORD=$(jq -r '.notifications.discord.enabled // false' "$CONFIG_FILE" 2>/dev/null)
  HAS_DISCORD_BOT=$(jq -r '.notifications["discord-bot"].enabled // false' "$CONFIG_FILE" 2>/dev/null)
  WEBHOOK_URL=$(jq -r '.notifications.discord.webhookUrl // empty' "$CONFIG_FILE" 2>/dev/null)
  MENTION=$(jq -r '.notifications.discord.mention // empty' "$CONFIG_FILE" 2>/dev/null)

  if [ "$HAS_DISCORD" = "true" ] || [ "$HAS_DISCORD_BOT" = "true" ]; then
    echo "EXISTING_CONFIG=true"
    echo "WEBHOOK_CONFIGURED=$HAS_DISCORD"
    echo "BOT_CONFIGURED=$HAS_DISCORD_BOT"
    [ -n "$WEBHOOK_URL" ] && echo "WEBHOOK_URL=$WEBHOOK_URL"
    [ -n "$MENTION" ] && echo "MENTION=$MENTION"
  else
    echo "EXISTING_CONFIG=false"
  fi
else
  echo "NO_CONFIG_FILE"
fi

如果找到現有設定,請向使用者顯示目前的設定內容,並詢問是否要更新或重新設定。

步驟 2:選擇 Discord 方法

使用 AskUserQuestion:

問題:「您想用什麼方式傳送 Discord 通知?」

選項:

  1. Webhook(建議) - 在你的 Discord 頻道中建立一個 Webhook。簡單,不需要 Bot。只要貼上網址即可。
  2. Bot API - 使用 Discord Bot Token + 頻道 ID。更彈性,需要一個 Bot 應用程式。

步驟 3A:Webhook 設定

如果使用者選擇 Webhook:

使用 AskUserQuestion:

問題:「請貼上你的 Discord Webhook 網址。要建立一個:伺服器設定 > 整合 > Webhooks > 新增 Webhook > 複製網址」

使用者在「其他」欄位中輸入他們的 Webhook 網址。

驗證 網址:

  • 必須以 https://discord.com/api/webhooks/ 或 https://discordapp.com/api/webhooks/ 開頭
  • 如果無效,請說明格式並再次詢問

步驟 3B:Bot API 設定

如果使用者選擇 Bot API:

詢問兩個問題:

  1. 「請貼上你的 Discord Bot Token」 - 來自 discord.com/developers > 你的應用程式 > Bot > Token
  2. 「請貼上頻道 ID」 - 右鍵點擊頻道 > 複製頻道 ID(需要開發者模式)

步驟 4:設定提及(使用者標記)

使用 AskUserQuestion:

問題:「您希望通知提及(標記)某人嗎?」

選項:

  1. 是,提及一位使用者 - 透過其 Discord 使用者 ID 標記特定使用者
  2. 是,提及一個角色 - 透過其角色 ID 標記一個角色
  3. 不提及 - 僅發布訊息,不標記任何人

如果使用者想要提及一位使用者:

詢問:「要提及的 Discord 使用者 ID 是什麼?(右鍵點擊使用者 > 複製使用者 ID,需要開發者模式)」

提及格式為:<@USER_ID>(例如 <@1465264645320474637>)

如果使用者想要提及一個角色:

詢問:「要提及的 Discord 角色 ID 是什麼?(伺服器設定 > 角色 > 右鍵點擊角色 > 複製角色 ID)」

提及格式為:<@&ROLE_ID>(例如 <@&123456789>)

步驟 5:設定觸發事件

使用 AddUserQuestion 搭配 multiSelect:

問題:「哪些事件應該觸發 Discord 通知?」

選項(multiSelect: true):

  1. 工作階段結束(建議) - 當 Claude 工作階段結束時
  2. 需要輸入 - 當 Claude 正在等待你的回覆(適合長時間執行的任務)
  3. 工作階段開始 - 當新工作階段開始時
  4. 工作階段持續中 - 當持續模式保持工作階段活躍時

預設選取:session-end + ask-user-question。

步驟 6:可選的自訂顯示名稱

使用 AskUserQuestion:

問題:「自訂 Bot 顯示名稱?(在 Discord 中顯示為 Webhook 發送者名稱)」

選項:

  1. OMC(預設) - 顯示為「OMC」
  2. Claude Code - 顯示為「Claude Code」
  3. 自訂 - 輸入自訂名稱

步驟 7:寫入設定

讀取現有設定,合併新的 Discord 設定,然後寫回:

CONFIG_FILE="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/.omc-config.json"
mkdir -p "$(dirname "$CONFIG_FILE")"

if [ -f "$CONFIG_FILE" ]; then
  EXISTING=$(cat "$CONFIG_FILE")
else
  EXISTING='{}'
fi

針對 Webhook 方法:

使用收集到的值建立 notifications 物件,並透過 jq 合併到 .omc-config.json:

# WEBHOOK_URL, MENTION, USERNAME 是從使用者收集的
# EVENTS 是啟用的事件列表

echo "$EXISTING" | jq \
  --arg url "$WEBHOOK_URL" \
  --arg mention "$MENTION" \
  --arg username "$USERNAME" \
  '.notifications = (.notifications // {enabled: true}) |
   .notifications.enabled = true |
   .notifications.discord = {
     enabled: true,
     webhookUrl: $url,
     mention: (if $mention == "" then null else $mention end),
     username: (if $username == "" then null else $username end)
   }' > "$CONFIG_FILE"

針對 Bot API 方法:

echo "$EXISTING" | jq \
  --arg token "$BOT_TOKEN" \
  --arg channel "$CHANNEL_ID" \
  --arg mention "$MENTION" \
  '.notifications = (.notifications // {enabled: true}) |
   .notifications.enabled = true |
   .notifications["discord-bot"] = {
     enabled: true,
     botToken: $token,
     channelId: $channel,
     mention: (if $mention == "" then null else $mention end)
   }' > "$CONFIG_FILE"

如果使用者未選取所有事件,則加入事件特定設定:

針對每個未選取的事件,將其停用:

# 範例:如果未選取 session-start,則停用它
echo "$(cat "$CONFIG_FILE")" | jq \
  '.notifications.events = (.notifications.events // {}) |
   .notifications.events["session-start"] = {enabled: false}' > "$CONFIG_FILE"

步驟 8:測試設定

寫入設定後,提供傳送測試通知的選項:

使用 AskUserQuestion:

問題:「要傳送測試通知來驗證設定嗎?」

選項:

  1. 是,立即測試(建議) - 傳送測試訊息到你的 Discord 頻道
  2. 不用,我稍後再測試 - 跳過測試

如果要測試:

# 針對 webhook:
curl -s -o /dev/null -w "%{http_code}" \
  -H "Content-Type: application/json" \
  -d "{\"content\": \"${MENTION:+$MENTION\\n}OMC test notification - Discord is configured!\"}" \
  "$WEBHOOK_URL"

回報成功或失敗。如果失敗...

(內容因原始截斷而截斷)

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

agent-doc-discipline

Writing-time discipline for documents agents consume (the five surfaces, specs, tickets, .omc/skills/) — every rule checkable and carrying a why, steps before reference, one meaning in one home, no restating what the environment already says. Mandatory at drydock seed generation and the launch C5 sediment pass; opt-in for any other agent-facing doc edit. The companion of minimal-code-discipline: that one disciplines code, this one disciplines papers.

ai-slop-cleaner

Clean AI-generated code slop with a regression-safe, deletion-first workflow and optional reviewer-only mode

ask

Process-first advisor routing for Claude, Codex, Gemini, Antigravity, Grok, or Cursor via `omc ask`, with artifact capture and no raw CLI assembly

ask-navigator

Shipyard

autopilot

Full autonomous execution from idea to working code

autoresearch

Stateful single-mission improvement loop with strict evaluator contract, markdown decision logs, and max-runtime stop behavior

cancel

Cancel any active OMC mode (autopilot, ralph, ultragoal, swarm, ultrapilot, pipeline, team) and clean up retired legacy state

debug

Diagnose the current OMC session or repo state using logs, traces, state, and focused reproduction

deepinit

Deep codebase initialization with hierarchical AGENTS.md documentation

deep-interview

Socratic deep interview with mathematical ambiguity gating before explicit execution approval

drydock

Lay the keel of the shipyard harness in any repo — the 4-pillar shared environment (Context, Rules, Tools, Standards) across 5 surfaces (CLAUDE.md, skills, design-system, mcp/cli, shared context) so that every human and agent inherits the same design language and anyone can ship. Run once per repo; re-run with --check to audit drift.

execute

Carry an approved task through to working, verified code

external-context

Invoke parallel document-specialist agents for external web searches and documentation lookup

graph

Deterministic orchestration graph runtime - declarative DAG pipelines with journal-based crash recovery

harbor

Harbor intake for external work — the captain only handles unresolved decisions. Sweeps incoming issues and PRs, verifies every claim before disposition, reuses every decision already made, and hands the maintainer a docket whose pending items each carry one question with options, recommendation, impact and evidence. Agent-autonomous for facts and for actions covered by standing authorization; signed for every new judgment. Never merges.

hud

Configure HUD display options (layout, presets, display elements)

launch

Shipyard

loft

Loft the shape before cutting steel — answer a design question that prose cannot settle by building a throwaway artifact: a pure logic module in a clickable shell, or structurally different UI variants behind one route. The captain reacts to the artifact; the answer folds into the decision; the artifact never docks. Use when a design question stalls in words, when a navigator map carries a loft ticket, or when a spec discussion reaches

minimal-code-discipline

YAGNI-ladder coding discipline for writing changes — existence-first, reuse before writing, dependency ladder, shortest correct diff, with non-negotiables that must never be minimized away

omc-doctor

Diagnose and fix oh-my-claudecode installation issues

相關技能