From 77c51cc76752715013f3c8564e766c3a82fd3923 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Fri, 22 Jul 2022 13:20:13 +0800 Subject: [PATCH] =?UTF-8?q?getdel=20=E8=8E=B7=E5=8F=96=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E7=BE=A4=E7=BB=84=E7=9A=84=E6=AD=BB=E5=8F=B7=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- getdel/main.py | 41 +++++++++++++++++++++++++++++++++++++++++ list.json | 10 ++++++++++ 2 files changed, 51 insertions(+) create mode 100644 getdel/main.py diff --git a/getdel/main.py b/getdel/main.py new file mode 100644 index 0000000..bd8f690 --- /dev/null +++ b/getdel/main.py @@ -0,0 +1,41 @@ +from datetime import datetime, timedelta + +from pyrogram.errors import FloodWait, ChatAdminRequired, UserAdminInvalid + +from pagermaid.listener import listener +from pagermaid.single_utils import Message + + +@listener(command="getdel", + groups_only=True, + need_admin=True, + parameters="清理", + description="获取当前群组的死号数。") +async def get_del(message: Message): + """ PagerMaid get_del. """ + need_kick = message.arguments + member_count = 0 + try: + await message.edit('遍历成员中。。。') + if need_kick: + user = await message.bot.get_chat_member(message.chat.id, (await message.bot.get_me()).id) + need_kick = bool(user.privileges and user.privileges.can_restrict_members) + async for member in message.bot.get_chat_members(message.chat.id): + if member.user.is_deleted: + member_count += 1 + if need_kick: + try: + await message.bot.ban_chat_member( + message.chat.id, + member.user.id, + datetime.now() + timedelta(minutes=5)) + except FloodWait: + return await message.edit('处理失败,您已受到 TG 服务器限制。') + except UserAdminInvalid: + pass + if need_kick: + await message.edit(f'此群组的死号数:`{member_count}`,并且已经清理完毕。') + else: + await message.edit(f'此群组的死号数:`{member_count}`。') + except ChatAdminRequired: + await message.edit("你好像并不拥有封禁用户权限。") diff --git a/list.json b/list.json index 6a03417..d1fd791 100644 --- a/list.json +++ b/list.json @@ -419,6 +419,16 @@ "supported": true, "des-short": "一键 AT 本群管理员。", "des": "一键 AT 本群管理员。\n指令:,atadmins" + }, + { + "name": "getdel", + "version": "1.0", + "section": "chat", + "maintainer": "xtaodada", + "size": "1.73 kb", + "supported": true, + "des-short": "获取当前群组的死号数。", + "des": "获取当前群组的死号数。\n指令:,getdel" } ] }