This commit is contained in:
yumoqing 2026-03-02 19:43:50 +08:00
parent 30ef0e80a0
commit b46e4fa864

View File

@ -41,25 +41,21 @@ async def run_zmq_proxy(app):
task1.cancel() task1.cancel()
task.cancel() task.cancel()
async def msg_handler(msgstr):
debug('get message:{msgstr}')
msg = DictObject(**json.loads(msgstr))
ret = {
"msgtype": "text", # 要返回的消息类型
"content": "收到" # 每个类型的消息所需要的数据
}
retstr = json.dumps(ret, ensure_ascii=False)
await zmq_publish(msg.subscribe_id, retstr)
async def woa_msghande(): async def woa_msghande():
debug('woa_msghander starting ....')
config = getConfig() config = getConfig()
while True: debug('woa_msghander on({config.woa_handler_id}) starting ....')
debug(f'zmq server receiv {config.woa_handler_id} message') await zmq_subscribe(config.woa_handler_id, msg_handler)
msgstr = await zmq_subscribe(config.woa_handler_id) debug('woa_msghandler stopped.................')'
debug(f'收到sage转发微信信息:{msgstr}, {type(msgstr)}')
msgdic = json.loads(msgstr)
# 这里按照业务逻辑处理收到的msg
debug(f'received wechat msgs={msgstr}')
# 处理完成后
retmsg = {
"msgtype": "text", # 要返回的消息类型
"content": "收到" # 每个类型的消息所需要的数据
}
retstr = json.dumps(retmsg, ensure_ascii=False)
debug(f'repy msg({retstr}) to wechat')
await zmq_publish(msgdic['subscribe_id'], retstr)
def init(): def init():
rf = RegisterFunction() rf = RegisterFunction()