bugfix
This commit is contained in:
parent
526ea8ee7d
commit
a69234636a
21
README.md
21
README.md
@ -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)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user