From b3071f0f67611ef4c41cae31ba80babb242a39de Mon Sep 17 00:00:00 2001 From: benli Date: Wed, 3 Sep 2025 18:57:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?bugfix:=20=E5=85=BC=E5=AE=B9=E4=BC=81?= =?UTF-8?q?=E4=B8=9A=E5=86=85=E9=83=A8=E6=99=BA=E8=83=BD=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E5=9C=BA=E6=99=AF&fix=E8=A7=A3=E5=AF=86=E5=90=8E?= =?UTF-8?q?=E6=98=8E=E6=96=87=E7=94=A8int=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- callback_json_python3/WXBizJsonMsgCrypt.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/callback_json_python3/WXBizJsonMsgCrypt.py b/callback_json_python3/WXBizJsonMsgCrypt.py index a954283..1ac0140 100644 --- a/callback_json_python3/WXBizJsonMsgCrypt.py +++ b/callback_json_python3/WXBizJsonMsgCrypt.py @@ -190,10 +190,13 @@ def decrypt(self,text,receiveid): except Exception as e: print(e) return ierror.WXBizMsgCrypt_IllegalBuffer,None - if from_receiveid != receiveid: + + # 兼容企业内部智能机器人,企业内部智能机器人解析出来的from_receiveid是'',参考官网:https://developer.work.weixin.qq.com/document/path/101033 + if from_receiveid and from_receiveid != receiveid: print("receiveid not match", receiveid, from_receiveid) return ierror.WXBizMsgCrypt_ValidateCorpid_Error,None - return 0,json_content + # 转成int类型,企信的消息要求是int类型的,解析出来的字符串返回会报错:echostr校验失败,请您检查是否正确解密并输出明文echostr + return 0,int(json_content) def get_random_str(self): """ 随机生成16位字符串 From d53b6cf1e1c376e2ca0d62b4b2ba6dc4f7c211e7 Mon Sep 17 00:00:00 2001 From: benli Date: Fri, 5 Sep 2025 10:04:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?bugfix:=20=E5=85=BC=E5=AE=B9=E4=BC=81?= =?UTF-8?q?=E4=B8=9A=E5=86=85=E9=83=A8=E6=99=BA=E8=83=BD=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E5=9C=BA=E6=99=AF&fix=E8=A7=A3=E5=AF=86=E5=90=8E?= =?UTF-8?q?=E6=98=8E=E6=96=87=E7=94=A8int=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- callback_json_python3/WXBizJsonMsgCrypt.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/callback_json_python3/WXBizJsonMsgCrypt.py b/callback_json_python3/WXBizJsonMsgCrypt.py index 1ac0140..c9725b0 100644 --- a/callback_json_python3/WXBizJsonMsgCrypt.py +++ b/callback_json_python3/WXBizJsonMsgCrypt.py @@ -195,8 +195,7 @@ def decrypt(self,text,receiveid): if from_receiveid and from_receiveid != receiveid: print("receiveid not match", receiveid, from_receiveid) return ierror.WXBizMsgCrypt_ValidateCorpid_Error,None - # 转成int类型,企信的消息要求是int类型的,解析出来的字符串返回会报错:echostr校验失败,请您检查是否正确解密并输出明文echostr - return 0,int(json_content) + return 0,json_content def get_random_str(self): """ 随机生成16位字符串 @@ -233,7 +232,8 @@ def VerifyURL(self, sMsgSignature, sTimeStamp, sNonce, sEchoStr): return ierror.WXBizMsgCrypt_ValidateSignature_Error, None pc = Prpcrypt(self.key) ret,sReplyEchoStr = pc.decrypt(sEchoStr,self.m_sReceiveId) - return ret,sReplyEchoStr + # 转成int类型,企信的消息要求是int类型的,解析出来的字符串返回会报错:echostr校验失败,请您检查是否正确解密并输出明文echostr + return ret,int(sReplyEchoStr) def EncryptMsg(self, sReplyMsg, sNonce, timestamp = None): #将企业回复用户的消息加密打包