def verify_reply(core, tns, reply, msgDict, isActualEncrypt): reply = reply_msg_format(reply) if reply: if reply.get('MsgType') in OUTCOME_MSG: reply['ToUserName'] = msgDict['FromUserName'] reply['FromUserName'] = msgDict['ToUserName'] if 'FileDir' in reply and reply['MsgType'] != TEXT: r = core.upload(reply['MsgType'], reply['FileDir']) if not r: logger.warning(r) return None, None else: reply['MediaId'] = r['media_id'] if core.config.encryptMode == SAFE and isActualEncrypt: return encrypt_msg(*(tns + [core.config, reply])), reply else: return construct_msg(reply), reply else: logger.warning('Reply is invalid: unknown MsgType') else: logger.warning('Reply is invalid: %s' % reply.get('errmsg')) return None, None
def verify_reply(core, tns, reply, msgDict, isActualEncrypt): reply = reply_msg_format(reply) if reply: if reply.get('MsgType') in OUTCOME_MSG: reply['ToUserName'] = msgDict['FromUserName'] reply['FromUserName'] = msgDict['ToUserName'] if 'FileDir' in reply and reply['MsgType'] != TEXT: r = core.upload(reply['MsgType'], reply['FileDir']) if not r: logger.warning(r); return None, None else: reply['MediaId'] = r['media_id'] if core.config.encryptMode == SAFE and isActualEncrypt: return encrypt_msg(*(tns + [core.config, reply])), reply else: return construct_msg(reply), reply else: logger.warning('Reply is invalid: unknown MsgType') else: logger.warning('Reply is invalid: %s' % reply.get('errmsg')) return None, None