From a5fbac441263dcdb7f93b41b5a5acebbbef0accf Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sat, 26 Nov 2022 12:55:44 +0800 Subject: [PATCH] =?UTF-8?q?clear=5Fblocked=20=E4=BF=AE=E5=A4=8D=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clear_blocked/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clear_blocked/main.py b/clear_blocked/main.py index 673a9ce..2cf6fca 100644 --- a/clear_blocked/main.py +++ b/clear_blocked/main.py @@ -4,6 +4,7 @@ from asyncio import sleep from pyrogram.errors import FloodWait from pyrogram.raw.functions.contacts import GetBlocked +from pyrogram.raw.types.contacts import BlockedSlice from pagermaid.listener import listener from pagermaid.enums import Client, Message @@ -27,12 +28,14 @@ async def clear_blocked_func(client: Client, message: Message): with contextlib.suppress(Exception): await message.edit(f"🧹 Clearing blocked users...\n\nWill run after {e.value} seconds.") await sleep(e.value + 1) + with contextlib.suppress(Exception): + await message.edit("🧹 Clearing blocked users...") await client.unblock_user(user.id) success += 1 except Exception: failed += 1 offset += 100 - if offset > blocked.count: + if (isinstance(blocked, BlockedSlice) and offset > blocked.count) or not isinstance(blocked, BlockedSlice): break return success, failed, skipped