MCPcopy
hub / github.com/wechatpy/wechatpy / parse_message

Method parse_message

wechatpy/component.py:526–544  ·  view source on GitHub ↗

处理 wechat server 推送消息 :params msg: 加密内容 :params msg_signature: 消息签名 :params timestamp: 时间戳 :params nonce: 随机数

(self, msg, msg_signature, timestamp, nonce)

Source from the content-addressed store, hash-verified

524 )
525
526 def parse_message(self, msg, msg_signature, timestamp, nonce):
527 """
528 处理 wechat server 推送消息
529
530 :params msg: 加密内容
531 :params msg_signature: 消息签名
532 :params timestamp: 时间戳
533 :params nonce: 随机数
534 """
535 content = self.crypto.decrypt_message(msg, msg_signature, timestamp, nonce)
536 message = xmltodict.parse(to_text(content))['xml']
537 message_type = message['InfoType'].lower()
538 message_class = COMPONENT_MESSAGE_TYPES.get(message_type, ComponentUnknownMessage)
539 msg = message_class(message)
540 if msg.type == 'component_verify_ticket':
541 self.session.set(msg.type, msg.verify_ticket)
542 elif msg.type in ('authorized', 'updateauthorized'):
543 msg.query_auth_result = self.query_auth(msg.authorization_code)
544 return msg
545
546 def cache_component_verify_ticket(self, msg, signature, timestamp, nonce):
547 """

Callers

nothing calls this directly

Calls 5

query_authMethod · 0.95
to_textFunction · 0.90
decrypt_messageMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected