返回顶部
n

node-telegram-cliTelegram命令行工具

CLI tool for Telegram via MTProto. Send/read messages, manage groups, search conversations, download media, and automate Telegram workflows. Use when the task involves any Telegram account interaction.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.5
安全检测
已通过
209
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

node-telegram-cli

来源与信任

  1. 1. 仓库:https://github.com/baontq23/node-telegram-cli
  2. npm:https://www.npmjs.com/package/node-telegram-cli(通过来源验证发布)
  3. 凭证通过操作系统密钥链安全存储(macOS 密钥链 / Windows 凭据管理器 / Linux 密钥服务),而非明文文件

安装

  1. 1. 需要 Node.js >= 20
  2. 全局安装:npm install -g node-telegram-cli
  3. 验证:ntg --version
  4. 运行一次 ntg login — 交互式操作,需要手机号 + Telegram 的 OTP 验证码

关键规则:始终使用 JSON 模式

  1. 1. 每条命令都添加 --json 标志以获得机器可读输出
  2. --json 是全局标志 — 可放在子命令之前或之后
  3. 示例:ntg --json inbox、ntg --json search @user keyword

对等体格式

  1. 1. @username — 最可靠,例如 @johndoe
  2. 手机号 — 用于没有用户名的联系人,例如 +84901234567
  3. me — 你自己的已保存消息
  4. 聊天标题 — 用引号括起来的群组/频道名称,例如 My Group

读取命令(无副作用)

  1. 1. ntg --json inbox — 列出最近对话
  2. ntg --json inbox --unread — 仅未读对话
  3. ntg --json inbox --private — 仅私密一对一聊天
  4. ntg --json inbox --unread --private — 组合筛选条件
  5. ntg --json inbox --chat --limit — 特定聊天的消息
  6. ntg --json search keyword — 在特定聊天中搜索
  7. ntg --json global-search keyword — 在所有聊天中搜索
  8. ntg --json chat-info — 显示群组/频道信息

写入命令(有副作用)

  1. 1. ntg msg text — 发送文本消息
  2. ntg msg text --silent — 静默发送(无通知声音)
  3. ntg fwd — 按 ID 转发消息
  4. ntg mark-read — 将所有消息标记为已读
  5. ntg delete-msg — 删除消息
  6. ntg send-photo — 发送照片
  7. ntg send-video — 发送视频
  8. ntg send-file — 以纯文本消息形式发送文本文件
  9. ntg download --chat — 从消息中下载媒体
  10. ntg download --chat --type — 指定媒体类型(photo、video、audio、doc)
  11. ntg view --chat — 下载并用系统查看器打开
  12. ntg clean-downloads — 删除所有已下载的媒体文件

群组管理

  1. 1. ntg create-group Topic @user1 @user2 — 创建新群组
  2. ntg chat-add — 将用户添加到群组
  3. ntg chat-kick — 从群组中移除用户
  4. ntg chat-rename New Name — 重命名群组
  5. ntg chat-set-photo — 设置群组头像

联系人管理

  1. 1. ntg add-contact — 添加联系人
  2. ntg rename-contact — 重命名联系人

JSON 输出模式

收件箱(对话列表)

  1. 1. name — 联系人/聊天显示名称
  2. peer — 用作 参数的标识符
  3. peerType — username | phone | id
  4. type — user | group | channel
  5. unreadCount — 未读消息数量
  6. lastMessage — 文本/说明(仅媒体时为空字符串)
  7. lastMessageId — 与 ntg download 配合使用以获取媒体
  8. mediaType — photo | video | document | audio | voice | sticker | location | contact | poll | null
  9. date — ISO 8601 时间戳

聊天消息(inbox --chat)

  1. 1. id — 消息 ID
  2. date — ISO 8601 时间戳
  3. sender — 发送者显示名称
  4. text — 消息文本/说明
  5. mediaType — 与上述相同的值
  6. isOutgoing — 如果由你发送则为 true

错误处理

  1. 1. 退出码 0 = 成功
  2. 退出码 1 = 错误(未登录、未找到对等体等)
  3. 如果未登录,命令失败并显示:Not logged in. Run ntg login first.

重要说明

  1. 1. 不要使用 ntg chat — 它是交互式的,会阻塞标准输入,不适合自动化
  2. 会话持续到调用 ntg logout — 命令之间无需重新登录
  3. 下载的文件保存到 ~/.telegram-cli/downloads/
  4. 下载媒体时始终指定 --chat 以标识来源聊天

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 telegram-cli-1776380701 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 telegram-cli-1776380701 技能

通过命令行安装

skillhub install telegram-cli-1776380701

下载

⬇ 下载 node-telegram-cli v1.0.5(免费)

文件大小: 2.5 KB | 发布时间: 2026-4-17 16:29

v1.0.5 最新 2026-4-17 16:29
- Documentation restructured and condensed for clarity and easier reference.
- Added explicit sections for command usage, peer formats, group/contact management, and JSON output schemas.
- Security/storage approach is now clearly summarized at the top.
- All examples and descriptions reinforce the requirement to use the `--json` flag for automation.
- Interactive/unsafe commands (e.g., `ntg chat`) are clearly marked as unsuitable for AI/automation.
- No functional or code changes detected; this is a documentation-focused update.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部