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()
|
task1.cancel()
|
||||||
task.cancel()
|
task.cancel()
|
||||||
|
|
||||||
|
async def msg_handler(msgstr):
|
||||||
async def woa_msghande():
|
debug('get message:{msgstr}')
|
||||||
debug('woa_msghander starting ....')
|
msg = DictObject(**json.loads(msgstr))
|
||||||
config = getConfig()
|
ret = {
|
||||||
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", # 要返回的消息类型
|
"msgtype": "text", # 要返回的消息类型
|
||||||
"content": "收到" # 每个类型的消息所需要的数据
|
"content": "收到" # 每个类型的消息所需要的数据
|
||||||
}
|
}
|
||||||
retstr = json.dumps(retmsg, ensure_ascii=False)
|
retstr = json.dumps(ret, ensure_ascii=False)
|
||||||
debug(f'repy msg({retstr}) to wechat')
|
await zmq_publish(msg.subscribe_id, retstr)
|
||||||
await zmq_publish(msgdic['subscribe_id'], retstr)
|
|
||||||
|
async def woa_msghande():
|
||||||
|
config = getConfig()
|
||||||
|
debug('woa_msghander on({config.woa_handler_id}) starting ....')
|
||||||
|
await zmq_subscribe(config.woa_handler_id, msg_handler)
|
||||||
|
debug('woa_msghandler stopped.................')'
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
rf = RegisterFunction()
|
rf = RegisterFunction()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user