JupNotiPy
Simple class for Python Telegram bot notifications, ideal for Jupyter notebooks and long-running scripts.
Features
- Easy setup: Quickly initialize your Telegram bot and get your chat_id.
- Customizable notifications: Send messages with custom text.
- Credential management: Cache and manage your bot credentials seamlessly.
- CLI support
- Python decorators support
How this works
JupNotiPy uses your Telegram bot to send you messages. The process involves two main steps:
- Initialization: Required for obtaining a chat_id. After first initialization you don't need login again because all data will be cached in file.
- Sending: Used for sending notifications through the given bot.
Installation
Install JupNotiPy using pip:
pip install jupnotipy
CLI Usage
Step 1: Initialize and Obtain chat_id
To initialize JupNotiPy and obtain your chat_id, use the following command:
jupnotipy init --bot_token "YOUR_BOT_TOKEN"
This will create a credentials file for future use.
Step 2: Send a Message
To send a message using the CLI:
jupnotipy send
Or, to send a custom message:
jupnotipy send --text "MY FANCY MESSAGE"
Python API
Step 1: Login and Initialize
To log in and initialize JupNotiPy within your Python script:
import jupnotipy
jupnotipy.login(bot_token="YOUR_BOT_TOKEN")
Step 2: Send Notifications
Use cached credentials to send a notification:
jupnotipy.notify()
Override cached credentials and send a notification:
jupnotipy.notify(bot_token="YOUR_BOT_TOKEN", chat_id=0)
Send a custom message:
jupnotipy.notify(message="MY_FANCY_MESSAGE")
Update cached credentials:
jupnotipy.notify(bot_token="YOUR_BOT_TOKEN", chat_id=0, update_credentials=True)
Example Code
Here's a sample Python script using JupNotiPy:
import jupnotipy
jupnotipy.login(bot_token="YOUR_BOT_TOKEN")
# use cached credentials
jupnotipy.notify()
# override the cached credentials
jupnotipy.notify(bot_token="YOUR_BOT_TOKEN", chat_id=0)
# define custom message
jupnotipy.notify(message="MY_FANCY_MESSAGE")
# update cached credentials
jupnotipy.notify(bot_token="YOUR_BOT_TOKEN", chat_id=0, update_credentials=True)
# use decorator function
@jupnotipy.notify_on_end()
def my_func():
for i in range(100):
# do something
...
# When the function execution is complete, you will be notified.
my_func()
Metadata
Release files for jupnotipy 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jupnotipy-0.1.7.tar.gz | 6.5 kB | Without provenance | Details for jupnotipy-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jupnotipy-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for jupnotipy-0.1.7-py3-none-any.whl |
Total release size: 14.1 kB
Release files / jupnotipy-0.1.7.tar.gz
| Download URL | jupnotipy-0.1.7.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d15add36a95a89a2a763772aa9986a2575750fdf3cf4972863a2217b3fe20f0
|
|
BLAKE2b-256 checksum How to use checksums |
60573c2583692f6b0fce2b80941235ae8cc8f149c9c92cf6aa87fefd2a6d0481
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.0 CPython/3.12.3 Darwin/23.5.0
|
Release files / jupnotipy-0.1.7-py3-none-any.whl
| Download URL | jupnotipy-0.1.7-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3eb66c4bcc490753ca1038829d33e449dbe4487ef24d736468c016da9e33893
|
|
BLAKE2b-256 checksum How to use checksums |
ca636c341ac0bb3bb0fcbc68d4b462e49c91778979dae4a65303006e81269881
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.0 CPython/3.12.3 Darwin/23.5.0
|
Security for jupnotipy 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.