From 6b21ff3d1e0c9a1b7256db1f9bea84e7eaf6adf4 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Mon, 12 Jul 2021 18:07:27 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20fuckmember=20=E5=88=97=E5=87=BA?= =?UTF-8?q?=E7=BE=A4=E7=BB=84=E4=B8=AD=E6=89=80=E6=9C=89=E6=BD=9C=E6=B0=B4?= =?UTF-8?q?=E8=B6=85=E8=BF=87=20n=20=E5=A4=A9=E7=9A=84=E6=88=90=E5=91=98?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fuckmember.py | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ list.json | 10 ++++++ 2 files changed, 94 insertions(+) create mode 100644 fuckmember.py diff --git a/fuckmember.py b/fuckmember.py new file mode 100644 index 0000000..4900635 --- /dev/null +++ b/fuckmember.py @@ -0,0 +1,84 @@ +from pagermaid.listener import listener +from pagermaid.utils import alias_command +from telethon.tl.types import ChannelParticipantsAdmins + + +def eval_time(context, msg, day): + now = context.date + old = msg.date + days = (now - old).days + if days < day: + return False + else: + return True + + +@listener(is_plugin=False, outgoing=True, command=alias_command("fuckmember"), + description='查找/清理群组中所有潜水超过 n 天的成员。(n>=7)。', + parameters=" ") +async def fuck_member(context): + if not context.is_group: + await context.edit('请在群组中运行。') + return + # 读取天数 + text = '' + kick_mode = False + if len(context.parameter) == 1 or len(context.parameter) == 2: + if len(context.parameter) == 2: + kick_mode = True + try: + day = int(context.parameter[0]) + if day < 7: + day = 7 + text += '由于输入的数据过小,时间自动设置为 7 天。\n' + except KeyError: + day = 7 + text += '由于输入的数据错误,时间自动设置为 7 天。\n' + else: + day = 7 + text += '由于未输入数据,时间自动设置为 7 天。\n' + text += f'查找潜水超过 {day} 天的成员中。' + if kick_mode: + text += '\n移除中。。。' + await context.edit(text) + # 获取管理员 + msg, count, counts, members, members_count = 0, 0, 0, 0, 0 + admins = await context.client.get_participants(context.chat, filter=ChannelParticipantsAdmins) + async for x in context.client.iter_participants(context.chat): + members += 1 + if x in admins: + continue + async for message in context.client.iter_messages(context.chat_id, limit=1, from_user=x): + msg += 1 + time = eval_time(context, message, day) + if time: + count += 1 + if kick_mode: + await context.client.kick_participant(context.chat_id, x) + if msg == 1: + msg = 0 + else: + counts += 1 + if kick_mode: + await context.client.kick_participant(context.chat_id, x) + # 每二十人修改一次 + if members == 20: + members_count += 1 + members = 0 + await context.edit(text + f'\n已查找 {members_count * 20} 人。') + text = '' + if count > 0: + text += f'查找到了 {count} 个未发言超过 {day} 天的群成员。\n' + if counts > 0: + text += f'查找到了 {counts} 个从未发言的群成员。\n' + all_count = count + counts + if all_count > 0: + text += f'总共查找了 {all_count} 个群成员。\n' + if not text == '': + if kick_mode: + text += '清理完毕。' + else: + text += f'使用 `-fuckmember {day} yes` 开始清理' + else: + text = f'没有发现潜水超过 {day} 天的群成员呢,大家都很活跃!' + await context.edit(text) diff --git a/list.json b/list.json index 58e185a..1a8df52 100644 --- a/list.json +++ b/list.json @@ -589,6 +589,16 @@ "supported": true, "des-short": "查询信用卡bin信息。", "des": "使用binlist api查询,1分钟限额10次否则报错。使用方法:-bin xxx (xxx为信用卡卡号前4-8位,推荐6位)" + }, + { + "name": "fuckmember", + "version": "1.0", + "section": "daily", + "maintainer": "xtaodada", + "size": "3.0 kb", + "supported": true, + "des-short": "查找/清理群组中所有潜水超过一定天数的成员。", + "des": "查找/清理群组中所有潜水超过 n 天的成员。(n>=7)。命令:fuckmember 。" } ] }