Fix bot leave when bot not admin

This commit is contained in:
yasirarism 2023-03-07 18:02:20 +07:00 committed by GitHub
parent a4ad5c1730
commit e59cb75743
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,7 +18,7 @@ async def kirimPesan(msg, text, **kwargs):
return await kirimPesan(msg, text, **kwargs) return await kirimPesan(msg, text, **kwargs)
except (ChatWriteForbidden, ChatAdminRequired): except (ChatWriteForbidden, ChatAdminRequired):
LOGGER.info(f"Leaving from {msg.chat.title} [{msg.chat.id}] because doesn't have admin permission.") 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: except Exception as e:
LOGGER.error(str(e)) LOGGER.error(str(e))
return return
@ -34,6 +34,9 @@ async def editPesan(msg, text, **kwargs):
return await editPesan(msg, text, **kwargs) return await editPesan(msg, text, **kwargs)
except (MessageNotModified, MessageIdInvalid, MessageEmpty): except (MessageNotModified, MessageIdInvalid, MessageEmpty):
return 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: except Exception as e:
LOGGER.error(str(e)) LOGGER.error(str(e))
return return