fuckmember 修复触发 flood 无法继续执行的问题

This commit is contained in:
xtaodada 2021-07-12 19:55:19 +08:00
parent bd2340d983
commit fe75822b97
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
2 changed files with 19 additions and 1 deletions

View File

@ -2,6 +2,8 @@ from pagermaid.listener import listener
from pagermaid.utils import alias_command from pagermaid.utils import alias_command
from telethon.tl.types import ChannelParticipantsAdmins from telethon.tl.types import ChannelParticipantsAdmins
from telethon.errors.rpcerrorlist import UserAdminInvalidError from telethon.errors.rpcerrorlist import UserAdminInvalidError
from telethon.errors.rpcerrorlist import FloodWaitError
from time import sleep
def eval_time(context, msg, day): def eval_time(context, msg, day):
@ -57,6 +59,14 @@ async def fuck_member(context):
if kick_mode: if kick_mode:
try: try:
await context.client.kick_participant(context.chat_id, x) await context.client.kick_participant(context.chat_id, x)
except FloodWaitError as e:
# Wait flood secs
await context.edit(f'触发 Flood ,暂停 {e.seconds + uniform(0.5, 1.0)} 秒。')
try:
sleep(e.seconds + uniform(0.5, 1.0))
except Exception as e:
print(f"Wait flood error: {e}")
return
except UserAdminInvalidError: except UserAdminInvalidError:
await context.edit('无管理员权限,停止查询。') await context.edit('无管理员权限,停止查询。')
return return
@ -67,6 +77,14 @@ async def fuck_member(context):
if kick_mode: if kick_mode:
try: try:
await context.client.kick_participant(context.chat_id, x) await context.client.kick_participant(context.chat_id, x)
except FloodWaitError as e:
# Wait flood secs
await context.edit(f'触发 Flood ,暂停 {e.seconds + uniform(0.5, 1.0)} 秒。')
try:
sleep(e.seconds + uniform(0.5, 1.0))
except Exception as e:
print(f"Wait flood error: {e}")
return
except UserAdminInvalidError: except UserAdminInvalidError:
await context.edit('无管理员权限,停止查询。') await context.edit('无管理员权限,停止查询。')
return return

View File

@ -592,7 +592,7 @@
}, },
{ {
"name": "fuckmember", "name": "fuckmember",
"version": "1.01", "version": "1.02",
"section": "daily", "section": "daily",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "3.0 kb", "size": "3.0 kb",