This commit is contained in:
yumoqing 2026-03-02 09:27:55 +08:00
parent c095389309
commit 1b548057ed
2 changed files with 20 additions and 1 deletions

View File

@ -36,9 +36,28 @@ __version__ = '0.0.1'
async def run_zmq_proxy(app):
task = asyncio.create_task(run_proxy())
app['zmq_proxy_task'] = task
task1 = asyncio.create_task(woa_msghande)
yield
task1.cancel()
task.cancel()
async def woa_msghande():
config = getConfig()
while True:
msgstr = await zmq_subscribe(config.woa_handler_id)
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():
rf = RegisterFunction()
set_globalvariable()

View File

@ -1,7 +1,7 @@
{
"password_key":"!@#$%^&*(*&^%$QWERTYUIqwertyui234567",
"logopath": "$[workdir]$/conf/logo.png",
"subscrible_id":"woa_subscribe_type",
"woa_handler_id":"woa_subscribe_type",
"logger":{
"name":"sage",
"levelname":"clientinfo",