From 229b849fbb9cba87df9757b5bd463804b67df451 Mon Sep 17 00:00:00 2001 From: QWQ2022 <94837700+QWQ2022@users.noreply.github.com> Date: Fri, 14 Feb 2025 23:50:15 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0wxpusher=E6=8E=A8?= =?UTF-8?q?=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/push.ini.example | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/config/push.ini.example b/config/push.ini.example index 07c9897..ee4d403 100644 --- a/config/push.ini.example +++ b/config/push.ini.example @@ -99,4 +99,12 @@ key=你的qmsg酱key # Discord Channel Webhook [discord] -webhook=https://discord.com/api/webhooks/your_channel_id_xxxxxx/your_webhook_token_xxxxxx \ No newline at end of file +webhook=https://discord.com/api/webhooks/your_channel_id_xxxxxx/your_webhook_token_xxxxxx + +# wxpusher +# https://wxpusher.zjiecode.com/获取所需参数 +[wxpusher] +app_token = +uids = +# uid非必填,多个用逗号分隔 +topic_ids = From 5d81f9c53c6c7bc9d6f60f34b0c442c1b2bfb735 Mon Sep 17 00:00:00 2001 From: QWQ2022 <94837700+QWQ2022@users.noreply.github.com> Date: Sat, 15 Feb 2025 00:01:36 +0800 Subject: [PATCH 2/6] Update push.py --- push.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/push.py b/push.py index 73a2cf7..bdd93d3 100644 --- a/push.py +++ b/push.py @@ -423,6 +423,36 @@ def wintoast(self, status_id, push_message): except: log.error(f"请先pip install win11toast再使用win通知") + def wxpusher(self, status_id, push_message): + """ + WxPusher + """ + from wxpusher import WxPusher + app_token = self.cfg.get('wxpusher', 'app_token', fallback=None) + uids = self.cfg.get('wxpusher', 'uids', fallback="").split(',') + topic_ids = self.cfg.get('wxpusher', 'topic_ids', fallback="").split(',') + if not app_token or not topic_ids: + log.error("WxPusher 推送失败!请检查 app_token, uids 或 topic_ids 是否正确配置") + return 1 + # 发送 WxPusher 消息 + try: + response = WxPusher.send_message( + content=get_push_title(status_id) + "\r\n" + push_message, + uids=[uid for uid in uids if uid], # 过滤空值 + topic_ids=[int(tid) for tid in topic_ids if tid.isdigit()], # 过滤并转换为整数 + token=app_token + ) + except: + log.error(f"请先pip install wxpusher再使用") + #返回结果 + if "data" in response: + status_list = [item.get("status", "未知状态") for item in response["data"]] + log.info(f"WxPusher 推送状态:{status_list}") + return 0 + else: + log.error(f"WxPusher 推送失败:{response}") + return 1 + # 其他推送方法,例如 ftqq, pushplus 等, 和 telegram 方法相似 # 在类内部直接使用 self.cfg 读取配置 From 446332653edba73642858f8e57713a4761cf6724 Mon Sep 17 00:00:00 2001 From: QWQ2022 <94837700+QWQ2022@users.noreply.github.com> Date: Sat, 15 Feb 2025 00:18:40 +0800 Subject: [PATCH 3/6] Update push.py --- push.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/push.py b/push.py index bdd93d3..079c737 100644 --- a/push.py +++ b/push.py @@ -427,24 +427,25 @@ def wxpusher(self, status_id, push_message): """ WxPusher """ - from wxpusher import WxPusher + try: + from wxpusher import WxPusher + except: + log.error("WxPusher 模块未安装,请先执行pip install wxpusher") + return 1 app_token = self.cfg.get('wxpusher', 'app_token', fallback=None) uids = self.cfg.get('wxpusher', 'uids', fallback="").split(',') topic_ids = self.cfg.get('wxpusher', 'topic_ids', fallback="").split(',') if not app_token or not topic_ids: log.error("WxPusher 推送失败!请检查 app_token, uids 或 topic_ids 是否正确配置") return 1 - # 发送 WxPusher 消息 - try: - response = WxPusher.send_message( - content=get_push_title(status_id) + "\r\n" + push_message, - uids=[uid for uid in uids if uid], # 过滤空值 - topic_ids=[int(tid) for tid in topic_ids if tid.isdigit()], # 过滤并转换为整数 - token=app_token - ) - except: - log.error(f"请先pip install wxpusher再使用") - #返回结果 + # 发送消息 + response = WxPusher.send_message( + content=get_push_title(status_id) + "\r\n" + push_message, + uids=[uid for uid in uids if uid], # 过滤空值 + topic_ids=[int(tid) for tid in topic_ids if tid.isdigit()], # 过滤并转换为整数 + token=app_token + ) + # 返回结果 if "data" in response: status_list = [item.get("status", "未知状态") for item in response["data"]] log.info(f"WxPusher 推送状态:{status_list}") From 3a9839d5ef747e68e4d87febced70d827d4dbbfc Mon Sep 17 00:00:00 2001 From: QWQ2022 <94837700+QWQ2022@users.noreply.github.com> Date: Sat, 15 Feb 2025 00:24:30 +0800 Subject: [PATCH 4/6] Update push.py --- push.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/push.py b/push.py index 079c737..723cb4c 100644 --- a/push.py +++ b/push.py @@ -436,7 +436,7 @@ def wxpusher(self, status_id, push_message): uids = self.cfg.get('wxpusher', 'uids', fallback="").split(',') topic_ids = self.cfg.get('wxpusher', 'topic_ids', fallback="").split(',') if not app_token or not topic_ids: - log.error("WxPusher 推送失败!请检查 app_token, uids 或 topic_ids 是否正确配置") + log.error("WxPusher 推送失败!请检查 app_token, topic_ids 是否正确配置") return 1 # 发送消息 response = WxPusher.send_message( From feb3c97c5118e937af9d98869071b3f4284967d3 Mon Sep 17 00:00:00 2001 From: QWQ2022 <94837700+QWQ2022@users.noreply.github.com> Date: Sat, 15 Feb 2025 00:29:23 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=88=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- push.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/push.py b/push.py index 723cb4c..01b2caa 100644 --- a/push.py +++ b/push.py @@ -438,14 +438,12 @@ def wxpusher(self, status_id, push_message): if not app_token or not topic_ids: log.error("WxPusher 推送失败!请检查 app_token, topic_ids 是否正确配置") return 1 - # 发送消息 response = WxPusher.send_message( content=get_push_title(status_id) + "\r\n" + push_message, uids=[uid for uid in uids if uid], # 过滤空值 - topic_ids=[int(tid) for tid in topic_ids if tid.isdigit()], # 过滤并转换为整数 + topic_ids=[int(tid) for tid in topic_ids if tid.isdigit()], token=app_token ) - # 返回结果 if "data" in response: status_list = [item.get("status", "未知状态") for item in response["data"]] log.info(f"WxPusher 推送状态:{status_list}") From 1e1e13c3e3c4cc0cf6584fbfe5a3acd183dcdc09 Mon Sep 17 00:00:00 2001 From: QWQ2022 <94837700+QWQ2022@users.noreply.github.com> Date: Sat, 15 Feb 2025 22:39:22 +0800 Subject: [PATCH 6/6] Update push.ini.example --- config/push.ini.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/push.ini.example b/config/push.ini.example index ee4d403..56b7170 100644 --- a/config/push.ini.example +++ b/config/push.ini.example @@ -102,9 +102,9 @@ key=你的qmsg酱key webhook=https://discord.com/api/webhooks/your_channel_id_xxxxxx/your_webhook_token_xxxxxx # wxpusher -# https://wxpusher.zjiecode.com/获取所需参数 +# https://wxpusher.zjiecode.com/ 获取所需参数 [wxpusher] app_token = uids = -# uid非必填,多个用逗号分隔 topic_ids = +# UID 与 Topic_Id 选填,多个 UID 使用逗号分隔