| name | tg |
| description | Use tg to send Telegram messages, attach files, and listen for replies from the command line. Trigger when the user wants to send notifications, share files, or receive messages via Telegram. |
| user-invocable | true |
tg - Telegram CLI
tg sends messages and files to a pre-configured Telegram chat.
Setup
Ask the user to run tg setup once to configure the bot token and chat ID.
You cannot do the setup alone.
Sending messages
tg "Hello, World!"
tg hello world
echo "build done" | tg
cat log.txt | tg
tg -e "line one\nline two"
tg -m markdown "*bold* _italic_"
tg -m html "<b>bold</b>"
tg -s "low priority alert"
Attaching files
tg attach report.pdf
tg attach *.log
tg attach foo.txt bar.c
tg attach -s backup.tar.gz
Interactive mode
Stream stdin updates by editing a single message:
some-command | tg -i
some-command | tg -i -f 2
Listening for replies
tg listen
tg listen > out.txt
Config management
tg config show
tg config reset
Library usage
use tg_cli::telegram;
#[tokio::main]
async fn main() {
telegram!("build {} complete", 42);
}
Key flags
| Flag | Description |
|---|
-e | Interpret escape sequences |
-n | Strip trailing newline |
-m MODE | Parse mode: markdown or html |
-i | Interactive mode (edit one message) |
-f SECS | Interactive update frequency |
-s | Silent (no notification) |
-q | Quiet (suppress non-error output) |