From 1b5617baa0870ce7d395b8b00d337235b32e917e Mon Sep 17 00:00:00 2001 From: Akimio521 Date: Sun, 25 Feb 2024 15:17:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1=E6=9C=BA?= =?UTF-8?q?=E5=99=A8=E4=BA=BA=E8=87=AA=E5=AE=9A=E4=B9=89=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sample/notify.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sample/notify.py b/sample/notify.py index 39198945..98bedb73 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -542,20 +542,23 @@ class WeCom: return respone["errmsg"] -def wecom_bot(title: str, content: str) -> None: +def wecom_bot(title: str, content: str, **kwargs) -> None: """ 通过 企业微信机器人 推送消息。 """ - if not push_config.get("QYWX_KEY"): + if not (kwargs.get("QYWX_KEY") or push_config.get("QYWX_KEY")): print("企业微信机器人 服务的 QYWX_KEY 未设置!!\n取消推送") return print("企业微信机器人服务启动") + QYWX_KEY = kwargs.get("QYWX_KEY", push_config.get("QYWX_KEY")) origin = "https://qyapi.weixin.qq.com" if push_config.get("QYWX_ORIGIN"): origin = push_config.get("QYWX_ORIGIN") + if kwargs.get("QYWX_ORIGIN"): + origin = kwargs.get("QYWX_ORIGIN") - url = f"{origin}/cgi-bin/webhook/send?key={push_config.get('QYWX_KEY')}" + url = f"{origin}/cgi-bin/webhook/send?key={QYWX_KEY}" headers = {"Content-Type": "application/json;charset=utf-8"} data = {"msgtype": "text", "text": {"content": f"{title}\n\n{content}"}} response = requests.post(