From 4d5ecc7ad407411fe1039153bfaea4aad492451f Mon Sep 17 00:00:00 2001 From: yasirarism Date: Fri, 1 Sep 2023 21:02:22 +0700 Subject: [PATCH] Remove id from DB if chat is peer id invalid Signed-off-by: yasirarism --- misskaty/plugins/nightmodev2.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/misskaty/plugins/nightmodev2.py b/misskaty/plugins/nightmodev2.py index d115b1e8..a9dd47e3 100644 --- a/misskaty/plugins/nightmodev2.py +++ b/misskaty/plugins/nightmodev2.py @@ -14,6 +14,7 @@ from pyrogram.errors import ( ChannelPrivate, ChatAdminRequired, ChatNotModified, + PeerIdInvalid, ) from pyrogram.types import ChatPermissions, InlineKeyboardButton, InlineKeyboardMarkup @@ -109,7 +110,7 @@ async def un_mute_chat(chat_id: int, perm: ChatPermissions): chat_id=chat_id, bname=BOT_NAME ), ) - except (ChannelInvalid, ChannelPrivate): + except (ChannelInvalid, ChannelPrivate, PeerIdInvalid): scheduler.remove_job(f"enable_nightmode_{chat_id}") scheduler.remove_job(f"disable_nightmode_{chat_id}") await app.send_message( @@ -151,7 +152,7 @@ async def mute_chat(chat_id: int): chat_id=chat_id, bname=BOT_NAME ), ) - except (ChannelInvalid, ChannelPrivate): + except (ChannelInvalid, ChannelPrivate, PeerIdInvalid): scheduler.remove_job(f"enable_nightmode_{chat_id}") scheduler.remove_job(f"disable_nightmode_{chat_id}") await app.send_message(