微算力 · API 导航与自营网关
API 接入 EN
未登录登录
✨

Telegram Group Chat Setup

Telegram Group Chat Setup · v1.0.0
可以安装,但有提示 HAS_SCRIPTS
安全 S 级 作者 arekqq 公开目录收录
2.4k 下载 0 安装 6.5k 收藏 2 浏览

简介

Telegram Group Chat Setup

原始描述

Configure a MoltBot agent to participate in a Telegram group chat. Automates adding the group to the allowlist, setting mention patterns, and configuring sender permissions — all via a single gateway config patch. Use when the user wants to set up their bot in a Telegram group, enable cross-bot communication, or configure group mention gating.

通过你的 Agent 添加

安装目录:telegram-groupchat-setup/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/telegram-group-chat-setup/
Codex CLI~/.codex/skills/telegram-group-chat-setup/
DeepSeek Harness~/.agents/skills/telegram-group-chat-setup/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

中文使用说明 来自收录源

核心用法

本 Skill 用于快速将 MoltBot 智能体接入 Telegram 群组,实现自动化配置管理。用户只需提供群组 ID 和授权用户列表,系统将自动完成四项关键配置:检测机器人身份信息、构建多模式 @触发规则、应用网关配置补丁并重启服务、发送确认消息。全程无需手动编辑 JSON 配置文件,大幅降低 Telegram Bot 的群聊部署门槛。

显著优点

配置高度自动化:自动检测 bot 名称和用户名,智能构建包含 @username、botname、@botname 等多种格式的触发规则,确保群成员以任意常见方式 @机器人都能获得响应。

权限管控精细:通过 groupAllowFrom 实现白名单机制,仅指定用户可触发 bot,有效防止群聊消息过载和未授权调用;requireMention 强制要求显式提及,避免 bot 干扰正常对话。

安全设计严谨:无第三方依赖,仅使用系统标准工具 curl 和 Python3;敏感凭证仅从本地配置文件读取,无硬编码密钥;所有网络通信采用 HTTPS 加密对接 Telegram 官方 API。

多 bot 协作友好:明确支持同一群组部署多个 MoltBot 实例,各 bot 独立配置互不冲突,适合复杂自动化场景。

潜在缺点与局限性

前置手动步骤较多:用户需先在 @BotFather 关闭隐私模式、手动创建群组并添加 bot、获取群组 ID(负数的复杂格式),对新手存在学习成本。

配置合并逻辑复杂:当 groupAllowFrom 或 mentionPatterns 已存在值时,需先读取当前配置、合并数组再补丁,操作链较长,极端情况下可能出现合并冲突。

网关重启依赖:配置生效必须重启网关服务,在高峰期可能造成短暂服务中断,且重启失败时缺乏自动回滚机制。

Telegram 平台限制:隐私模式等关键设置无法通过 API 修改,必须人工介入;群组 ID 获取不便(需通过辅助 bot 或 API 查询)。

适合的目标群体

  • 社群运营者:管理大型 Telegram 社区,需要 AI 助手处理 FAQ、内容审核、活动通知
  • 开发团队:在项目组群中部署 CI/CD 通知 bot、代码审查助手、需求管理机器人
  • 多 bot 架构师:构建复杂自动化工作流,需要多个专业 bot 在同一群组协同工作
  • MoltBot 平台用户:已使用 MoltBot 构建智能体,希望扩展至 Telegram 群组场景

使用风险

性能风险:网关重启期间服务不可用,建议在低峰期执行配置;配置文件读取失败会导致整个流程中断。

依赖项风险:依赖系统 curl 和 Python3 环境,极端精简容器可能缺失;Telegram API 服务波动可能影响 bot 信息检测。

配置漂移风险:多管理员环境下,手动修改网关配置可能与 Skill 自动配置产生冲突,建议建立配置变更规范。

凭证泄露风险:虽然 Skill 本身安全,但用户本地配置文件若权限设置不当(非 600),可能被系统其他用户读取 bot token。

误授权风险:groupAllowFrom 配置错误可能导致未授权用户调用或合法用户被拒绝,建议配置后充分测试验证。

技能正文


name: telegram-groupchat-setup description: > Configure a MoltBot agent to participate in a Telegram group chat. Automates adding the group to the allowlist, setting mention patterns, and configuring sender permissions — all via a single gateway config patch. Use when the user wants to set up their bot in a Telegram group, enable cross-bot communication, or configure group mention gating.


Telegram Group Chat Setup

Automate the configuration needed for a MoltBot agent to work in a Telegram group.

What this skill does

  1. Adds a Telegram group to the gateway allowlist with requireMention: true
  2. Configures groupAllowFrom with specified user IDs / @usernames
  3. Auto-detects the bot's name and @username via the Telegram Bot API
  4. Sets mentionPatterns so the bot responds to its name and @username
  5. Applies the config patch and restarts the gateway

Prerequisites (manual steps)

Before running this skill, the user must:

  1. Create the Telegram group and add the bot to it
  2. Disable privacy mode in @BotFather: /mybots → select bot → Bot Settings → Group Privacy → Turn off (See references/telegram-privacy-mode.md for details)
  3. Know the group ID (negative number for Telegram groups)
  4. Know the user IDs or @usernames of people allowed to trigger the bot

Usage

The user provides:

  • group_id: Telegram group ID (e.g., -1001234567890)
  • allowed_users: List of Telegram user IDs or @usernames who can trigger the bot

Example prompt:

"Set up my bot in Telegram group -1001234567890. Allow users 123456789 and @some_user to ping me."

Implementation Steps

Step 1: Detect bot info

Run the detection script to get the bot's name and username:

bash skills/groupchat-setup/scripts/detect_bot_info.sh

This reads the bot token from the gateway config and returns the bot's name and username. If the script is unavailable, extract the bot token from channels.telegram.botToken in the gateway config and call https://api.telegram.org/bot<TOKEN>/getMe.

Step 2: Build mention patterns

From the detected bot info, construct mention patterns:

  • @<username> (e.g., @my_awesome_bot)
  • <name> lowercase (e.g., mybot)
  • @<name> lowercase (e.g., @mybot)

Remove duplicates. Patterns are case-insensitive regexes.

Step 3: Apply config patch

Use the gateway tool with action: "config.patch" to apply:

{
  "channels": {
    "telegram": {
      "groups": {
        "<group_id>": {
          "requireMention": true
        }
      },
      "groupAllowFrom": ["<user1>", "<user2>"]
    }
  },
  "messages": {
    "groupChat": {
      "mentionPatterns": ["@bot_username", "bot_name", "@bot_name"]
    }
  }
}

Important: If groupAllowFrom or mentionPatterns already have values, merge them (do not overwrite). Read the current config first with gateway action: "config.get", merge arrays, then patch.

Step 4: Confirm

After the gateway restarts, send a test message to the group confirming the setup:

"✅ Bot configured for this group! I'll respond when someone mentions my name. Allowed users: [list]."

Notes

  • requireMention: true means the bot only responds when explicitly mentioned — it won't spam every message.
  • groupAllowFrom restricts which senders can trigger the bot. Without it, messages from unknown senders may be dropped.
  • groupPolicy: "allowlist" is the Telegram default — only explicitly listed groups are active.
  • Privacy mode is a Telegram-side setting that cannot be changed via API. The user must do this in @BotFather.
  • For multi-bot groups (e.g., two MoltBot agents), each bot must run this setup independently on its own gateway.

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

没有标签

同类 Skill