Skip to main content

All abilities (mail/telegram) to send alert msgs (threading)

Project description

alerts_msg

Features

  1. send alert msgs
    • emails
    • telegram
  2. 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 *

GUIDE

See tests and source for other examples.

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)
{
    "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


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

Uploaded Source

Built Distribution

alerts_msg-0.2.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file alerts_msg-0.2.0.tar.gz.

File metadata

  • Download URL: alerts_msg-0.2.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for alerts_msg-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c60fb11dda27859993fd52fe2d624455532d88445335cd0627b9208e35325adb
MD5 b2d2cae49d411b8a63c720a2aa9cb276
BLAKE2b-256 c52ae3375843bc2a453642c7f83466655b35dc7064f39ad71a670c22b724c025

See more details on using hashes here.

File details

Details for the file alerts_msg-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: alerts_msg-0.2.0-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.11.4

File hashes

Hashes for alerts_msg-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b9048de4259bcaa80d90fa15deecf83d6b5a0d6e951cb0f9ca153eae21d1a69
MD5 fa92d2480ddf2e6a15ae5a00f5473ed2
BLAKE2b-256 898e22e04b40507ec9849fc42b11f3cbe0fa31199bdc6411560d7398cbac7ea1

See more details on using hashes here.

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