Skip to main content

No project description provided

Project description

Telegram Exception Alerts

Code style: black

Installation

pip install telegram_exception_alerts

or

poetry add telegram_exception_alerts

Usage

After you initialize the alerter instance you can attach the decorator to any function. If it raises an exception information will be send to the chat specified in chat_id (don't forget that if you want to send notification to a channel you need to prepend that chat_id with -100).

Normal initialization

from telegram_exception_alerts import Alerter

alerter = Alerter(bot_token='YOUR_BOT_TOKEN', chat_id='YOUR_CHAT_ID')

@alerter.exception_alert
def some_func_that_can_raise_an_exception():
    raise RuntimeError('this is an exception')

Initialization from environment (recommended)

You can also initialize the alerter from environment variables. This is the recommended way because it will make sure you're not committing sensitive information to the repo.

  • ALERT_BOT_TOKEN - your bot token
  • ALERT_CHAT_ID - your chat id to receive notifications
from telegram_exception_alerts import Alerter

alerter = Alerter.from_environment()

@alerter.exception_alert
def some_func_that_can_raise_an_exception():
    raise RuntimeError('this is an exception')

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_exception_alerts-0.1.0.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

telegram_exception_alerts-0.1.0-py3-none-any.whl (2.7 kB view hashes)

Uploaded Python 3

Supported by

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