diff --git a/server.py b/server.py index 96a021a..1308bde 100644 --- a/server.py +++ b/server.py @@ -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) - await sio_decorator.route2cmd_and_run() + try: + await sio_decorator.route2cmd_and_run() + except IndexError: + # 处理非文本消息 + pass if __name__ == "__main__": diff --git a/sio_model.py b/sio_model.py index 2c15cc1..db3a909 100644 --- a/sio_model.py +++ b/sio_model.py @@ -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']