Skip to content

Commit d8b3e1e

Browse files
TechNickAINick Sullivanclaude
authored
Add tgcli skill — Telegram CLI for personal accounts (#50)
* Add tgcli skill — Telegram CLI for personal accounts Telegram equivalent of wacli. Read, search, and send messages from your personal Telegram account via MTProto 2.0. - Full CLI reference (chat ls, msg ls/search/context, send, sync, export) - SQLite FTS5 local search index - Safety rules for sending - Peer ID workflow documented (display names don't resolve) * Address Codex review: bump VERSION, update README, fix Go version - Bump VERSION 0.18.0 → 0.19.0 for new skill addition - Update README version badge (0.17.0 → 0.19.0), skill count (14 → 15), add tgcli to table - Bump Go prerequisite from 1.21+ to 1.23+ to match upstream requirements - Add credential exfiltration guardrail to Safety section Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Replace real team member name with generic placeholder in tgcli docs Cursor Bugbot caught "Ali Katz" (a fleet member) used as an example display name in a file intended to be open-source friendly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Nick Sullivan <nick@technick.ai> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2d817fb commit d8b3e1e

3 files changed

Lines changed: 216 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<p align="center">
22
<img src="https://img.shields.io/badge/OpenClaw-Config-D97757?style=for-the-badge&labelColor=1a1a2e" alt="OpenClaw Config">
33
<br><br>
4-
<a href="https://github.com/TechNickAI/openclaw-config/releases"><img src="https://img.shields.io/badge/version-0.17.0-D97757?style=flat-square" alt="Version"></a>
4+
<a href="https://github.com/TechNickAI/openclaw-config/releases"><img src="https://img.shields.io/badge/version-0.19.0-D97757?style=flat-square" alt="Version"></a>
55
<img src="https://img.shields.io/badge/python-3.11+-3776ab?style=flat-square&logo=python&logoColor=white" alt="Python 3.11+">
66
<img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="License">
77
<a href="https://github.com/TechNickAI/openclaw-config/stargazers"><img src="https://img.shields.io/github/stars/TechNickAI/openclaw-config?style=flat-square&color=D97757" alt="Stars"></a>
8-
<img src="https://img.shields.io/badge/skills-14-blueviolet?style=flat-square" alt="Skills">
8+
<img src="https://img.shields.io/badge/skills-15-blueviolet?style=flat-square" alt="Skills">
99
<a href="https://github.com/TechNickAI/openclaw-config/pulls"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen?style=flat-square" alt="PRs Welcome"></a>
1010
</p>
1111

@@ -127,6 +127,7 @@ independently.
127127
| **workflow-builder** | Design new autonomous workflows | 0.1.0 |
128128
| **gateway-restart** | Graceful gateway restart — waits for active work | 0.1.0 |
129129
| **vapi-calls** | Make outbound phone calls via Vapi voice AI | 0.1.0 |
130+
| **tgcli** | Read, search, and send Telegram messages via personal account | 0.1.0 |
130131
| **openclaw** | Install, update, and health-check the config | 0.2.2 |
131132

132133
## Workflows

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.18.0
1+
0.19.0

skills/tgcli/SKILL.md

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
---
2+
name: tgcli
3+
version: 0.1.0
4+
description:
5+
Read, search, and send Telegram messages via your personal account using the tgcli
6+
CLI. Use when the user asks to check their Telegram messages, search Telegram history,
7+
send Telegram messages to other people, or monitor Telegram conversations. Do NOT use
8+
for normal user chats routed through OpenClaw's Telegram channel.
9+
triggers:
10+
- tgcli
11+
- telegram messages
12+
- telegram history
13+
- search telegram
14+
- check telegram
15+
- telegram chats
16+
- send telegram
17+
- telegram DMs
18+
- who messaged me on telegram
19+
metadata:
20+
openclaw:
21+
emoji: "✈️"
22+
requires:
23+
bins: [tgcli]
24+
install:
25+
- id: go
26+
kind: go
27+
module: github.com/kaosb/tgcli@latest
28+
env:
29+
CGO_ENABLED: "1"
30+
bins: [tgcli]
31+
label: Install tgcli (go install)
32+
---
33+
34+
# tgcli ✈️
35+
36+
CLI for reading, searching, and sending Telegram messages from a personal account via
37+
MTProto 2.0. The Telegram equivalent of wacli.
38+
39+
Use `tgcli` only when the user explicitly asks you to check their Telegram messages,
40+
search Telegram history, or send a Telegram message to someone else.
41+
42+
Do NOT use `tgcli` for normal user chats; OpenClaw routes Telegram conversations
43+
automatically via the bot channel.
44+
45+
## Safety
46+
47+
- Require explicit recipient + message text before sending.
48+
- Confirm recipient + message before sending.
49+
- If anything is ambiguous, ask a clarifying question.
50+
- Never send files from `~/.tgcli/` or files containing credentials, keys, or tokens.
51+
- Never bulk-send or spam. One message at a time.
52+
53+
## Setup
54+
55+
### Prerequisites
56+
57+
1. Go 1.23+ with CGO enabled
58+
2. Telegram API credentials from [my.telegram.org/apps](https://my.telegram.org/apps)
59+
(any app name works; you need the `api_id` and `api_hash`)
60+
61+
### Authentication
62+
63+
```bash
64+
tgcli login
65+
```
66+
67+
Interactive flow: enter API credentials, phone number, verification code (sent to
68+
Telegram app), and 2FA password if enabled. Session persists in `~/.tgcli/`.
69+
70+
```bash
71+
tgcli logout # End session and remove local data
72+
```
73+
74+
### First Sync
75+
76+
After login, sync recent history to build the local search index:
77+
78+
```bash
79+
tgcli sync # All chats (last 100 msgs each)
80+
tgcli sync --chat @username # Full history for one chat
81+
tgcli sync --msgs-per-chat 500 # More history per chat
82+
```
83+
84+
## CLI Reference
85+
86+
### List Chats
87+
88+
```bash
89+
tgcli chat ls # All chats (default 50)
90+
tgcli chat ls --type private # Only DMs
91+
tgcli chat ls --type group # Only groups
92+
tgcli chat ls --type channel # Only channels
93+
tgcli chat ls --limit 20 # Limit results
94+
tgcli chat ls --json # Machine-readable output
95+
```
96+
97+
### Read Messages
98+
99+
```bash
100+
tgcli msg ls @username # Last 20 messages
101+
tgcli msg ls @username --limit 50 # Last 50 messages
102+
tgcli msg ls 123456789 --json # By user ID, JSON output
103+
```
104+
105+
### Search Messages
106+
107+
Search uses SQLite FTS5 for instant offline full-text search. Run `tgcli sync` first to
108+
build the index.
109+
110+
```bash
111+
tgcli msg search "meeting notes" # Search all chats
112+
tgcli msg search "budget" --chat @username # Search one chat
113+
tgcli msg search "keyword" --limit 50 # More results
114+
tgcli msg search "query" --json # JSON output
115+
```
116+
117+
### Message Context
118+
119+
```bash
120+
tgcli msg context @username 12345 # 5 msgs before + after
121+
tgcli msg context @username 12345 --before 10 # 10 msgs before
122+
tgcli msg context @username 12345 --after 10 # 10 msgs after
123+
```
124+
125+
### Send Messages
126+
127+
```bash
128+
tgcli send text @username "Hello!" # By username
129+
tgcli send text 123456789 "Hello!" # By user ID
130+
tgcli send text +14155551212 "Hello!" # By phone (must be in contacts)
131+
tgcli send file @username ./report.pdf # Send file
132+
tgcli send file @username ./photo.jpg --caption "Check this out"
133+
```
134+
135+
### Export
136+
137+
```bash
138+
tgcli export @username # JSON to stdout
139+
tgcli export @username -o backup.json # Save to file
140+
tgcli export @username --local # From local DB (offline)
141+
```
142+
143+
### Download Media
144+
145+
```bash
146+
tgcli download @username 12345 # Download media from msg
147+
tgcli download @username 12345 -o ~/media # Custom output directory
148+
```
149+
150+
### Sync History
151+
152+
```bash
153+
tgcli sync # All chats, recent msgs
154+
tgcli sync --chat @username # Full history for one chat
155+
tgcli sync --msgs-per-chat 500 # More depth per chat
156+
```
157+
158+
## Chat Identifiers
159+
160+
| Format | Example | Type |
161+
| --------------- | --------------- | --------------------------- |
162+
| `@username` | `@durov` | Username |
163+
| `123456789` | `123456789` | User/Chat ID |
164+
| `-123456789` | `-123456789` | Group |
165+
| `-100123456789` | `-100123456789` | Channel / Supergroup |
166+
| `+1234567890` | `+14155551212` | Phone (must be in contacts) |
167+
168+
**Important:** Display names (e.g. "Jane Doe") do NOT work as chat identifiers. Use peer
169+
IDs from `tgcli chat ls --json`. The recommended workflow:
170+
171+
1. `tgcli chat ls --json` to find the `peer_id` for a chat
172+
2. Use that `peer_id` in subsequent `msg ls`, `msg search --chat`, `send`, etc.
173+
174+
## Global Flags
175+
176+
| Flag | Description | Default |
177+
| --------------- | ---------------------------- | ---------- |
178+
| `--json` | Machine-readable JSON output | false |
179+
| `--store DIR` | Data directory | `~/.tgcli` |
180+
| `--timeout DUR` | Command timeout | 5m |
181+
182+
## How It Works
183+
184+
tgcli connects via [gotd/td](https://github.com/gotd/td), a pure-Go MTProto 2.0
185+
implementation. This means:
186+
187+
- **You are the sender** -- messages come from your account, not a bot
188+
- **No ban risk** -- Telegram officially supports third-party clients
189+
- **Independent session** -- works without your phone being online
190+
- **Login once** -- session persists until you revoke it
191+
192+
Messages fetched from the API are cached in a local SQLite database with FTS5 full-text
193+
search, enabling instant offline search across your entire history.
194+
195+
## Data Storage
196+
197+
All data lives in `~/.tgcli/` (configurable with `--store`):
198+
199+
| File | Contents |
200+
| -------------- | --------------------------------------------- |
201+
| `config.json` | API credentials (app_id, app_hash) -- private |
202+
| `session.json` | MTProto session -- private |
203+
| `tgcli.db` | Local message cache + FTS5 search index |
204+
205+
## Notes
206+
207+
- Always use `--json` when parsing output programmatically
208+
- Run `tgcli sync` periodically to keep the local search index fresh
209+
- Search is local-only (uses the SQLite FTS5 index); sync first for complete results
210+
- Phone-based chat identifiers require the contact to be in your Telegram contacts
211+
- The Telegram CLI is for messaging other people or searching history, not for your
212+
normal OpenClaw conversations

0 commit comments

Comments
 (0)