From 43b31d2d63a7f3175c1f57cc3e4c1b4ff64996a7 Mon Sep 17 00:00:00 2001 From: lesteryou Date: Tue, 29 Dec 2020 18:12:03 +0800 Subject: [PATCH 1/2] Update sendmsg.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 企业微信消息推送,如果消息接受者ID为空,则不会调用企业微信官方API. --- common/utils/sendmsg.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/utils/sendmsg.py b/common/utils/sendmsg.py index 10e85ef732..93909c73f3 100755 --- a/common/utils/sendmsg.py +++ b/common/utils/sendmsg.py @@ -168,6 +168,9 @@ def send_ding2user(self, userid_list, content): def send_wx2user(self, msg, user_list): to_user = '|'.join(list(set(user_list))) + if not to_user: + logger.error(f'企业微信推送失败,无法获取到推送的用户') + return access_token = get_wx_access_token() send_url = f'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={access_token}' data = { From 797fd6e73f7874732c12289de5c2ea854fcdcc56 Mon Sep 17 00:00:00 2001 From: lesteryou Date: Wed, 30 Dec 2020 13:54:13 +0800 Subject: [PATCH 2/2] Update sendmsg.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 企业微信推送失败,无法获取到推送的用户 --- common/utils/sendmsg.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/utils/sendmsg.py b/common/utils/sendmsg.py index 93909c73f3..c0a5e09d17 100755 --- a/common/utils/sendmsg.py +++ b/common/utils/sendmsg.py @@ -167,10 +167,10 @@ def send_ding2user(self, userid_list, content): logger.error(f'钉钉推送失败\n请求连接:{send_url}\n请求参数:{data}\n请求响应:{r_json}') def send_wx2user(self, msg, user_list): - to_user = '|'.join(list(set(user_list))) - if not to_user: - logger.error(f'企业微信推送失败,无法获取到推送的用户') + if not user_list: + logger.error(f'企业微信推送失败,无法获取到推送的用户.') return + to_user = '|'.join(list(set(user_list))) access_token = get_wx_access_token() send_url = f'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={access_token}' data = {