From 82f65e8e275e628fb3f3d427760b7561aae289e1 Mon Sep 17 00:00:00 2001 From: Akimio521 Date: Sun, 25 Feb 2024 14:51:57 +0800 Subject: [PATCH] =?UTF-8?q?go=5Fcqhttp=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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sample/notify.py b/sample/notify.py index dd608b08..f2476283 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -227,16 +227,24 @@ def feishu_bot(title: str, content: str, **kwargs) -> None: print("飞书 推送失败!错误信息如下:\n", response) -def go_cqhttp(title: str, content: str) -> None: +def go_cqhttp(title: str, content: str, **kwargs) -> None: """ 使用 go_cqhttp 推送消息。 """ - if not push_config.get("GOBOT_URL") or not push_config.get("GOBOT_QQ"): + if not ((kwargs.get("GOBOT_URL") and kwargs.get("GOBOT_QQ")) or (push_config.get("GOBOT_URL") and push_config.get("GOBOT_QQ"))): print("go-cqhttp 服务的 GOBOT_URL 或 GOBOT_QQ 未设置!!\n取消推送") return print("go-cqhttp 服务启动") + if kwargs.get("GOBOT_URL") and kwargs.get("GOBOT_QQ"): + GOBOT_URL = kwargs.get("GOBOT_URL") + GOBOT_QQ = kwargs.get("GOBOT_QQ") + GOBOT_TOKEN = kwargs.get("GOBOT_TOKEN") + else: + GOBOT_URL = push_config.get("GOBOT_URL") + GOBOT_QQ = push_config.get("GOBOT_QQ") + GOBOT_TOKEN = push_config.get("GOBOT_TOKEN") - url = f'{push_config.get("GOBOT_URL")}?access_token={push_config.get("GOBOT_TOKEN")}&{push_config.get("GOBOT_QQ")}&message=标题:{title}\n内容:{content}' + url = f'{GOBOT_URL}?access_token={GOBOT_TOKEN}&{GOBOT_QQ}&message=标题:{title}\n内容:{content}' response = requests.get(url).json() if response["status"] == "ok":