tg
tg tool allows you to interact with a Telegram bot to send messages, get bot information, and list channels configured in your configuration file. I use it to keep my quick notes.
Usage
Commands
Server
Start a background server that continuously syncs messages from configured forum groups:
The server:
- Discovers all topics in configured forum groups at startup
- Pulls message history via MTProto
- Syncs new messages on the configured interval
- Creates markdown files in
~/.local/share/tg/<group_name>/
Note: New topics created after server start won't appear until restart.
Pull
One-shot pull of messages from all configured forum groups:
Open
Open a topic file in $EDITOR (uses fzf for pattern matching):
Send
Send a message to a topic:
List
List all discovered topics:
Todos
Aggregate TODOs from all topic files:
Bot Info
Retrieve information about the bot:
Configuration
Create a configuration file at ~/.config/tg.toml:
= 59753
= 1000
# MTProto credentials (required for pull/server)
# Get these from https://my.telegram.org/
= 12345
= "your_api_hash" # or use TELEGRAM_API_HASH env var
= "+1234567890" # or use PHONE_NUMBER_FR env var
= "@yourusername" # for session file naming
[]
= "-1002244305221" # forum group
= "-1002244305221/3" # specific topic in group
Groups are specified by chat ID (with -100 prefix for supergroups). Append /topic_id to target a specific topic.
Example config: ./examples/config.toml
Environment Variables
# for send/bot-info
# alternative to config
# alternative to config