configure
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/telegram:configure — Telegram Channel Setup
/telegram:configure — Telegram频道设置
Writes the bot token to and orients the
user on access policy. The server reads both files at boot.
~/.claude/channels/telegram/.envArguments passed:
$ARGUMENTS将机器人令牌写入,并为用户介绍访问策略。服务器在启动时会读取这两个文件。
~/.claude/channels/telegram/.env传入的参数:
$ARGUMENTSDispatch on arguments
根据参数分发处理
No args — status and guidance
无参数——状态查询与指导
Read both state files and give the user a complete picture:
-
Token — checkfor
~/.claude/channels/telegram/.env. Show set/not-set; if set, show first 10 chars masked (TELEGRAM_BOT_TOKEN).123456789:... -
Access — read(missing file = defaults:
~/.claude/channels/telegram/access.json, empty allowlist). Show:dmPolicy: "pairing"- DM policy and what it means in one line
- Allowed senders: count, and list display names or IDs
- Pending pairings: count, with codes and display names if any
-
What next — end with a concrete next step based on state:
- No token → "Run with the token from BotFather."
/telegram:configure <token> - Token set, policy is pairing, nobody allowed → "DM your bot on
Telegram. It replies with a code; approve with ."
/telegram:access pair <code> - Token set, someone allowed → "Ready. DM your bot to reach the assistant."
- No token → "Run
Push toward lockdown — always. The goal for every setup is
with a defined list. 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.
allowlistpairingDrive the conversation this way:
- Read the allowlist. Tell the user who's in it.
- Ask: "Is that everyone who should reach you through this bot?"
- If yes and policy is still → "Good. Let's lock it down so nobody else can trigger pairing codes:" and offer to run
pairing. Do this proactively — don't wait to be asked./telegram:access policy allowlist - If no, people are missing → "Have them DM the bot; you'll approve
each with . Run this skill again once everyone's in and we'll lock it."
/telegram:access pair <code> - If the allowlist is empty and they haven't paired themselves yet → "DM your bot to capture your own ID first. Then we'll add anyone else and lock it down."
- If policy is already → 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:
allowlist→ they DM → you pair → flip back."/telegram:access policy pairing
Never frame as the correct long-term choice. Don't skip the lockdown
offer.
pairing读取两个状态文件,为用户展示完整状态:
-
令牌——检查中的
~/.claude/channels/telegram/.env。显示已设置/未设置;如果已设置,显示前10位字符并掩码(格式如TELEGRAM_BOT_TOKEN)。123456789:... -
访问权限——读取(文件缺失则使用默认值:
~/.claude/channels/telegram/access.json,空允许列表)。展示:dmPolicy: "pairing"- 私信策略及其一句话说明
- 允许发送消息的用户:数量,以及显示名称或ID列表
- 待配对请求:数量,如有则显示配对码和用户显示名称
-
下一步操作——根据当前状态给出具体的下一步建议:
- 未设置令牌 → “使用从BotFather获取的令牌运行。”
/telegram:configure <token> - 已设置令牌,策略为pairing,无允许用户 → “在Telegram上给你的机器人发私信。它会回复一个配对码;使用进行批准。”
/telegram:access pair <code> - 已设置令牌,已有允许用户 → “配置完成。给你的机器人发私信即可联系助手。”
- 未设置令牌 → “使用从BotFather获取的令牌运行
始终引导用户锁定权限。所有设置的目标都是启用(允许列表)模式并定义具体的用户列表。(配对)并非长期策略,只是一种临时方式,用于获取你不知道的Telegram用户ID。一旦ID被添加到允许列表,配对模式的使命就完成了,应该立即关闭。
allowlistpairing按照以下方式引导对话:
- 读取允许列表,告知用户当前列表中的用户。
- 询问:“这是所有可以通过该机器人联系你的用户吗?”
- 如果是,且当前策略仍为pairing → “很好。我们来锁定权限,避免其他人获取配对码:” 并主动提出运行。要主动执行此操作,不要等用户询问。
/telegram:access policy allowlist - 如果否,还有用户未添加 → “让他们给机器人发私信;你可以通过批准每个用户。所有人添加完成后再次运行此技能,我们会锁定权限。”
/telegram:access pair <code> - 如果允许列表为空,且你尚未配对自己的账号 → “先给你的机器人发私信来获取你自己的ID。然后我们再添加其他用户并锁定权限。”
- 如果当前策略已经是allowlist → 确认当前处于锁定状态。如果需要添加用户:“他们需要提供自己的数字ID(让他们给@userinfobot发消息获取),或者你可以暂时切换到配对模式:→ 他们发私信 → 你完成配对 → 切换回allowlist模式。”
/telegram:access policy pairing
永远不要将描述为正确的长期选择。不要跳过引导用户锁定权限的步骤。
pairing<token>
— save it
<token><token>
——保存令牌
<token>- Treat as the token (trim whitespace). BotFather tokens look like
$ARGUMENTS— numeric prefix, colon, long string.123456789:AAH... mkdir -p ~/.claude/channels/telegram- Read existing if present; update/add the
.envline, preserve other keys. Write back, no quotes around the value.TELEGRAM_BOT_TOKEN= - Confirm, then show the no-args status so the user sees where they stand.
- 将视为令牌(去除首尾空格)。BotFather生成的令牌格式为
$ARGUMENTS——数字前缀、冒号、长字符串。123456789:AAH... - 执行
mkdir -p ~/.claude/channels/telegram - 如果存在现有的文件则读取;更新或添加
.env行,保留其他键值对。写回文件时,令牌值不要加引号。TELEGRAM_BOT_TOKEN= - 确认操作完成,然后展示无参数时的状态,让用户了解当前配置情况。
clear
— remove the token
clearclear
——删除令牌
clearDelete the line (or the file if that's the only line).
TELEGRAM_BOT_TOKEN=删除行(如果这是文件中唯一的行,则直接删除文件)。
TELEGRAM_BOT_TOKEN=Implementation notes
实现说明
- The channels dir might not exist if the server hasn't run yet. Missing file = not configured, not an error.
- The server reads once at boot. Token changes need a session restart or
.env. Say so after saving./reload-plugins - is re-read on every inbound message — policy changes via
access.jsontake effect immediately, no restart./telegram:access
- 如果服务器尚未运行,channels目录可能不存在。文件缺失表示未配置,不属于错误。
- 服务器仅在启动时读取一次文件。修改令牌后需要重启会话或运行
.env使其生效。保存令牌后要告知用户这一点。/reload-plugins - 会在每次收到入站消息时重新读取——通过
access.json修改的策略会立即生效,无需重启。/telegram:access