Skip to main content

一个简单可扩展的消息通知库

Project description

一个简单可扩展的消息通知库

安装

pip install ml-simple-notify

使用

from notify.notification import Notify
# import settings

notify = Notify.from_settings()
notify.send_message(content="content", title="title")

settings模板文件可参考default_settings.py

# 消息通知渠道的配置项
CHANNELS = {
    'DING': {
        'ACCESS_TOKEN': "ee45bea8e9b5029a9c71*********6f0d98cff232a6b35e52df2",
        'AT_ALL': True
    }
}
# 消息通知启用项目
TRIGGERS = {
    # 开启库中钉钉消息通知,对应的CHANNELS中需要配置钉钉的token
    'notify.channels.ding.Ding': 100,
}

自己开发消息通知

from notify.notification import Notification


class Custom(Notification):
    """自定义消息"""
    def __init__(self, settings):
        self.settings = settings

    def send_message(self, content, title=None):
        print(f"来自自定义的消息{content}")

    @classmethod
    def from_settings(cls, settings):
        return cls(settings)

随后在settings.py文件中的TRIGGERS开启此通知

TRIGGERS = {
    'channels.custom.Custom': 100,
}

触发器的值为字典类型,键名为包路径,键值为优先级,值越小优先级越高

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

ml-simple-notify-0.0.5.tar.gz (6.0 kB view details)

Uploaded Source

File details

Details for the file ml-simple-notify-0.0.5.tar.gz.

File metadata

  • Download URL: ml-simple-notify-0.0.5.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for ml-simple-notify-0.0.5.tar.gz
Algorithm Hash digest
SHA256 5b17697b72edf32804ef308a310cbcad83ca5eb6c4ebcfbe025ab7563b1b8b4d
MD5 ee6ca931b368435f8c5ffbb5d0734079
BLAKE2b-256 34d0c4bf72548e52f439d523aa687ca2e02b835b5cf11fc53737b2eaca1fcd6d

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