Skip to main content

tg-push

Python CLI for sending text plus an optional file to Telegram.

There is no bot polling loop, no MCP bridge, and no long-running server, just simple one-way messages.

Install

pip install tg-push

Or with pipx for an isolated install:

pipx install tg-push

Environment

Variable Required Description
TG_BOT_TOKEN yes Telegram bot token from @BotFather
TG_CHAT_ID yes Target chat ID or @channelusername

For a 1:1 bot chat, TG_CHAT_ID is your Telegram user id. For groups and channels, use the actual chat id instead.

Usage

tg-push --text "build finished"
tg-push --file ./render.png
tg-push --text "latest render" --file ./render.png
tg-push --text "report" --file ./report.pdf
git log -5 | tg-push --stdin
tg-push --stdin --file ./report.pdf < notes.txt

Multi-line text

Text is sent as-is, as plain text (no Markdown or HTML parsing). Telegram breaks the line wherever the text contains a real newline character, and an empty line gives a paragraph gap. A typed \n is not converted: --text "one\ntwo" arrives as the literal one\ntwo.

tg-push --text $'line one\nline two'      # bash/zsh $'...' quoting
printf 'line one\nline two\n' | tg-push --stdin
tg-push --stdin <<'EOF'                   # best for long messages
line one

line three, after a blank line
EOF

With --stdin, trailing newlines are dropped; everything else is kept.

Behavior

  • At least one of --text, --stdin or --file is required. --text and --stdin cannot be combined.
  • If --file is present, recognized images and videos are sent as Telegram media.
  • Other files are sent as documents, so PDFs, archives, and extensionless files work.
  • Supported image extensions: .jpg, .jpeg, .png, .webp
  • Supported video extensions: .mp4, .mov, .m4v, .webm, .mkv, .avi
  • If the text is longer than Telegram's media caption limit, the file is sent first and the text is sent as follow-up messages.
  • Text over 4096 characters is split into several messages, at line breaks where possible.
  • On success a one-line confirmation is printed to stdout, for example Sent report.pdf (document) to @mychannel. Errors go to stderr with exit code 1.
  • The project has no runtime dependencies outside the Python standard library.

Metadata

Release files for tg-push 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tg-push 2.1.0
File Size Uploaded
tg_push-2.1.0.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tg-push 2.1.0
File Interpreter ABI Platform
tg_push-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.3 kB

Release files / tg_push-2.1.0.tar.gz

Download URL tg_push-2.1.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b3b08bb433d6fbc73fecdca1f27de068a4d9acbd9c9ced4557bf93e770394589
BLAKE2b-256 checksum
How to use checksums
1e06f9075b4cbe84b1a42f24b6cddc9ae6f3b67420f30e6d8c8a65b21125d873
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / tg_push-2.1.0-py3-none-any.whl

Download URL tg_push-2.1.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ef34443a2c16a30e7756b680185eb78590bc3bb5de8ecc747dcfc68e23309cd
BLAKE2b-256 checksum
How to use checksums
c270176dc7da2e47c793b852ec703d955e174d52f871df99ccbd9af858c74a98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page