Skip to main content

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.2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tg_notify-0.1.2-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file tg_notify-0.1.2.tar.gz.

File metadata

  • Download URL: tg_notify-0.1.2.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

Hashes for tg_notify-0.1.2.tar.gz
Algorithm Hash digest
SHA256 53e74e4a69d6ba7569fdc171e9967035690c2a112270ed564b721e63a102340c
MD5 5178f5a1382091156aa3e88735a0df24
BLAKE2b-256 b40049231c92bf55b92a364f0b66dfdd9c13bee67d22b96f4efb71fe1d769969

See more details on using hashes here.

File details

Details for the file tg_notify-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: tg_notify-0.1.2-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

Hashes for tg_notify-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bf0ec402e6d99a4f893590c2a5bdb7207f1dfa4cddc26ace30bf620c10c180c3
MD5 685b29b93e0bc0837fb95a33a93d0e1d
BLAKE2b-256 28e137d9b6f77ace839091c01d88d58d8c4128e230ef5ca33829ce5b516fa741

See more details on using hashes here.

Supported by

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