From 949e0b8a1d508858e382b76f70a9ee9915f44d4b Mon Sep 17 00:00:00 2001 From: xtaodada Date: Wed, 16 Jun 2021 22:57:44 +0800 Subject: [PATCH] =?UTF-8?q?xtao-some=20=E5=A2=9E=E5=8A=A0=20getdel=20?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=BE=A4=E7=BB=84=E6=9C=BA=E5=99=A8=E4=BA=BA?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.json | 4 ++-- xtao-some.py | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/list.json b/list.json index 93e380c..52bb045 100644 --- a/list.json +++ b/list.json @@ -62,13 +62,13 @@ }, { "name": "xtao-some", - "version": "1.17", + "version": "1.18", "section": "daily", "maintainer": "xtaodada", "size": "18.8 kb", "supported": true, "des-short": "一大堆便民功能。", - "des": "超多功能 例如 -ip -ipping -guess -t -getdel 等。" + "des": "超多功能 例如 -ip -ipping -guess -t -getdel -get_bots 等。" }, { "name": "yb-dl", diff --git a/xtao-some.py b/xtao-some.py index b8bcd64..d7e586b 100644 --- a/xtao-some.py +++ b/xtao-some.py @@ -5,7 +5,8 @@ from pagermaid import bot, log from pagermaid.listener import listener, config from pagermaid.utils import clear_emojis, obtain_message, attach_log, alias_command from telethon.errors import ChatAdminRequiredError -from telethon.tl.types import ChannelParticipantsAdmins +from telethon.errors.rpcerrorlist import FloodWaitError +from telethon.tl.types import ChannelParticipantsAdmins, ChannelParticipantsBots, ChannelParticipantAdmin @listener(is_plugin=True, outgoing=True, command=alias_command("guess"), @@ -291,7 +292,11 @@ async def getdel(context): if member.deleted: member_count += 1 if need_kick: - await context.client.kick_participant(context.chat_id, member.id) + try: + await context.client.kick_participant(context.chat_id, member.id) + except FloodWaitError: + await context.edit(context.chat_id, '处理失败,您已受到 TG 服务器限制。') + return if need_kick: await context.edit(f'此频道/群组的死号数:`{member_count}`,并且已经清理完毕。') else: @@ -299,4 +304,28 @@ async def getdel(context): except ChatAdminRequiredError: await context.edit('未加入此频道。') else: - await context.edit("请在在群组/频道发送。") + await context.edit("请在群组/频道发送。") + + +@listener(is_plugin=True, outgoing=True, command=alias_command("get_bots"), + description="获取当前群组/频道的Bot列表。") +async def get_bots(context): + cid = str(context.chat_id) + pri = cid.startswith('-100') + mentions = '以下是当前群组/频道的 Bot 列表:\n' + admins = [] + members = [] + if pri: + try: + await context.edit('遍历成员中。。。') + async for x in context.client.iter_participants(context.chat, filter=ChannelParticipantsBots): + if isinstance(x.participant, ChannelParticipantAdmin): + admins.append("⚜️ [{}](tg://user?id={})".format(x.first_name, x.id)) + else: + members.append("[{}](tg://user?id={})".format(x.first_name, x.id)) + mentions = mentions + '\n'.join(admins) + '\n' + '\n'.join(members) + except Exception as e: + mentions += " " + str(e) + "\n" + await context.edit(mentions) + else: + await context.edit("请在群组/频道发送。")