killallmembers v1.10 Channel可用

This commit is contained in:
Pentacene 2021-06-01 09:37:26 +08:00
parent 7a23b3e897
commit 08c36418a9
2 changed files with 47 additions and 36 deletions

View File

@ -1,6 +1,7 @@
""" PagerMaid Plugin killallmembers """ """ PagerMaid Plugin killallmembers """
from asyncio import sleep from asyncio import sleep
from telethon.tl.types import ChannelParticipantsAdmins from telethon.tl.types import ChannelParticipantsAdmins
from telethon.errors.rpcerrorlist import FloodWaitError
from pagermaid.listener import listener from pagermaid.listener import listener
@listener(is_plugin=True, outgoing=True, command="killallmembers", @listener(is_plugin=True, outgoing=True, command="killallmembers",
@ -9,43 +10,53 @@ async def killallmembers(context):
""" PagerMaid Plugin killallmembers """ """ PagerMaid Plugin killallmembers """
await context.edit('正在准备扬了这个破群的所有人...') await context.edit('正在准备扬了这个破群的所有人...')
chat = await context.get_chat() chat = await context.get_chat()
is_channel = False
if not context.is_group: if not context.is_group:
await context.edit('发生错误,请在群组中运行本命令。') 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('发生错误,无法获取本群名单。')
await sleep(10) await sleep(10)
await context.delete() await context.delete()
return False return False
else:
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('发生错误,无法获取本群名单。')
await sleep(10)
await context.delete()
return False
if context.sender.id in admins_ids: if (not is_channel) and (context.sender.id not in admins_ids):
i = 0 await context.edit('你又不是管理员,你在这儿干个屁?')
for user_id in users_wo_admins: await sleep(10)
try: await context.delete()
await context.client.edit_permissions(context.chat_id, user_id, view_messages=False) else:
i += 1 i = 0
if i == len(users_wo_admins): for user_id in users_wo_admins:
await context.edit(f'完成!\n进度:{i}/{len(users_wo_admins)}') try:
elif (i < 10) or (i % 10 == 0): await context.client.edit_permissions(context.chat_id, user_id, view_messages=False)
await context.edit(f'进度:{i}/{len(users_wo_admins)}' i += 1
"{'percent: {:.0f}%'.format(i/len(users_wo_admins))") if i == len(users_wo_admins):
except: await context.edit(f'完成!\n进度: {i}/{len(users_wo_admins)}')
await context.edit('发生错误') a = 1
await sleep(10) elif (i < 3) or (i % 10 == 0):
await context.delete() percent = i/len(users_wo_admins) * 100
await sleep(5) await context.edit(f'进度: {i}/{len(users_wo_admins)}\nPercent: {percent:.2f}%')
await context.delete() await sleep(.5)
else: except FloodWaitError as e:
await context.edit('你又不是管理员,你在这儿干个屁?') await context.edit('尝试次数过多,请稍后重试\n' + str(e))
await sleep(10) await sleep(10)
await context.delete() await context.delete()
return
except:
await context.edit('发生错误')
await sleep(10)
await context.delete()
return

View File

@ -292,7 +292,7 @@
}, },
{ {
"name": "killallmembers", "name": "killallmembers",
"version": "1.03", "version": "1.10",
"section": "chat", "section": "chat",
"maintainer": "Pentacene", "maintainer": "Pentacene",
"size": "idk", "size": "idk",