Document rule system
This commit is contained in:
@@ -9,6 +9,17 @@ log = logs.get_logger(__name__)
|
||||
|
||||
# Actual function to send a message to a topic
|
||||
def ntfy_sendmsg(**kwargs):
|
||||
"""
|
||||
Send a message to a topic using NTFY.
|
||||
kwargs:
|
||||
msg: Message to send, must be specified
|
||||
notification_settings: Notification settings, must be specified
|
||||
url: URL to NTFY server, can be None to use default
|
||||
topic: Topic to send message to, must be specified
|
||||
priority: Priority of message, optional
|
||||
title: Title of message, optional
|
||||
tags: Tags to add to message, optional
|
||||
"""
|
||||
msg = kwargs.get("msg", None)
|
||||
notification_settings = kwargs.get("notification_settings")
|
||||
|
||||
@@ -36,6 +47,12 @@ def ntfy_sendmsg(**kwargs):
|
||||
|
||||
|
||||
def webhook_sendmsg(**kwargs):
|
||||
"""
|
||||
Send a message to a webhook.
|
||||
kwargs:
|
||||
msg: Message to send, must be specified
|
||||
notification_settings: Notification settings, must be specified
|
||||
url: URL to webhook, must be specified"""
|
||||
msg = kwargs.get("msg", None)
|
||||
notification_settings = kwargs.get("notification_settings")
|
||||
url = notification_settings.get("url")
|
||||
@@ -50,6 +67,26 @@ def webhook_sendmsg(**kwargs):
|
||||
|
||||
# Sendmsg helper to send a message to a user's notification settings
|
||||
def sendmsg(**kwargs):
|
||||
"""
|
||||
Send a message to a user's notification settings.
|
||||
Fetches the user's default notification settings if not specified.
|
||||
kwargs:
|
||||
user: User to send message to, must be specified
|
||||
notification_settings: Notification settings, optional
|
||||
service: Notification service to use
|
||||
|
||||
kwargs for both services:
|
||||
msg: Message to send, must be specified
|
||||
notification_settings: Notification settings, must be specified
|
||||
url: URL to NTFY server, can be None to use default
|
||||
|
||||
extra kwargs for ntfy:
|
||||
title: Title of message, optional
|
||||
tags: Tags to add to message, optional
|
||||
notification_settings: Notification settings, must be specified
|
||||
topic: Topic to send message to, must be specified
|
||||
priority: Priority of message, optional
|
||||
"""
|
||||
user = kwargs.get("user", None)
|
||||
notification_settings = kwargs.get(
|
||||
"notification_settings", user.get_notification_settings().__dict__
|
||||
|
||||
Reference in New Issue
Block a user