From 74f36b3978c641a5e9be8610413e9038e00ec2f9 Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Mon, 8 Apr 2024 16:45:18 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20body=20=E6=8B=86?= =?UTF-8?q?=E5=88=86=E7=AC=94=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sample/notify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sample/notify.py b/sample/notify.py index 1bcd35b2..31a53cad 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -771,10 +771,10 @@ def parse_body(body, content_type): if not body or content_type == "text/plain": return body - parsed = parse_string(input_string) + parsed = parse_string(body) if content_type == "application/x-www-form-urlencoded": - data = urlencode(parsed, doseq=True) + data = urllib.parse.urlencode(parsed, doseq=True) return data if content_type == "application/json": From 75ebbab8544da25ee73045c8101ba3516d9c997f Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Mon, 8 Apr 2024 16:50:12 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=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} 推送内容为空!") From f0f27ef72a0bb93823cd3956de7255c0cd8124a1 Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Mon, 8 Apr 2024 17:10:12 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E6=AF=8F=E6=AC=A1=E8=B0=83=E7=94=A8=20send?= =?UTF-8?q?()=20=E6=97=B6=E9=87=8D=E6=96=B0=E6=A3=80=E6=9F=A5=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=B8=A0=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sample/notify.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sample/notify.py b/sample/notify.py index 5c36d575..2a595308 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -113,7 +113,6 @@ push_config = { 'WEBHOOK_METHOD': '', # 自定义通知 请求方法 'WEBHOOK_CONTENT_TYPE': '' # 自定义通知 content-type } -notify_function = [] # fmt: on # 首先读取 面板变量 或者 github action 运行变量 @@ -840,6 +839,7 @@ def one() -> str: def add_notify_function(): + notify_function = [] if push_config.get("BARK_PUSH"): notify_function.append(bark) if push_config.get("CONSOLE"): @@ -897,6 +897,7 @@ def add_notify_function(): if not notify_function: print(f"无推送渠道,请检查通知变量是否正确") + return notify_function def send(title: str, content: str, ignore_default_config: bool = False, **kwargs): @@ -921,7 +922,7 @@ def send(title: str, content: str, ignore_default_config: bool = False, **kwargs hitokoto = push_config.get("HITOKOTO") content += "\n\n" + one() if hitokoto else "" - add_notify_function() + notify_function = add_notify_function() ts = [ threading.Thread(target=mode, args=(title, content), name=mode.__name__) for mode in notify_function