From be7ca57c416684a7589e984d10c64694529a2aa1 Mon Sep 17 00:00:00 2001 From: MingxuanGame Date: Mon, 18 Aug 2025 16:41:11 +0000 Subject: [PATCH] fix(chat): catch exception when handling bot message --- app/router/chat/banchobot.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/router/chat/banchobot.py b/app/router/chat/banchobot.py index ad84a51..6cddee9 100644 --- a/app/router/chat/banchobot.py +++ b/app/router/chat/banchobot.py @@ -81,11 +81,13 @@ class Bot: if handler is None: return else: - res = handler(user, args, session, channel) - if asyncio.iscoroutine(res): - res = await res - reply = res # type: ignore[assignment] - + try: + res = handler(user, args, session, channel) + if asyncio.iscoroutine(res): + res = await res + reply = res # type: ignore[assignment] + except Exception: + reply = "Unknown error occured." if reply: await self._send_reply(user, channel, reply, session)