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

Uploaded Source

File details

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

File metadata

  • Download URL: ml-simple-notify-0.0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 bae95b4ec8cce25f2e5465f956fa11aabd4e1fa9d9e91b6f98fce7643dc9acf2
MD5 22668e76174587c8e809f1d15764e289
BLAKE2b-256 63367e1e7a9d26a28b275f2e9352c5ebd8a3a69c2d956bcd12915b1b8dba3f35

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