bugfix
This commit is contained in:
parent
30ef0e80a0
commit
b46e4fa864
28
app/sage.py
28
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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user