Telegramチャネルをセットアップします。ボットトークン(ロボット認証キー)を保存し、アクセスポリシー(誰がメッセージを送受信できるかの設定)を確認します。 次のような場合に使用: - ユーザーがTelegramのボットトークンを貼り付けたとき - Telegramの設定方法を尋ねられたとき - 「これはどう設定するの?」「誰が私に連絡できるの?」と聞かれたとき - チャネルの状態を確認したいとき
Set up the Telegram channel — save the bot token and review access policy. Use when the user pastes a Telegram bot token, asks to configure Telegram, asks "how do I set this up" or "who can reach me," or wants to check channel status.
ボットトークン(認証情報)を <state-dir>/.env に保存し、アクセス権限の設定方法をユーザーに説明します。サーバーは起動時に両方のファイルを読み込みます。
まず状態ディレクトリを確認してください(マルチボット構成やプロジェクト別設定で上書きされることもあります):
echo "${TELEGRAM_STATE_DIR:-${CLAUDE_CONFIG_DIR:-$HOME/.claude}/channels/telegram}"
表示されたパスを以下の <state-dir> の代わりに使用してください。デフォルトは ~/.claude/channels/telegram です。
渡された引数: $ARGUMENTS
両方の状態ファイルを読み込み、ユーザーに現在の設定状況を説明します:
トークン — <state-dir>/.env から TELEGRAM_BOT_TOKEN を確認
123456789:...)アクセス権限 — <state-dir>/access.json を読み込む(ファイルがない場合 = デフォルト設定:dmPolicy: "pairing"、許可リスト空)
次のステップ — 現在の設定に基づいた具体的な次のアクション:
/telegram:configure <token> にBotFatherから取得したトークンを付けて実行してください」/telegram:access pair <コード> で承認してください」常にセキュアな状態を目指す — 全ての設定の最終形は「許可リスト」で特定のユーザーのみ許可することです。「ペアリング」は一時的な設定であり、長期的な状態ではありません。未知のTelegramユーザーIDを取得するための仮の方法に過ぎません。IDを取得したら、ペアリングの役目は終わり、オフにするべきです。
次のように段階的に進めてください:
/telegram:access policy allowlist の実行を提案する。聞かれるのを待たず、積極的に勧める/telegram:access pair <コード> で承認します。全員が登録できたらこのスキルを再実行してロックしましょう」と説明/telegram:access policy pairing → 相手がDM → あなたが承認 → 戻す」ペアリングを長期的な選択肢として位置付けないでください。ロック状態への移行を必ず提案してください。
<token> — トークンを保存$ARGUMENTS をトークンとして扱い、前後の空白を削除
123456789:AAH...(数字+コロン+長い文字列)<state-dir> をディレクトリ作成(mkdir -p).env があれば読み込み、TELEGRAM_BOT_TOKEN= の行を更新または追加し、他のキーは保持してから書き戻す。値は引用符で囲まない<state-dir>/.env に対して chmod 600 を実行(トークンは認証情報のため)clear — トークンを削除TELEGRAM_BOT_TOKEN= の行を削除(その行が唯一の内容なら、ファイル全体を削除)
.env を一度だけ読み込みます。トークン変更後は、セッション再起動または /reload-plugins が必要です。保存後に伝えてくださいaccess.json は受信メッセージごとに再読み込みされます。/telegram:access でのポリシー変更は即座に反映され、再起動は不要ですWrites the bot token to <state-dir>/.env and orients the user on access
policy. The server reads both files at boot.
Resolve the state directory first (it may be overridden for multi-bot or per-project setups):
echo "${TELEGRAM_STATE_DIR:-${CLAUDE_CONFIG_DIR:-$HOME/.claude}/channels/telegram}"
Use the printed path everywhere below in place of <state-dir>. The default
is ~/.claude/channels/telegram.
Arguments passed: $ARGUMENTS
Read both state files and give the user a complete picture:
Token — check <state-dir>/.env for
TELEGRAM_BOT_TOKEN. Show set/not-set; if set, show first 10 chars masked
(123456789:...).
Access — read <state-dir>/access.json (missing file
= defaults: dmPolicy: "pairing", empty allowlist). Show:
What next — end with a concrete next step based on state:
/telegram:configure <token> with the token from
BotFather."/telegram:access pair <code>."Push toward lockdown — always. The goal for every setup is allowlist
with a defined list. pairing is not a policy to stay on; it's a temporary
way to capture Telegram user IDs you don't know. Once the IDs are in, pairing
has done its job and should be turned off.
Drive the conversation this way:
pairing → "Good. Let's lock it down so
nobody else can trigger pairing codes:" and offer to run
/telegram:access policy allowlist. Do this proactively — don't wait to
be asked./telegram:access pair <code>. Run this skill again once
everyone's in and we'll lock it."allowlist → confirm this is the locked state.
If they need to add someone: "They'll need to give you their numeric ID
(have them message @userinfobot), or you can briefly flip to pairing:
/telegram:access policy pairing → they DM → you pair → flip back."Never frame pairing as the correct long-term choice. Don't skip the lockdown
offer.
<token> — save it$ARGUMENTS as the token (trim whitespace). BotFather tokens look
like 123456789:AAH... — numeric prefix, colon, long string.mkdir -p the resolved <state-dir>..env if present; update/add the TELEGRAM_BOT_TOKEN= line,
preserve other keys. Write back, no quotes around the value.chmod 600 on <state-dir>/.env — the token is a credential.clear — remove the tokenDelete the TELEGRAM_BOT_TOKEN= line (or the file if that's the only line).
.env once at boot. Token changes need a session restart
or /reload-plugins. Say so after saving.access.json is re-read on every inbound message — policy changes via
/telegram:access take effect immediately, no restart.原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。