All abilities (mail/telegram) to send alert msgs (threading)
Project description
alerts_msg (v0.2.1)
DESCRIPTION_SHORT
All abilities (mail/telegram) to send alert msgs (threading)
DESCRIPTION_LONG
designed for ...
Features
- send alert msgs:
- emails
- telegram
- threading
License
See the LICENSE file for license rights and limitations (MIT).
Release history
See the HISTORY.md file for release history.
Installation
pip install alerts-msg
Import
from alerts_msg import *
USAGE EXAMPLES
See tests and sourcecode for other examples.
1. example1.py
# =========================================================================================
### 0. BEST PRACTICE
from alerts_msg import *
class AlertADX(AlertSelect.TELEGRAM_DEF):
pass
AlertADX("hello")
AlertADX("World")
AlertADX.threads_wait_all()
# =========================================================================================
# =========================================================================================
# =========================================================================================
### AlertSmtp
#### 1. add new server if not exists
from alerts_msg import *
class SmtpServersMOD(SmtpServers):
EXAMPLE_RU: SmtpAddress = SmtpAddress("smtp.EXAMPLE.ru", 123)
class AlertSmtpMOD(AlertSmtp):
SERVER_SMTP: SmtpAddress = SmtpServersMOD.EXAMPLE_RU # or direct =SmtpAddress("smtp.EXAMPLE.ru", 123)
# =========================================================================================
#### 2. change authorisation data (see `private_values` for details)
from alerts_msg import *
class AlertSmtpMOD(AlertSmtp):
AUTH: PrivateAuto = PrivateAuto(_section="AUTH_EMAIL_MOD")
# =========================================================================================
#### 3. change other settings (see source for other not mentioned)
from alerts_msg import *
class AlertSmtpMOD(AlertSmtp):
RECONNECT_PAUSE: int = 60
RECONNECT_LIMIT: int = 10
TIMEOUT_RATELIMIT: int = 600
RECIPIENT_SPECIAL: str = "my_address_2@mail.ru"
# =========================================================================================
#### 4. send
# if no mods
from alerts_msg import *
AlertSmtp(_subj_name="Hello", body="World!")
# with mods
from alerts_msg import *
class AlertSmtpMOD(AlertSmtp):
pass # changed
AlertSmtpMOD(_subj_name="Hello", body="World!")
# =========================================================================================
#### 5. using in class with saving alert object
from alerts_msg import *
class AlertSmtpMOD(AlertSmtp):
pass # changed
class MyMonitor:
ALERT = AlertSmtpMOD
monitor = MyMonitor()
monitor.ALERT("Hello")
# =========================================================================================
# =========================================================================================
### AlertTelegram
# All idea is similar to AlertSmtp.
# add auth data
# add pv.json or do smth else (for details see private_values.PrivateJsonTgBotAddress)
# json
{
"TG_ID": {"MyTgID": 1234567890},
"TGBOT_DEF": {
"LINK_ID": "@my_bot_20230916",
"NAME": "my_bot",
"TOKEN": "9876543210xxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
# =========================================================================================
from alerts_msg import *
class MyMonitor:
ALERT = AlertTelegram
monitor = MyMonitor()
monitor.ALERT("Hello")
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
alerts_msg-0.2.1.tar.gz
(7.2 kB
view details)
Built Distribution
File details
Details for the file alerts_msg-0.2.1.tar.gz
.
File metadata
- Download URL: alerts_msg-0.2.1.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2049cb3bf3c17736c0b9aa166298ba9b20796e8051c3ae3187c0904852c38070 |
|
MD5 | 74d30939aa62b5e7cefff7ef034f0df1 |
|
BLAKE2b-256 | 3ed6b6bffcee8d561a96eb06f7b5e4777929f2153d8fc61f8747fb37cab5093e |
File details
Details for the file alerts_msg-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: alerts_msg-0.2.1-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0436321690bc468870e4c82f4f3a61ce5ad59cc00ea3acb33bfd9f27d0b1cdb |
|
MD5 | 8b84f66716a20b0853d7f74a291a659b |
|
BLAKE2b-256 | ab81c06a0392fbc67720ee2c4d4e5aceb2a3330098eb6d94b094c4e12217f3c6 |