解决非文本消息报错
This commit is contained in:
parent
6df0e82420
commit
02b9ffec7b
@ -240,7 +240,11 @@ def start_sio_listener():
|
|||||||
@app.ctx.sio.on('addMessage')
|
@app.ctx.sio.on('addMessage')
|
||||||
async def add_message(data: Dict[str, Any]):
|
async def add_message(data: Dict[str, Any]):
|
||||||
sio_decorator = cmds.cmds(app, data)
|
sio_decorator = cmds.cmds(app, data)
|
||||||
|
try:
|
||||||
await sio_decorator.route2cmd_and_run()
|
await sio_decorator.route2cmd_and_run()
|
||||||
|
except IndexError:
|
||||||
|
# 处理非文本消息
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -110,8 +110,6 @@ class SioDecorator:
|
|||||||
self.cmds[f'/{cmd}'] = func
|
self.cmds[f'/{cmd}'] = func
|
||||||
|
|
||||||
async def route2cmd_and_run(self):
|
async def route2cmd_and_run(self):
|
||||||
if self._cmd == '':
|
|
||||||
return None
|
|
||||||
func = self.cmds.get(self._cmd[0])
|
func = self.cmds.get(self._cmd[0])
|
||||||
if func:
|
if func:
|
||||||
sender_id = self.data['message']['senderId']
|
sender_id = self.data['message']['senderId']
|
||||||
|
Loading…
Reference in New Issue
Block a user