| name | tgcli |
| description | Telegram CLI for syncing, searching, sending messages, and managing chats. Pure Rust implementation with no TDLib dependency. Supports multi-account setups, local FTS5 search, media download, scheduled messages, and real-time daemon mode. Use for interacting with Telegram from the command line or in scripts. |
tgcli – Telegram CLI
Pure Rust Telegram client. No TDLib. Fast. Cross-platform.
Quick Start
tgcli auth
tgcli sync
tgcli chats list --output markdown
tgcli messages list --chat 987654321 --output markdown
tgcli send --to 123456789 --message "Hello there!"
Core Commands
Sync
Fetch updates from Telegram servers. Always incremental (skips duplicates).
tgcli sync
tgcli sync -q
tgcli sync --full
tgcli sync --download-media
tgcli sync --stream
Chats
Manage chats: list, search, archive, pin, mute, create groups, join, leave.
tgcli chats list --output markdown
tgcli chats list --limit 50
tgcli chats search "DevTeam"
tgcli chats archive 987654321
tgcli chats pin 987654321
tgcli chats mute 987654321
tgcli chats create --group "Project Alpha" --user 111222333
tgcli chats join https://t.me/joinchat/...
tgcli chats leave 987654321
Messages
List, search, show, download, delete messages. Supports forum topics.
tgcli messages list --chat 987654321 --output markdown
tgcli messages list --chat 987654321 --limit 100
tgcli messages list --chat 987654321 --topic 42
tgcli messages search "project deadline" --output markdown
tgcli messages search --global "urgent task"
tgcli messages show --chat 987654321 --message 4567
tgcli messages context --chat 987654321 --message 4567
tgcli messages download --chat 987654321 --message 4567
tgcli messages delete --chat 987654321 --message 4567
Send
Send messages, files, voice/video notes, scheduled messages, replies.
tgcli send --to 123456789 --message "Hello from tgcli"
tgcli send --to 123456789 --file report.pdf
tgcli send --to 123456789 --voice note.ogg
tgcli send --to 123456789 --video video.mp4
tgcli send --to 123456789 --message "Meeting tomorrow" --schedule "tomorrow 9am"
tgcli send --to 123456789 --message "Agreed" --reply-to 5678
Contacts
List and search contacts.
tgcli contacts list --output markdown
tgcli contacts search "Alice"
Users
Show user info, block/unblock.
tgcli users show 123456789
tgcli users block 123456789
tgcli users unblock 123456789
Stickers
List, search, and send stickers.
tgcli stickers list --output markdown
tgcli stickers search "cat"
tgcli stickers send --to 123456789 --sticker CAT_ABC123
Folders
Create and manage chat folders.
tgcli folders list --output markdown
tgcli folders create "Work Chats"
tgcli folders delete 5
Admin (Groups/Channels)
Ban, kick, promote, demote members.
tgcli admin ban --chat 111222333 --user 999888777
tgcli admin kick --chat 111222333 --user 999888777
tgcli admin unban --chat 111222333 --user 999888777
tgcli admin promote --chat 111222333 --user 999888777
tgcli admin demote --chat 111222333 --user 999888777
Daemon (Real-Time)
Listen for real-time updates from Telegram servers. Optional — use sync for most workflows.
tgcli daemon
tgcli daemon --stream
tgcli daemon --no-backfill
tgcli daemon --ignore 987654321
tgcli daemon --ignore-channels
Other
tgcli read --chat 987654321
tgcli typing --chat 987654321
tgcli profile show
tgcli profile set --first-name "Alex"
tgcli completions bash
tgcli wipe
Multi-Account
Use --store to manage multiple Telegram accounts:
tgcli --store ~/.tgcli-personal sync
tgcli --store ~/.tgcli-work chats list --output markdown
tgcli --store ~/.tgcli-bot messages list --chat 987654321
Output Formats
Always use markdown when available (recommended for LLMs and piping):
tgcli chats list
tgcli chats list --output markdown
tgcli chats list --output json
Markdown advantages:
- Readable structure (headers, bullet points, dividers)
- Pipe to ripgrep/grep for filtering
- Feed to LLMs for processing
- Consistent across commands
Storage
Data stored in --store directory (default ~/.tgcli/):
~/.tgcli/session.db # Telegram session & authentication
~/.tgcli/tgcli.db # Messages, chats, contacts (FTS5-indexed)
~/.tgcli/media/ # Downloaded media files
Tips & Tricks
Search messages with ripgrep:
tgcli messages list --chat 987654321 --output markdown | rg "keyword"
Export to markdown file:
tgcli messages list --chat 987654321 --output markdown > exported.md
Sync multiple accounts in parallel:
for account in personal work bot; do
tgcli --store ~/.tgcli-$account sync -q &
done
wait
Links