2020-12-23 09:07:50 +00:00
|
|
|
""" PagerMaid Plugin killallmembers """
|
|
|
|
from asyncio import sleep
|
2020-08-27 10:33:56 +00:00
|
|
|
from telethon.tl.types import ChannelParticipantsAdmins
|
2021-06-01 01:37:26 +00:00
|
|
|
from telethon.errors.rpcerrorlist import FloodWaitError
|
2022-01-18 08:47:20 +00:00
|
|
|
from pagermaid import version
|
2020-12-23 09:07:50 +00:00
|
|
|
from pagermaid.listener import listener
|
2021-06-16 07:09:40 +00:00
|
|
|
from pagermaid.utils import alias_command
|
2020-08-27 10:33:56 +00:00
|
|
|
|
2021-06-16 07:09:40 +00:00
|
|
|
|
|
|
|
@listener(is_plugin=True, outgoing=True, command=alias_command("killallmembers"),
|
2020-08-27 10:33:56 +00:00
|
|
|
description="⚠⚠慎用! 一件扬了群内所有成员⚠⚠")
|
|
|
|
async def killallmembers(context):
|
2020-12-23 09:07:50 +00:00
|
|
|
""" PagerMaid Plugin killallmembers """
|
2020-08-27 10:33:56 +00:00
|
|
|
await context.edit('正在准备扬了这个破群的所有人...')
|
|
|
|
chat = await context.get_chat()
|
2021-06-01 01:37:26 +00:00
|
|
|
is_channel = False
|
2020-08-27 10:33:56 +00:00
|
|
|
if not context.is_group:
|
2021-06-01 01:37:26 +00:00
|
|
|
if context.is_channel:
|
|
|
|
is_channel = True
|
|
|
|
else:
|
|
|
|
is_channel = False
|
|
|
|
await context.edit('发生错误,请在群组或频道中运行本命令。')
|
|
|
|
await sleep(10)
|
|
|
|
await context.delete()
|
|
|
|
return
|
|
|
|
try:
|
|
|
|
chat = await context.get_chat()
|
|
|
|
admins = await context.client.get_participants(chat, filter=ChannelParticipantsAdmins)
|
|
|
|
users = await context.client.get_participants(chat)
|
|
|
|
admins_ids = [a.id for a in admins]
|
|
|
|
users_ids = [u.id for u in users]
|
|
|
|
users_wo_admins = list(set(users_ids).difference(set(admins_ids)))
|
|
|
|
except:
|
|
|
|
await context.edit('发生错误,无法获取本群名单。')
|
2020-08-27 10:33:56 +00:00
|
|
|
await sleep(10)
|
|
|
|
await context.delete()
|
|
|
|
return False
|
2020-12-23 09:07:50 +00:00
|
|
|
|
2021-06-19 07:15:43 +00:00
|
|
|
if (not is_channel) and (context.sender_id not in admins_ids):
|
2021-06-01 01:37:26 +00:00
|
|
|
await context.edit('你又不是管理员,你在这儿干个屁?')
|
|
|
|
await sleep(10)
|
|
|
|
await context.delete()
|
|
|
|
else:
|
|
|
|
i = 0
|
|
|
|
for user_id in users_wo_admins:
|
|
|
|
try:
|
|
|
|
await context.client.edit_permissions(context.chat_id, user_id, view_messages=False)
|
|
|
|
i += 1
|
|
|
|
if i == len(users_wo_admins):
|
|
|
|
await context.edit(f'完成!\n进度: {i}/{len(users_wo_admins)}')
|
|
|
|
a = 1
|
|
|
|
elif (i < 3) or (i % 10 == 0):
|
|
|
|
percent = i/len(users_wo_admins) * 100
|
|
|
|
await context.edit(f'进度: {i}/{len(users_wo_admins)}\nPercent: {percent:.2f}%')
|
|
|
|
await sleep(.5)
|
|
|
|
except FloodWaitError as e:
|
|
|
|
await context.edit('尝试次数过多,请稍后重试\n' + str(e))
|
|
|
|
await sleep(10)
|
|
|
|
await context.delete()
|
|
|
|
return
|
|
|
|
except:
|
|
|
|
await context.edit('发生错误')
|
|
|
|
await sleep(10)
|
|
|
|
await context.delete()
|
|
|
|
return
|