telegram
Send Telegram messages and files from the shell
TLDR
SYNOPSIS
telegram [-t *token*] [-c *chat_id*]... [-f *file* | -i *image* | -V *video*] [-M | -H] [*message* | -]
DESCRIPTION
telegram (script from the telegram.sh project) sends messages, files, images, and videos through the Telegram Bot API using bash and curl. Typical uses are cron notifications, shipping small server files past awkward network paths, and piping command output to yourself.Create a bot with @BotFather, message the bot once from your client, then discover your chat_id with telegram -t *token* -l. Token and chat id can come from flags, environment variables (TELEGRAM_TOKEN, TELEGRAM_CHAT), or config files (see CONFIGURATION). Multiple -c values send to several chats.
PARAMETERS
-t *token*
Bot API token from BotFather.-c *chat_id*
Destination chat id; repeatable for multiple chats.-f *file*
Send a document/file.-i *image*
Send a photo with preview.-V *video*
Send a video file.-M
Parse message as Markdown.-H
Parse message as HTML (when supported by your script version).-l
List known chats for the bot (jq improves formatting).-m
Print the last received message: message id, sender id, chat id, text.-
Read the message body from stdin (sent as monospace when piped).*message*
Text to send; may include shell newlines.Proxy: set HTTPS_PROXY (or put it in a config file) for curl-supported proxies such as socks5://127.0.0.1:1234.
CONFIGURATION
Settings are loaded in order (later wins):1. /etc/telegram.sh.conf2. ~/.telegram.sh3. ~/.telegram.sh.conf4. ./telegram.sh.conf (beside the script)5. Environment TELEGRAM_TOKEN / TELEGRAM_CHAT6. Command-line flagsExample file:
TELEGRAM_CHAT="12345678"
CAVEATS
Only bash and curl are required; -l pretty-print needs jq. Message size and media types follow Telegram Bot API limits. Misconfigured tokens or chat ids fail at the API. This is not the official Telegram Desktop client (telegram-desktop).
SEE ALSO
curl(1), jq(1), notify-send(1)
