From 75ebbab8544da25ee73045c8101ba3516d9c997f Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Mon, 8 Apr 2024 16:50:12 +0000 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sample/notify.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/sample/notify.py b/sample/notify.py index 31a53cad..5c36d575 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -113,14 +113,11 @@ push_config = { 'WEBHOOK_METHOD': '', # 自定义通知 请求方法 'WEBHOOK_CONTENT_TYPE': '' # 自定义通知 content-type } - -push_config_keys = tuple(push_config.keys()) # 保存push_config的键 - notify_function = [] # fmt: on # 首先读取 面板变量 或者 github action 运行变量 -for k in push_config_keys: +for k in push_config: if os.getenv(k): v = os.getenv(k) push_config[k] = v @@ -903,14 +900,12 @@ def add_notify_function(): def send(title: str, content: str, ignore_default_config: bool = False, **kwargs): - if ignore_default_config and kwargs: - global push_config - push_config = {} # 清空从环境变量获取的配置 - if kwargs: - for k in kwargs: - if k in push_config_keys: - push_config[k] = kwargs.get(k) + global push_config + if ignore_default_config: + push_config = kwargs # 清空从环境变量获取的配置 + else: + push_config.update(kwargs) if not content: print(f"{title} 推送内容为空!")