A simple notifier for sending a message to a Telegram chat using the Telegram Bot API.
Project description
py-telegram-notifier
A simple utilization of the Telegram Bot API for sending messages to a Telegram chat by means of a context manager, function calls, or a CLI.
Installation
pip install py-telegram-notifier
Requirements
In order for the module to function, you must supply it with a bot token, and a chat id. Full instructions on creating a bot can be found here.
Usage as context manager
Firstly, set up the config for your Notifier. This only has to be done once, assuming you are sending messages from the same bot to the same chat every time.
from telegram_notifier import set_config_options
chat_id = 0000000000 # Your chat id
token = "0000000000" # Your bot token
set_config_options(chat_id=chat_id, token=token)
Then, you may use a Notifier as a context manager that will notify you of the type of exit that was encountered, including whether it finished with or without an error.
from telegram_notifier import Notifier
with Notifier("This is a task."):
# Code that takes a long time.
pass
Usage as CLI
Save bot information in settings by using:
telegram_notifier --chat_id XXXX --token YYYY
XXXX
the unique identifier for a target chat (chat id).YYYY
the bot token.
Send a message to a chat once the settings are saved:
telegram_notifier --message ZZZZ
ZZZZ
the message to send.
Disclaimer
The author of this software is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Telegram or any of its affiliates and is independently owned and created.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file py_telegram_notifier-0.2.4.tar.gz
.
File metadata
- Download URL: py_telegram_notifier-0.2.4.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8af513359e6cb55897e5bc16b8a954b5388d586025aef6d10ba7bcf354fe4a0e |
|
MD5 | a6002f0a663cf31133df725627d90512 |
|
BLAKE2b-256 | 482117e45e67e75469a4f663b64b831e54212cafeca249e97205a32f8dbfa84d |