clear_blocked 修复错误

This commit is contained in:
xtaodada 2022-11-26 12:55:44 +08:00
parent c6b6ec5c29
commit a5fbac4412
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -4,6 +4,7 @@ from asyncio import sleep
from pyrogram.errors import FloodWait from pyrogram.errors import FloodWait
from pyrogram.raw.functions.contacts import GetBlocked from pyrogram.raw.functions.contacts import GetBlocked
from pyrogram.raw.types.contacts import BlockedSlice
from pagermaid.listener import listener from pagermaid.listener import listener
from pagermaid.enums import Client, Message from pagermaid.enums import Client, Message
@ -27,12 +28,14 @@ async def clear_blocked_func(client: Client, message: Message):
with contextlib.suppress(Exception): with contextlib.suppress(Exception):
await message.edit(f"🧹 Clearing blocked users...\n\nWill run after {e.value} seconds.") await message.edit(f"🧹 Clearing blocked users...\n\nWill run after {e.value} seconds.")
await sleep(e.value + 1) await sleep(e.value + 1)
with contextlib.suppress(Exception):
await message.edit("🧹 Clearing blocked users...")
await client.unblock_user(user.id) await client.unblock_user(user.id)
success += 1 success += 1
except Exception: except Exception:
failed += 1 failed += 1
offset += 100 offset += 100
if offset > blocked.count: if (isinstance(blocked, BlockedSlice) and offset > blocked.count) or not isinstance(blocked, BlockedSlice):
break break
return success, failed, skipped return success, failed, skipped