From e7b7df374afa9f2c4c49fd111fe849be3b9b30b8 Mon Sep 17 00:00:00 2001 From: Akimio521 Date: Sun, 25 Feb 2024 15:42:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=BA=E8=83=BD=E5=BE=AE=E7=A7=98=E4=B9=A6?= =?UTF-8?q?=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 | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/sample/notify.py b/sample/notify.py index 2a6dd453..0747c7f0 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -629,31 +629,42 @@ def telegram_bot(title: str, content: str, **kwargs) -> None: print("tg 推送失败!") -def aibotk(title: str, content: str) -> None: +def aibotk(title: str, content: str, **kwargs) -> None: """ 使用 智能微秘书 推送消息。 """ - if ( - not push_config.get("AIBOTK_KEY") - or not push_config.get("AIBOTK_TYPE") - or not push_config.get("AIBOTK_NAME") + if not ( + kwargs.get("AIBOTK_KEY") + and kwargs.get("AIBOTK_TYPE") + and kwargs.get("AIBOTK_NAME") + )or ( + push_config.get("AIBOTK_KEY") + and push_config.get("AIBOTK_TYPE") + and push_config.get("AIBOTK_NAME") ): print("智能微秘书 的 AIBOTK_KEY 或者 AIBOTK_TYPE 或者 AIBOTK_NAME 未设置!!\n取消推送") return print("智能微秘书 服务启动") - - if push_config.get("AIBOTK_TYPE") == "room": + if kwargs.get("AIBOTK_KEY") and kwargs.get("AIBOTK_TYPE") and kwargs.get("AIBOTK_NAME"): + AIBOTK_KEY = kwargs.get("AIBOTK_KEY") + AIBOTK_TYPE = kwargs.get("AIBOTK_TYPE") + AIBOTK_NAME = kwargs.get("AIBOTK_NAME") + else: + AIBOTK_KEY = push_config.get("AIBOTK_KEY") + AIBOTK_TYPE = push_config.get("AIBOTK_TYPE") + AIBOTK_NAME = push_config.get("AIBOTK_NAME") + if AIBOTK_TYPE == "room": url = "https://api-bot.aibotk.com/openapi/v1/chat/room" data = { - "apiKey": push_config.get("AIBOTK_KEY"), - "roomName": push_config.get("AIBOTK_NAME"), + "apiKey": AIBOTK_KEY, + "roomName": AIBOTK_NAME, "message": {"type": 1, "content": f"【青龙快讯】\n\n{title}\n{content}"}, } else: url = "https://api-bot.aibotk.com/openapi/v1/chat/contact" data = { - "apiKey": push_config.get("AIBOTK_KEY"), - "name": push_config.get("AIBOTK_NAME"), + "apiKey": AIBOTK_KEY, + "name": AIBOTK_NAME, "message": {"type": 1, "content": f"【青龙快讯】\n\n{title}\n{content}"}, } body = json.dumps(data).encode(encoding="utf-8")