diff --git a/bot/types.py b/bot/types.py new file mode 100644 index 00000000..33cd8014 --- /dev/null +++ b/bot/types.py @@ -0,0 +1,17 @@ + +from lib_not_dr.types import Options + + +class SocketData(Options): + name = 'SocketData' + + def to_json(self) -> dict: + return self.option() + + +class AddMessage(SocketData): + name = 'icalingua socket add message event' + + roomId: int + + diff --git a/connect.py b/connect.py index 9f463611..c6311825 100644 --- a/connect.py +++ b/connect.py @@ -188,7 +188,10 @@ async def add_message(data: Dict[str, Any]): elif data.get('message').get('content').startswith('=='): evals: str = data.get('message').get('content')[2:] - result = await safe_eval(evals) + try: + result = await asyncio.wait_for(safe_eval(evals), 5) + except asyncio.TimeoutError: + result = f'{evals}\n超时' reply = ReplyMessage(id=data['message']['_id']) message = Message(content=result, reply_to=reply, diff --git a/main.py b/main.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/main.py @@ -0,0 +1 @@ +