From 05e002b1f149e4fe795dc5ee2f9b0990f07d6a42 Mon Sep 17 00:00:00 2001 From: Akimio521 Date: Sun, 25 Feb 2024 15:09:34 +0800 Subject: [PATCH] =?UTF-8?q?push+=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, 6 insertions(+), 4 deletions(-) diff --git a/sample/notify.py b/sample/notify.py index 4724b362..85ee0d14 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -382,21 +382,23 @@ def chat(title: str, content: str, **kwargs) -> None: print("Chat 推送失败!错误信息:", response) -def pushplus_bot(title: str, content: str) -> None: +def pushplus_bot(title: str, content: str, **kwargs) -> None: """ 通过 push+ 推送消息。 """ - if not push_config.get("PUSH_PLUS_TOKEN"): + if not (kwargs.get("PUSH_PLUS_TOKEN") or push_config.get("PUSH_PLUS_TOKEN")): print("PUSHPLUS 服务的 PUSH_PLUS_TOKEN 未设置!!\n取消推送") return print("PUSHPLUS 服务启动") + PUSH_PLUS_TOKEN = kwargs.get("PUSH_PLUS_TOKEN", push_config.get("PUSH_PLUS_TOKEN")) + PUSH_PLUS_USER = kwargs.get("PUSH_PLUS_USER", push_config.get("PUSH_PLUS_USER")) url = "http://www.pushplus.plus/send" data = { - "token": push_config.get("PUSH_PLUS_TOKEN"), + "token": PUSH_PLUS_TOKEN, "title": title, "content": content, - "topic": push_config.get("PUSH_PLUS_USER"), + "topic": PUSH_PLUS_USER, } body = json.dumps(data).encode(encoding="utf-8") headers = {"Content-Type": "application/json"}