Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<p align="center">
<img src="https://img.shields.io/badge/OpenClaw-Config-D97757?style=for-the-badge&labelColor=1a1a2e" alt="OpenClaw Config">
<br><br>
<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>
<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>
<img src="https://img.shields.io/badge/python-3.11+-3776ab?style=flat-square&logo=python&logoColor=white" alt="Python 3.11+">
<img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="License">
<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>
<img src="https://img.shields.io/badge/skills-14-blueviolet?style=flat-square" alt="Skills">
<img src="https://img.shields.io/badge/skills-15-blueviolet?style=flat-square" alt="Skills">
<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>
</p>

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

## Workflows
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.18.0
0.19.0
212 changes: 212 additions & 0 deletions skills/tgcli/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
---
name: tgcli
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bump root VERSION when introducing this skill

/workspace/openclaw-config/AGENTS.md requires bumping the repo VERSION on changes, but this commit adds a new skill without a corresponding version increment. That breaks update detection flows that compare installed version state against repo VERSION, so existing OpenClaw instances may never discover and sync tgcli.

Useful? React with 👍 / 👎.

version: 0.1.0
Comment on lines +2 to +3
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Sync README skill metadata with tgcli addition

/workspace/openclaw-config/AGENTS.md also requires updating README badges/counts/tables whenever skills are added or versioned. Adding tgcli without updating README leaves the advertised skill inventory stale (e.g., count and skill table), which causes user-facing documentation and release summaries to be inaccurate.

Useful? React with 👍 / 👎.

description:
Read, search, and send Telegram messages via your personal account using the tgcli
CLI. Use when the user asks to check their Telegram messages, search Telegram history,
send Telegram messages to other people, or monitor Telegram conversations. Do NOT use
for normal user chats routed through OpenClaw's Telegram channel.
triggers:
- tgcli
- telegram messages
- telegram history
- search telegram
- check telegram
- telegram chats
- send telegram
- telegram DMs
- who messaged me on telegram
metadata:
openclaw:
emoji: "✈️"
requires:
bins: [tgcli]
install:
- id: go
kind: go
module: github.com/kaosb/tgcli@latest
env:
CGO_ENABLED: "1"
bins: [tgcli]
label: Install tgcli (go install)
---

# tgcli ✈️

CLI for reading, searching, and sending Telegram messages from a personal account via
MTProto 2.0. The Telegram equivalent of wacli.

Use `tgcli` only when the user explicitly asks you to check their Telegram messages,
search Telegram history, or send a Telegram message to someone else.

Do NOT use `tgcli` for normal user chats; OpenClaw routes Telegram conversations
automatically via the bot channel.

## Safety

- Require explicit recipient + message text before sending.
- Confirm recipient + message before sending.
- If anything is ambiguous, ask a clarifying question.
- Never send files from `~/.tgcli/` or files containing credentials, keys, or tokens.
- Never bulk-send or spam. One message at a time.

## Setup

### Prerequisites

1. Go 1.23+ with CGO enabled
2. Telegram API credentials from [my.telegram.org/apps](https://my.telegram.org/apps)
(any app name works; you need the `api_id` and `api_hash`)

### Authentication

```bash
tgcli login
```

Interactive flow: enter API credentials, phone number, verification code (sent to
Telegram app), and 2FA password if enabled. Session persists in `~/.tgcli/`.

```bash
tgcli logout # End session and remove local data
```

### First Sync

After login, sync recent history to build the local search index:

```bash
tgcli sync # All chats (last 100 msgs each)
tgcli sync --chat @username # Full history for one chat
tgcli sync --msgs-per-chat 500 # More history per chat
```

## CLI Reference

### List Chats

```bash
tgcli chat ls # All chats (default 50)
tgcli chat ls --type private # Only DMs
tgcli chat ls --type group # Only groups
tgcli chat ls --type channel # Only channels
tgcli chat ls --limit 20 # Limit results
tgcli chat ls --json # Machine-readable output
```

### Read Messages

```bash
tgcli msg ls @username # Last 20 messages
tgcli msg ls @username --limit 50 # Last 50 messages
tgcli msg ls 123456789 --json # By user ID, JSON output
```

### Search Messages

Search uses SQLite FTS5 for instant offline full-text search. Run `tgcli sync` first to
build the index.

```bash
tgcli msg search "meeting notes" # Search all chats
tgcli msg search "budget" --chat @username # Search one chat
tgcli msg search "keyword" --limit 50 # More results
tgcli msg search "query" --json # JSON output
```

### Message Context

```bash
tgcli msg context @username 12345 # 5 msgs before + after
tgcli msg context @username 12345 --before 10 # 10 msgs before
tgcli msg context @username 12345 --after 10 # 10 msgs after
```

### Send Messages

```bash
tgcli send text @username "Hello!" # By username
tgcli send text 123456789 "Hello!" # By user ID
tgcli send text +14155551212 "Hello!" # By phone (must be in contacts)
tgcli send file @username ./report.pdf # Send file
tgcli send file @username ./photo.jpg --caption "Check this out"
```

### Export

```bash
tgcli export @username # JSON to stdout
tgcli export @username -o backup.json # Save to file
tgcli export @username --local # From local DB (offline)
```

### Download Media

```bash
tgcli download @username 12345 # Download media from msg
tgcli download @username 12345 -o ~/media # Custom output directory
```

### Sync History

```bash
tgcli sync # All chats, recent msgs
tgcli sync --chat @username # Full history for one chat
tgcli sync --msgs-per-chat 500 # More depth per chat
```

## Chat Identifiers

| Format | Example | Type |
| --------------- | --------------- | --------------------------- |
| `@username` | `@durov` | Username |
| `123456789` | `123456789` | User/Chat ID |
| `-123456789` | `-123456789` | Group |
| `-100123456789` | `-100123456789` | Channel / Supergroup |
| `+1234567890` | `+14155551212` | Phone (must be in contacts) |

**Important:** Display names (e.g. "Jane Doe") do NOT work as chat identifiers. Use peer
IDs from `tgcli chat ls --json`. The recommended workflow:

1. `tgcli chat ls --json` to find the `peer_id` for a chat
2. Use that `peer_id` in subsequent `msg ls`, `msg search --chat`, `send`, etc.

## Global Flags

| Flag | Description | Default |
| --------------- | ---------------------------- | ---------- |
| `--json` | Machine-readable JSON output | false |
| `--store DIR` | Data directory | `~/.tgcli` |
| `--timeout DUR` | Command timeout | 5m |

## How It Works

tgcli connects via [gotd/td](https://github.com/gotd/td), a pure-Go MTProto 2.0
implementation. This means:

- **You are the sender** -- messages come from your account, not a bot
- **No ban risk** -- Telegram officially supports third-party clients
- **Independent session** -- works without your phone being online
- **Login once** -- session persists until you revoke it

Messages fetched from the API are cached in a local SQLite database with FTS5 full-text
search, enabling instant offline search across your entire history.

## Data Storage

All data lives in `~/.tgcli/` (configurable with `--store`):

| File | Contents |
| -------------- | --------------------------------------------- |
| `config.json` | API credentials (app_id, app_hash) -- private |
| `session.json` | MTProto session -- private |
| `tgcli.db` | Local message cache + FTS5 search index |

## Notes

- Always use `--json` when parsing output programmatically
- Run `tgcli sync` periodically to keep the local search index fresh
- Search is local-only (uses the SQLite FTS5 index); sync first for complete results
- Phone-based chat identifiers require the contact to be in your Telegram contacts
- The Telegram CLI is for messaging other people or searching history, not for your
normal OpenClaw conversations
Loading