用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/nanocoai/nanoclaw --skill add-telegram命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | add-telegram |
| description | Add Telegram channel integration via Chat SDK. |
Adds Telegram bot support via the Chat SDK bridge. NanoClaw doesn't ship
channels in trunk — this skill copies the Telegram adapter, its pairing helper,
and their tests in from the channels branch. The
pair-telegram setup step is maintained in trunk, so it is not copied here.
The mechanical steps under Apply carry nc: directive fences: an agent
reads the prose and applies them, and a parser can apply them deterministically
from the same document. Every directive is idempotent, so the whole skill is
safe to re-run; anything a parser can't apply falls back to the prose beside it.
Fetch the channels branch and copy the Telegram adapter, its pairing helper
(with its test), and the registration test into place (overwrite — the branch
is canonical):
src/channels/telegram.ts
src/channels/telegram-pairing.ts
src/channels/telegram-pairing.test.ts
src/channels/telegram-registration.test.ts
Append the self-registration import to the channel barrel (skipped if the line is already present). This one line is the skill's only reach-in into core:
import './telegram.js';
Add the pair-telegram loader to the STEPS map in setup/index.ts, inside the
dormant marker region (skipped if already present — pair-telegram ships in core,
so this idempotent-skips on a normal install, but is expressed for a
clean-upstream rebuild). The pairing handshake below spawns this step:
'pair-telegram': () => import('./pair-telegram.js'),
Pinned to an exact version — the supply-chain policy rejects ranges and latest:
@chat-adapter/telegram@4.29.0
Build first: it guards the typed createChatSdkBridge(...) core call and proves
the dependency is installed. Then run the one integration test.
pnpm run build
pnpm exec vitest run src/channels/telegram-registration.test.ts
telegram-registration.test.ts imports the real channel barrel and asserts the
registry contains telegram. It goes red if the import line is deleted or drifts,
if the barrel fails to evaluate, or if @chat-adapter/telegram isn't installed
(the import throws) — so it also covers the dependency from step 4. End-to-end
delivery against a real bot is verified manually once the service runs.
Bot creation in Telegram is human and interactive — no parser can click through BotFather. The adapter is installed and registered, but it can't receive a message until the bot exists. Tell the user:
Create the Telegram bot:
1. Open Telegram and message @BotFather — Telegram's official bot for creating bots.
2. Send /newbot and follow the prompts: a friendly name, then a username that must end in "bot".
3. Copy the bot token it gives you (looks like 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11a).
4. Planning to use the bot in group chats? Send /mybots → your bot → Bot Settings → Group Privacy → Turn off, so the bot can see all messages and not just @mentions.
Collect the bot token and store it — the bridge reads it from .env (set-if-absent,
so a value you've already filled in is never overwritten) and syncs it to the
container:
Paste the bot token from BotFather (looks like `123456:ABC-DEF...`).
TELEGRAM_BOT_TOKEN={{bot_token}}
Confirm the token works and capture the bot's handle — getMe returns the bot
account and fails here if the token is bad. You'll use the handle to open the
right chat just before pairing:
curl -sf https://api.telegram.org/bot{{bot_token}}/getMe | jq -er '.result.username'
Restart the service so it loads the Telegram adapter and the token you just stored, and wait for its CLI socket. The adapter must be live and polling before pairing — it's the thing that observes the code you send:
bash setup/lib/restart.sh
Telegram tokens carry no user binding, so the agent proves you own the chat with a one-time pairing handshake: it issues a 4-digit code, you send those exact 4 digits to the bot from the chat you want to register, and the live adapter matches them. Open the bot first so you're on the right screen when the code appears. Tell the user:
Open @{{bot_username}} (https://telegram.me/{{bot_username}}) in Telegram now and keep it on screen — a 4-digit pairing code is about to appear in this terminal. When it does, send just those 4 digits to the bot as a message (in a group chat with Group Privacy on, prefix them with @{{bot_username}}). A wrong guess is rejected and a fresh code is issued automatically.
Run the pairing handshake. It prints the code, streams "waiting…" and wrong-code
feedback while it watches for your message, and resolves your chat address
telegram:<chatId> plus your Telegram user id once the code matches:
pnpm exec tsx setup/index.ts --step pair-telegram -- --intent main
owner_handle (your Telegram user id) and platform_id (telegram:<chatId>)
are what the owner-wiring step needs. The greeting goes out over the same chat as
soon as pairing completes.
If you're in the middle of /setup, return to the setup flow now. Otherwise wire
this channel with /init-first-agent (or /manage-channels).
telegramtelegram:{chatId} (e.g. telegram:123456789 for a DM, telegram:-1001234567890 for a group — negative chat IDs are groups/channels).pnpm exec tsx setup/index.ts --step pair-telegram -- --intent <main|wire-to:folder|new-agent:folder>. The step prints a 4-digit code (and re-prints a fresh one if a wrong code invalidates it, up to 5 times); tell the user to send just those 4 digits from the chat they want to register (DM the bot for main, post in the group otherwise; with Group Privacy ON, prefix @<botname> CODE). Success emits a PAIR_TELEGRAM block with STATUS=success, PLATFORM_ID, IS_GROUP, ADMIN_USER_ID (the bare Telegram user id) and PAIRED_USER_ID (the telegram:-prefixed form). The service must be running — the polling adapter is what observes the code.The bot token paste is rejected. A BotFather token is <numeric bot id>:<35+ character secret> — e.g. 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11a. Pasting only the part after the colon, or the bot's @username, won't pass. Recover the full token any time by sending /token to @BotFather.
getMe fails. The token was revoked (a /revoke or a fresh /token invalidates the old value) or picked up whitespace in the paste. Get the current token from BotFather and re-paste it.
Pairing never completes. The live adapter is what observes the code, so the service must be running — the restart step comes before pairing for exactly this reason. Send just the 4 digits from the exact chat you want registered; in a group with Group Privacy on, prefix them with @<botname>. Wrong guesses are fine (a fresh code is issued, up to 5 times), but a dead adapter waits forever.
The bot ignores group messages. Group Privacy is on, so the bot only sees @-mentions and replies. BotFather → /mybots → your bot → Bot Settings → Group Privacy → Turn off — then remove and re-add the bot to the group so the change takes effect.
Everything green but no replies. Run pnpm exec vitest run src/channels/telegram-registration.test.ts — red means the barrel import or the @chat-adapter/telegram install drifted, so re-run the Apply steps. If green, restart again (bash setup/lib/restart.sh) and check logs/nanoclaw.error.log for token errors.