解决非文本消息报错

This commit is contained in:
San Liy 2023-12-21 00:59:47 +08:00
parent 6df0e82420
commit 02b9ffec7b
2 changed files with 5 additions and 3 deletions

View File

@ -240,7 +240,11 @@ def start_sio_listener():
@app.ctx.sio.on('addMessage')
async def add_message(data: Dict[str, Any]):
sio_decorator = cmds.cmds(app, data)
try:
await sio_decorator.route2cmd_and_run()
except IndexError:
# 处理非文本消息
pass
if __name__ == "__main__":

View File

@ -110,8 +110,6 @@ class SioDecorator:
self.cmds[f'/{cmd}'] = func
async def route2cmd_and_run(self):
if self._cmd == '':
return None
func = self.cmds.get(self._cmd[0])
if func:
sender_id = self.data['message']['senderId']