fix(chat): catch exception when handling bot message
This commit is contained in:
@@ -81,11 +81,13 @@ class Bot:
|
|||||||
if handler is None:
|
if handler is None:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
res = handler(user, args, session, channel)
|
try:
|
||||||
if asyncio.iscoroutine(res):
|
res = handler(user, args, session, channel)
|
||||||
res = await res
|
if asyncio.iscoroutine(res):
|
||||||
reply = res # type: ignore[assignment]
|
res = await res
|
||||||
|
reply = res # type: ignore[assignment]
|
||||||
|
except Exception:
|
||||||
|
reply = "Unknown error occured."
|
||||||
if reply:
|
if reply:
|
||||||
await self._send_reply(user, channel, reply, session)
|
await self._send_reply(user, channel, reply, session)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user