From e59cb75743c3e1998de208fd0ea8888f555610b9 Mon Sep 17 00:00:00 2001 From: yasirarism <55983182+yasirarism@users.noreply.github.com> Date: Tue, 7 Mar 2023 18:02:20 +0700 Subject: [PATCH] Fix bot leave when bot not admin --- misskaty/core/message_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/misskaty/core/message_utils.py b/misskaty/core/message_utils.py index 2bbbe1fa..a3819f26 100644 --- a/misskaty/core/message_utils.py +++ b/misskaty/core/message_utils.py @@ -18,7 +18,7 @@ async def kirimPesan(msg, text, **kwargs): return await kirimPesan(msg, text, **kwargs) except (ChatWriteForbidden, ChatAdminRequired): LOGGER.info(f"Leaving from {msg.chat.title} [{msg.chat.id}] because doesn't have admin permission.") - return await msg.leave() + return await msg.chat.leave() except Exception as e: LOGGER.error(str(e)) return @@ -34,6 +34,9 @@ async def editPesan(msg, text, **kwargs): return await editPesan(msg, text, **kwargs) except (MessageNotModified, MessageIdInvalid, MessageEmpty): return + except (ChatWriteForbidden, ChatAdminRequired): + LOGGER.info(f"Leaving from {msg.chat.title} [{msg.chat.id}] because doesn't have admin permission.") + return await msg.chat.leave() except Exception as e: LOGGER.error(str(e)) return