Skip to main content

Python CLI tool and library for sending messages to Telegram

Project description

telegram-cli

PyPI Changelog Tests License

Python CLI tool and library for sending messages to Telegram

Installation

Install this tool using pip:

pip install telegram-cli

Usage

Basic

For sending a simple text message to a user o group, run:

export TELEGRAM_TOKEN='bot123456:de4dbeefde4dbeefde4dbeefde4dbeefde4dbeef' 

$ tgm message send --text 'Hello' --chat-id 123456
message-id: 676

Text from a stream (file or stdin)

For sending the content of a text file as message text:

# you have a text file with a message you want to send
echo "hey dude" > message.txt 

# (1) use the `--text-file` option
tgm message send --chat-id 123456 --text-file message.txt 

# (2) use `<`
tgm message send --chat-id 123456 < message.txt 

# (3) use `|`
cat message.txt | tgm message send --chat-id 123456
# or
echo "hey dude, it's me again" | tgm message send --chat-id 123456 

# (4) type your message and send it by typing `CTRL+D`
tgm message send --chat-id 123456
Hey dude, yeah it's me again!
<CTRL+D>

Parse modes

For using one of the supported parse modes (MarkdownV2 or HTML) of the entities in the message, run:

tgm message send --parse-mode "MarkdownV2" --text '**Hello**' --chat-id 123456

tgm message send --parse-mode "HTML" --text '<b>Hello</b>' --chat-id 123456

See the available formatting options to learn how to use --parse-mode.

For help, run:

telegram-cli --help

You can also use:

python -m telegram_cli --help

Development

To contribute to this tool, first checkout the code. Then create a new virtual environment:

cd telegram-cli
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

telegram-cli-0.2.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

telegram_cli-0.2.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file telegram-cli-0.2.0.tar.gz.

File metadata

  • Download URL: telegram-cli-0.2.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for telegram-cli-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6a69ca8c672b23038891d6362a2d2f8d25b4f482353fc8b6afc4a2ed6c7360c3
MD5 9d90dd8741beac7527d7be279b6d9aaa
BLAKE2b-256 0c954cc061bb4da41c2fbc419c6037f95c0ff89180dd87865a6c1b59378660db

See more details on using hashes here.

File details

Details for the file telegram_cli-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for telegram_cli-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 466211439554a2e99beb3695384da029082b350c5b37734200ea5cd879867c2a
MD5 732c3f1ff7e5d3360abe2e57fdde13fa
BLAKE2b-256 63fc02b177062f968e4b00d091ec24d1748c8118ee359d7ee6a5eb3fead0f3c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page