返回顶部
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
安全检测
已通过
183
下载量
免费
免费
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 验证码

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

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

对话对象格式

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

读取命令(无副作用)

  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 <对话对象> 关键词——在特定聊天中搜索
  7. ntg --json global-search 关键词——在所有聊天中搜索
  8. ntg --json chat-info <聊天>——显示群组/频道信息

写入命令(有副作用)

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

群组管理

  1. 1. ntg create-group 主题 @用户1 @用户2——创建新群组
  2. ntg chat-add <聊天> <用户>——将用户添加到群组
  3. ntg chat-kick <聊天> <用户>——将用户移出群组
  4. ntg chat-rename <聊天> 新名称——重命名群组
  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-1776098534 技能

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

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

通过命令行安装

skillhub install telegram-cli-1776098534

下载

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

文件大小: 2.5 KB | 发布时间: 2026-4-14 14:42

v1.0.5 最新 2026-4-14 14:42
- 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
返回顶部