This skill should be used for comprehensive Telegram automation via Telethon API. Use for sending/receiving messages, monitoring chats, running a background daemon that triggers Claude Code sessions, managing channels/groups, and downloading media. Triggers on "telegram daemon", "monitor telegram", "telegram bot", "spawn Claude from telegram", or any Telethon-related request. IMPORTANT: Use `draft` command for "драфт/draft", use `send` for "отправь/send"; if ambiguous, ASK before sending.
| User says | Claude does | Clarify? |
|---|---|---|
| "драфт", "draft", "сделай драфт" | draft | No |
| "отправь", "пошли", "send" | send | No |
| "напиши сообщение" (ambiguous) | Ask what user wants | Yes |
draft command immediatelysend command immediately"сделай драфт для lv: привет" Uses immediately
draft --chat "lv" --text "привет"User: "отправь сообщение Маше: встретимся в 5?"
Claude: Uses send --chat "Маша" --text "встретимся в 5?" immediately
User: "напиши сообщение для Маши: встретимся в 5?" Claude: Asks "Создать драфт или сразу отправить?"
Full Telethon API wrapper with daemon mode and Claude Code integration. Supports interactive setup, background message monitoring, and automatic Claude session spawning per chat.
Run setup wizard on first use:
python3 scripts/tg.py setup
This guides through:
For use from Claude Code or scripts without TTY:
# Step 1: Provide credentials and trigger code send
python3 scripts/tg.py setup --api-id 12345678 --api-hash abc123... --phone +1234567890
# Step 2: User receives code on phone, then complete auth
python3 scripts/tg.py setup --api-id 12345678 --api-hash abc123... --phone +1234567890 --code 12345
# If 2FA enabled, add password
python3 scripts/tg.py setup --api-id 12345678 --api-hash abc123... --phone +1234567890 --code 12345 --password mypassword
The script auto-detects TTY and switches between interactive/non-interactive modes.
# Check connection status
python3 scripts/tg.py status
# List chats
python3 scripts/tg.py list
# Get recent messages from a chat
python3 scripts/tg.py recent "John Doe" --limit 20
# Search messages
python3 scripts/tg.py search "meeting notes"
# Configure daemon triggers interactively
python3 scripts/tg.py daemon-config
# Start daemon (foreground with logs)
python3 scripts/tgd.py start --foreground
# Start daemon (background)
python3 scripts/tgd.py start
# View daemon logs
python3 scripts/tgd.py logs
# List all chats
python3 scripts/tg.py list [--limit 30] [--search "term"]
# Fetch recent messages
python3 scripts/tg.py recent [CHAT] [--limit 50] [--days 7] [--format markdown|json] [--output file.md]
# Search messages by content
python3 scripts/tg.py search QUERY [--chat "Chat Name"] [--limit 50] [--format markdown|json]
# Fetch unread messages
python3 scripts/tg.py unread [--chat "Chat Name"] [--format markdown|json]
# Fetch forum thread
python3 scripts/tg.py thread CHAT_ID THREAD_ID [--limit 100]
# Send message
python3 scripts/tg.py send --chat "Chat Name" --text "Message text" [--reply-to MSG_ID] [--file path] [--topic TOPIC_ID]
# Edit message
python3 scripts/tg.py edit --chat "Chat Name" --message-id MESSAGE_ID --text "New text"
# Delete messages
python3 scripts/tg.py delete --chat "Chat Name" --message-ids 123 456 789 [--no-revoke]
# Forward messages
python3 scripts/tg.py forward --from "Source" --to "Dest" --message-ids 123 456
# Mark messages as read
python3 scripts/tg.py mark-read --chat "Chat Name" [--max-id MSG_ID]
# Save/update a draft message
python3 scripts/tg.py draft --chat "Chat Name" --text "Draft text" [--reply-to MSG_ID] [--no-preview]
# Clear a draft (save empty text)
python3 scripts/tg.py draft --chat "Chat Name" --text ""
# Clear all drafts
python3 scripts/tg.py draft --clear-all
# List all drafts
python3 scripts/tg.py drafts [--limit 50]
# Send a draft as a message (clears the draft)
python3 scripts/tg.py draft-send --chat "Chat Name"
Note: Use "me" as the chat name to target Saved Messages (your own chat). The literal name "Saved Messages" doesn't work as it's localized differently per user.
# Download media from chat
python3 scripts/tg.py download "Chat Name" [--limit 5] [--output-dir ~/Downloads] [--message-id ID] [--type voice|video|photo]
# Transcribe voice messages
python3 scripts/tg.py transcribe "Chat Name" MESSAGE_ID [--method telegram|groq|whisper]
# Batch transcribe voice messages
python3 scripts/tg.py transcribe "Chat Name" --batch [--limit 10]
# Append messages to today's daily note
python3 scripts/tg.py to-daily "Chat Name" [--vault ~/Brains/brain] [--section "Telegram"]
# Append messages to a person's note
python3 scripts/tg.py to-person "Chat Name" "Person Name" [--vault ~/Brains/brain]
The skill supports three transcription methods with automatic fallback:
GROQ_API_KEY environment variable)pip install openai-whisper)# Use Telegram's transcription (Premium feature)
python3 scripts/tg.py transcribe "Chat" 123
# Force Groq transcription
python3 scripts/tg.py transcribe "Chat" 123 --method groq
# Force local Whisper
python3 scripts/tg.py transcribe "Chat" 123 --method whisper
The daemon monitors Telegram for messages matching configured triggers and can:
Triggers are stored in ~/.config/telegram-telethon/daemon.yaml: