From e083eaad938adb4073e6293bf00a316968145b45 Mon Sep 17 00:00:00 2001 From: Akimio521 Date: Sun, 25 Feb 2024 14:55:35 +0800 Subject: [PATCH] =?UTF-8?q?gotify=E8=87=AA=E5=AE=9A=E4=B9=89=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sample/notify.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sample/notify.py b/sample/notify.py index f2476283..197992c8 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -253,20 +253,28 @@ def go_cqhttp(title: str, content: str, **kwargs) -> None: print("go-cqhttp 推送失败!") -def gotify(title: str, content: str) -> None: +def gotify(title: str, content: str, **kwargs) -> None: """ 使用 gotify 推送消息。 """ - if not push_config.get("GOTIFY_URL") or not push_config.get("GOTIFY_TOKEN"): + if not ((kwargs.get("GOTIFY_URL") and kwargs.get("GOTIFY_TOKEN")) or (push_config.get("GOTIFY_URL") and push_config.get("GOTIFY_TOKEN"))): print("gotify 服务的 GOTIFY_URL 或 GOTIFY_TOKEN 未设置!!\n取消推送") return print("gotify 服务启动") + if kwargs.get("GOTIFY_URL") and kwargs.get("GOTIFY_TOKEN"): + GOTIFY_URL = kwargs.get("GOTIFY_URL") + GOTIFY_TOKEN = kwargs.get("GOBOTGOTIFY_TOKEN_QQ") + GOTIFY_PRIORITY = kwargs.get("GOTIFY_PRIORITY") + else: + GOTIFY_URL = push_config.get("GOTIFY_URL") + GOTIFY_TOKEN = push_config.get("GOTIFY_TOKEN") + GOTIFY_PRIORITY = kwargs.get("GOTIFY_PRIORITY") - url = f'{push_config.get("GOTIFY_URL")}/message?token={push_config.get("GOTIFY_TOKEN")}' + url = f'{GOTIFY_URL}/message?token={GOTIFY_TOKEN}' data = { "title": title, "message": content, - "priority": push_config.get("GOTIFY_PRIORITY"), + "priority": GOTIFY_PRIORITY, } response = requests.post(url, data=data).json()