format .
This commit is contained in:
@@ -4,6 +4,7 @@ from typing import Dict, Tuple, Union
|
||||
import xmltodict
|
||||
from fastapi import HTTPException, Request
|
||||
from uvicorn.server import logger
|
||||
|
||||
from .wx_com import wxcpt
|
||||
|
||||
|
||||
@@ -23,7 +24,10 @@ async def get_request_params(request: Request) -> Tuple[bytes, str, str, str]:
|
||||
|
||||
return body, msg_signature, timestamp, nonce
|
||||
|
||||
def decrypt_message(body: bytes, msg_signature: str, timestamp: str, nonce: str) -> dict:
|
||||
|
||||
def decrypt_message(
|
||||
body: bytes, msg_signature: str, timestamp: str, nonce: str
|
||||
) -> dict:
|
||||
"""解密消息"""
|
||||
ret, sMsg = wxcpt.DecryptMsg(body, msg_signature, timestamp, nonce)
|
||||
if ret != 0:
|
||||
@@ -35,6 +39,7 @@ def decrypt_message(body: bytes, msg_signature: str, timestamp: str, nonce: str)
|
||||
|
||||
return xml_dict
|
||||
|
||||
|
||||
def extract_message_content(
|
||||
xml_dict: Dict,
|
||||
) -> Tuple[str, str, str, str, Union[Dict[str, Union[str, None]], str, None], str, str]:
|
||||
@@ -82,7 +87,6 @@ def extract_message_content(
|
||||
message_data = xml_content.get("Content")
|
||||
logger.info(f"收到未知类型消息: {message_data}")
|
||||
|
||||
|
||||
return {
|
||||
"ToUserName": to_user_name,
|
||||
"FromUserName": from_user_name,
|
||||
@@ -91,4 +95,4 @@ def extract_message_content(
|
||||
"MsgId": msg_id,
|
||||
"AgentID": agent_id,
|
||||
**message_data,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user