Remove id from DB if chat is peer id invalid

Signed-off-by: yasirarism <github@yasir.eu.org>
This commit is contained in:
yasirarism 2023-09-01 21:02:22 +07:00 committed by GitHub
parent c717921e06
commit 4d5ecc7ad4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,6 +14,7 @@ from pyrogram.errors import (
ChannelPrivate, ChannelPrivate,
ChatAdminRequired, ChatAdminRequired,
ChatNotModified, ChatNotModified,
PeerIdInvalid,
) )
from pyrogram.types import ChatPermissions, InlineKeyboardButton, InlineKeyboardMarkup 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 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"enable_nightmode_{chat_id}")
scheduler.remove_job(f"disable_nightmode_{chat_id}") scheduler.remove_job(f"disable_nightmode_{chat_id}")
await app.send_message( await app.send_message(
@ -151,7 +152,7 @@ async def mute_chat(chat_id: int):
chat_id=chat_id, bname=BOT_NAME 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"enable_nightmode_{chat_id}")
scheduler.remove_job(f"disable_nightmode_{chat_id}") scheduler.remove_job(f"disable_nightmode_{chat_id}")
await app.send_message( await app.send_message(