From bcd7bcd0c16e27519d5eb8c7bfa6eece772e5969 Mon Sep 17 00:00:00 2001 From: Akimio521 Date: Sun, 25 Feb 2024 15:00:28 +0800 Subject: [PATCH] =?UTF-8?q?serverJ=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 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sample/notify.py b/sample/notify.py index 056b0f06..dad51422 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -304,20 +304,21 @@ def iGot(title: str, content: str, **kwargs) -> None: print(f'iGot 推送失败!{response["errMsg"]}') -def serverJ(title: str, content: str) -> None: +def serverJ(title: str, content: str, **kwargs) -> None: """ 通过 serverJ 推送消息。 """ - if not push_config.get("PUSH_KEY"): + if not (kwargs.get("PUSH_KEY") or push_config.get("PUSH_KEY")): print("serverJ 服务的 PUSH_KEY 未设置!!\n取消推送") return print("serverJ 服务启动") + PUSH_KEY = kwargs.get("PUSH_KEY", push_config.get("PUSH_KEY")) data = {"text": title, "desp": content.replace("\n", "\n\n")} - if push_config.get("PUSH_KEY").find("SCT") != -1: - url = f'https://sctapi.ftqq.com/{push_config.get("PUSH_KEY")}.send' + if PUSH_KEY.find("SCT") != -1: + url = f'https://sctapi.ftqq.com/{PUSH_KEY}.send' else: - url = f'https://sc.ftqq.com/{push_config.get("PUSH_KEY")}.send' + url = f'https://sc.ftqq.com/{PUSH_KEY}.send' response = requests.post(url, data=data).json() if response.get("errno") == 0 or response.get("code") == 0: