Telegram CLI
2026-03-29
新闻来源:网淘吧
围观:19
电脑广告
手机广告
Telegram CLI
用于快速读取、搜索和发送消息的Telegram命令行界面。
使用场景
当用户出现以下需求时,可使用此功能:
- 要求查看Telegram消息或收件箱
- 想要在Telegram中搜索某个主题/关键词
- 想要向某人发送Telegram消息
- 询问Telegram群组、联系人或聊天信息
- 想要查看未读消息
- 需要查找群组成员或管理员
安装
npm install -g @cyberdrk/tg
或从源代码安装:
cd ~/Code/cyberdrk305/telegram && npm install && npm run build && npm link
认证
首次设置需要从以下网址获取API凭证:https://my.telegram.org/apps
tg auth
命令
读取
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 chats
写入
tg send @username "message" # Send DM
tg send "GroupName" "message" # Send to group
tg reply "ChatName" 12345 "response" # Reply to message ID
联系人及群组
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 admin
状态
tg whoami # Show logged-in account
tg check # Verify session
输出格式
所有命令均支持--json适用于处理的结构化输出:
tg inbox --json # JSON format
tg read "Chat" --json # JSON with messages array
tg chats --json # JSON with chat list
示例
检查收件箱:
tg inbox
读取聊天中的最近消息:
tg read "MetaDAO Community" -n 20
搜索主题:
tg search "futarchy" --chat "MetaDAO"
发送消息:
tg send @username "Hello, checking in!"
注意事项
- 聊天名称可以部分匹配(例如,"MetaDAO" 匹配 "MetaDAO Community")
- 用户名必须以 @ 开头(例如,@username)
- 消息按时间倒序返回(最新的在前)
- --since
标志接受 "1h"、"30m"、"7d" 等格式flag accepts formats like "1h", "30m", "7d"
文章底部电脑广告
手机广告位-内容正文底部
上一篇:Aubrai Longevity Research
下一篇:CallRail


微信扫一扫,打赏作者吧~