From bd2340d98349643b6a05897a75ef1e7bf9cc135b Mon Sep 17 00:00:00 2001 From: xtaodada Date: Mon, 12 Jul 2021 18:24:15 +0800 Subject: [PATCH] fuckmember fix edit too quick bug. --- fuckmember.py | 19 ++++++++++++++----- list.json | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/fuckmember.py b/fuckmember.py index 4900635..bc00389 100644 --- a/fuckmember.py +++ b/fuckmember.py @@ -1,6 +1,7 @@ from pagermaid.listener import listener from pagermaid.utils import alias_command from telethon.tl.types import ChannelParticipantsAdmins +from telethon.errors.rpcerrorlist import UserAdminInvalidError def eval_time(context, msg, day): @@ -54,18 +55,26 @@ async def fuck_member(context): if time: count += 1 if kick_mode: - await context.client.kick_participant(context.chat_id, x) + try: + await context.client.kick_participant(context.chat_id, x) + except UserAdminInvalidError: + await context.edit('无管理员权限,停止查询。') + return if msg == 1: msg = 0 else: counts += 1 if kick_mode: - await context.client.kick_participant(context.chat_id, x) - # 每二十人修改一次 - if members == 20: + try: + await context.client.kick_participant(context.chat_id, x) + except UserAdminInvalidError: + await context.edit('无管理员权限,停止查询。') + return + # 每一百人修改一次 + if members == 100: members_count += 1 members = 0 - await context.edit(text + f'\n已查找 {members_count * 20} 人。') + await context.edit(text + f'\n已查找 {members_count * 100} 人。') text = '' if count > 0: text += f'查找到了 {count} 个未发言超过 {day} 天的群成员。\n' diff --git a/list.json b/list.json index 1a8df52..5db8b60 100644 --- a/list.json +++ b/list.json @@ -592,7 +592,7 @@ }, { "name": "fuckmember", - "version": "1.0", + "version": "1.01", "section": "daily", "maintainer": "xtaodada", "size": "3.0 kb",