Rate-limited Telegram notifications with priority queue
Project description
tg-notify
Rate-limited Telegram notifications with priority queue.
Install
pip install tg-notify
Quick Start
export TELEGRAM_BOT_TOKEN="your-bot-token"
export TELEGRAM_CHAT_ID="-1001234567890"
from tg_notify import send_telegram_message
send_telegram_message("Hello from tg-notify!")
Shortcuts
from tg_notify import send_error, send_success, send_warning, send_info, send_stats, send_alert
send_error("DB connection failed", {"host": "db.example.com"})
send_success("Deploy complete", {"version": "1.2.3"})
send_warning("Disk usage high", {"usage": "89%"})
send_info("New user registered", {"email": "user@example.com"})
send_stats("Daily Report", {"users": 1500, "revenue": "$3200"})
send_alert("Server down!", {"server": "prod-1"})
TelegramSender
from tg_notify import TelegramSender
sender = TelegramSender(bot_token="your-token", chat_id=-123456)
sender.send_message("Hello!")
sender.send_photo("chart.png", caption="Daily stats")
sender.send_document("report.pdf")
Priority Queue
Messages are queued with 4 priority levels and rate-limited to 20 msg/sec:
| Priority | Use case |
|---|---|
CRITICAL (1) |
Security alerts, system down |
HIGH (2) |
Errors, important warnings |
NORMAL (3) |
Info, success messages |
LOW (4) |
Stats, debug |
Auto-cleanup drops low-priority messages when queue fills up.
from tg_notify import telegram_queue
# Flush before exit (CLI scripts)
telegram_queue.flush(timeout=5)
License
MIT
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
tg_notify-0.1.4.tar.gz
(10.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
tg_notify-0.1.4-py3-none-any.whl
(12.8 kB
view details)
File details
Details for the file tg_notify-0.1.4.tar.gz.
File metadata
- Download URL: tg_notify-0.1.4.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ec668aae3713f26d7119658296c3a13d479b36ac08ea4762694e26e1ff993da
|
|
| MD5 |
9b0318690424486d6756c0a8ba505b40
|
|
| BLAKE2b-256 |
517961d66d8331533bdf63e45680e33473f776d6ed5cf8c2ba4b75e2ca93a001
|
File details
Details for the file tg_notify-0.1.4-py3-none-any.whl.
File metadata
- Download URL: tg_notify-0.1.4-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ff15dc6e33fbdfeb3059ffe6136f70b222481f2b5aff822b313e0d4a72e77e2
|
|
| MD5 |
e2cf4abf243d0f668e6bb2cd8d632695
|
|
| BLAKE2b-256 |
52284a97534d846d598298e612c5aa035aacb8d0dc14ba9dd9f7c4c1e6e8afa4
|