This commit is contained in:
yumoqing 2026-03-02 08:53:20 +08:00
parent 526ea8ee7d
commit a69234636a

View File

@ -89,4 +89,25 @@
返回消息有以下属性
## 消息处理的例子
```
import asyncio
from appPublic.jsonConfig import getConfig
from appPublic.zmqapi import zmq_publish, zmq_subscribe
import json
async def woa_msghandle():
config = getConfig()
config.woa_handler_id
while True:
msgstr = await zmq_subscribe(config.woa_handler_id)
msgdic = json.loads(msgstr)
# 这里按照业务逻辑处理收到的msg
# 处理完成后
retmsg = {
"msgtype": "text", # 要返回的消息类型
“content": "收到" # 每个类型的消息所需要的数据
}
retstr = json.dumps(retmsg, ensure_ascii=False)
await zmq_publish(msgdic['subscribe_id'], retstr)