From b46e4fa864d00f9c2d84f35c9f00dca70df0d268 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 2 Mar 2026 19:43:50 +0800 Subject: [PATCH] bugfix --- app/sage.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/app/sage.py b/app/sage.py index 45d2d74..5ab1faf 100644 --- a/app/sage.py +++ b/app/sage.py @@ -41,25 +41,21 @@ async def run_zmq_proxy(app): task1.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(): - debug('woa_msghander starting ....') config = getConfig() - while True: - debug(f'zmq server receiv {config.woa_handler_id} message') - msgstr = await zmq_subscribe(config.woa_handler_id) - 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) + debug('woa_msghander on({config.woa_handler_id}) starting ....') + await zmq_subscribe(config.woa_handler_id, msg_handler) + debug('woa_msghandler stopped.................')' def init(): rf = RegisterFunction()