No project description provided
Project description
Telegram Exception Alerts
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 tokenALERT_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
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
Built Distribution
Close
Hashes for telegram_exception_alerts-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e46f11fb51b4f30de5eab61a9bacd4b29ea95139ae2fb187bf8db9db4a364732 |
|
MD5 | 6a7d82344240ce5e4bc30c8ac27b9ece |
|
BLAKE2b-256 | 0a5c8ec45533509ec3a1729d6b305683fb7ff7ef8946a7ef605977ff7397300c |
Close
Hashes for telegram_exception_alerts-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad283151289ada11c1550cf1a91df000dfdcfacef4ac715fca0d857e15e34784 |
|
MD5 | 5647be8cc663b7b61015967437f0c106 |
|
BLAKE2b-256 | 0a51e72a83320adf0a2a7692f3dda0e32acd59cf51810aa889f50786c2b6364c |