From 3c9c6de34e736e595007a69e9436498bcbeeb61e Mon Sep 17 00:00:00 2001 From: Akimio521 Date: Sun, 25 Feb 2024 15:03:35 +0800 Subject: [PATCH] =?UTF-8?q?PushDeer=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 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sample/notify.py b/sample/notify.py index dad51422..bb0603c2 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -327,23 +327,27 @@ def serverJ(title: str, content: str, **kwargs) -> None: print(f'serverJ 推送失败!错误码:{response["message"]}') -def pushdeer(title: str, content: str) -> None: +def pushdeer(title: str, content: str, **kwargs) -> None: """ 通过PushDeer 推送消息 """ - if not push_config.get("DEER_KEY"): + if not (kwargs.get("DEER_KEY") or push_config.get("DEER_KEY")): print("PushDeer 服务的 DEER_KEY 未设置!!\n取消推送") return print("PushDeer 服务启动") + DEER_KEY = kwargs.get("DEER_KEY", push_config.get("DEER_KEY")) + data = { "text": title, "desp": content, "type": "markdown", - "pushkey": push_config.get("DEER_KEY"), + "pushkey": DEER_KEY, } url = "https://api2.pushdeer.com/message/push" if push_config.get("DEER_URL"): url = push_config.get("DEER_URL") + if kwargs.get("DEER_URL"): + url = kwargs.get("DEER_URL") response = requests.post(url, data=data).json()