tg
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTelegram CLI
Telegram CLI
Fast Telegram CLI for reading, searching, and sending messages.
一款可用于读取、搜索和发送消息的高速Telegram CLI工具。
When to Use
适用场景
Use this skill when the user:
- Asks to check Telegram messages or inbox
- Wants to search Telegram for a topic/keyword
- Wants to send a Telegram message to someone
- Asks about a Telegram group, contact, or chat
- Wants to see unread messages
- Needs to look up group members or admins
当用户有以下需求时可使用该技能:
- 要求查看Telegram消息或收件箱
- 想要搜索Telegram中的某个主题/关键词
- 需要向某人发送Telegram消息
- 询问Telegram群组、联系人或聊天相关信息
- 想要查看未读消息
- 需要查询群组成员或管理员列表
Install
安装
bash
npm install -g @cyberdrk/tgOr from source:
bash
cd ~/Code/cyberdrk305/telegram && npm install && npm run build && npm linkbash
npm install -g @cyberdrk/tg或者从源码安装:
bash
cd ~/Code/cyberdrk305/telegram && npm install && npm run build && npm linkAuthentication
身份验证
First-time setup requires API credentials from https://my.telegram.org/apps
bash
tg authbash
tg authCommands
可用命令
Reading
读取类命令
bash
tg inbox # Unread messages summary
tg chats # List all chats
tg read "ChatName" -n 50 # Read last 50 messages
tg read "ChatName" --since "1h" # Messages from last hour
tg read @username -n 20 # Read DM with user
tg search "query" --chat "ChatName" # Search within chat
tg search "query" --all # Search all chatsbash
tg inbox # 未读消息汇总
tg chats # 列出所有聊天
tg read "ChatName" -n 50 # 读取最近50条消息
tg read "ChatName" --since "1h" # 读取最近1小时的消息
tg read @username -n 20 # 读取与该用户的私信
tg search "query" --chat "ChatName" # 在指定聊天中搜索
tg search "query" --all # 搜索所有聊天Writing
发送类命令
bash
tg send @username "message" # Send DM
tg send "GroupName" "message" # Send to group
tg reply "ChatName" 12345 "response" # Reply to message IDbash
tg send @username "message" # 发送私信
tg send "GroupName" "message" # 发送消息到群组
tg reply "ChatName" 12345 "response" # 回复指定ID的消息Contacts & Groups
联系人和群组类命令
bash
tg contact @username # Get contact info
tg members "GroupName" # List group members
tg admins "GroupName" # List admins only
tg groups --admin # Groups where you're adminbash
tg contact @username # 获取联系人信息
tg members "GroupName" # 列出群组成员
tg admins "GroupName" # 仅列出管理员
tg groups --admin # 列出你担任管理员的群组Status
状态类命令
bash
tg whoami # Show logged-in account
tg check # Verify sessionbash
tg whoami # 显示当前登录的账号
tg check # 验证会话是否有效Output Formats
输出格式
All commands support for structured output suitable for processing:
--jsonbash
tg inbox --json # JSON format
tg read "Chat" --json # JSON with messages array
tg chats --json # JSON with chat list所有命令都支持参数,可输出适合程序处理的结构化数据:
--jsonbash
tg inbox --json # JSON格式输出
tg read "Chat" --json # 输出包含消息数组的JSON
tg chats --json # 输出包含聊天列表的JSONExamples
使用示例
Check inbox:
bash
tg inboxRead recent messages from a chat:
bash
tg read "MetaDAO Community" -n 20Search for a topic:
bash
tg search "futarchy" --chat "MetaDAO"Send a message:
bash
tg send @username "Hello, checking in!"查看收件箱:
bash
tg inbox读取某个聊天的最近消息:
bash
tg read "MetaDAO Community" -n 20搜索某个主题:
bash
tg search "futarchy" --chat "MetaDAO"发送消息:
bash
tg send @username "Hello, checking in!"Notes
注意事项
- Chat names can be partial matches (e.g., "MetaDAO" matches "MetaDAO Community")
- Usernames must start with @ (e.g., @username)
- Messages are returned in reverse chronological order (newest first)
- The flag accepts formats like "1h", "30m", "7d"
--since
- 聊天名称支持部分匹配(例如"MetaDAO"可匹配"MetaDAO Community")
- 用户名必须以@开头(例如@username)
- 消息返回顺序为倒序(最新的在前)
- 参数支持"1h"、"30m"、"7d"这类格式
--since