mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-25 00:04:32 +00:00
unbanby 查询/解除群组中被所回复用户所封禁的用户。
This commit is contained in:
parent
1cc3a12f6d
commit
8271821071
@ -3,7 +3,7 @@ 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 telethon.errors.rpcerrorlist import FloodWaitError
|
||||||
from time import sleep
|
from asyncio import sleep
|
||||||
from random import uniform
|
from random import uniform
|
||||||
|
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ async def fuck_member(context):
|
|||||||
# Wait flood secs
|
# Wait flood secs
|
||||||
await context.edit(f'触发 Flood ,暂停 {e.seconds + uniform(0.5, 1.0)} 秒。')
|
await context.edit(f'触发 Flood ,暂停 {e.seconds + uniform(0.5, 1.0)} 秒。')
|
||||||
try:
|
try:
|
||||||
sleep(e.seconds + uniform(0.5, 1.0))
|
await sleep(e.seconds + uniform(0.5, 1.0))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Wait flood error: {e}")
|
print(f"Wait flood error: {e}")
|
||||||
return
|
return
|
||||||
|
10
list.json
10
list.json
@ -599,6 +599,16 @@
|
|||||||
"supported": true,
|
"supported": true,
|
||||||
"des-short": "查找/清理群组中所有潜水超过一定天数的成员。",
|
"des-short": "查找/清理群组中所有潜水超过一定天数的成员。",
|
||||||
"des": "查找/清理群组中所有潜水超过 n 天的成员。(n>=7)。命令:fuckmember 。"
|
"des": "查找/清理群组中所有潜水超过 n 天的成员。(n>=7)。命令:fuckmember 。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "unbanby",
|
||||||
|
"version": "1.0",
|
||||||
|
"section": "daily",
|
||||||
|
"maintainer": "xtaodada",
|
||||||
|
"size": "2.8 kb",
|
||||||
|
"supported": true,
|
||||||
|
"des-short": "查询/解除群组中被所回复用户所封禁的用户。",
|
||||||
|
"des": "查询/解除群组中被所回复用户所封禁的用户。命令:unbanby 。"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
70
unbanby.py
Normal file
70
unbanby.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
from pagermaid.listener import listener
|
||||||
|
from pagermaid.utils import alias_command
|
||||||
|
from telethon.tl.types import ChannelParticipantsKicked, ChannelParticipantsAdmins
|
||||||
|
from telethon.errors.rpcerrorlist import UserAdminInvalidError
|
||||||
|
from telethon.errors.rpcerrorlist import FloodWaitError
|
||||||
|
from asyncio import sleep
|
||||||
|
from random import uniform
|
||||||
|
|
||||||
|
|
||||||
|
@listener(is_plugin=False, outgoing=True, command=alias_command("unbanby"),
|
||||||
|
description='查询/解除群组中被所回复用户所封禁的用户。',
|
||||||
|
parameters="<true>")
|
||||||
|
async def unban_by_bot(context):
|
||||||
|
if not context.is_group:
|
||||||
|
await context.edit('请在群组中运行。')
|
||||||
|
return
|
||||||
|
reply = await context.get_reply_message()
|
||||||
|
if not reply:
|
||||||
|
await context.edit('请回复一个用户。')
|
||||||
|
return
|
||||||
|
# 读取模式
|
||||||
|
unban_mode = False
|
||||||
|
if len(context.parameter) == 1:
|
||||||
|
unban_mode = True
|
||||||
|
text = f'查找被 Ta 封禁的用户中。'
|
||||||
|
if unban_mode:
|
||||||
|
text += '\n移除中。。。'
|
||||||
|
await context.edit(text)
|
||||||
|
# 读取权限
|
||||||
|
count, members, members_count = 0, 0, 0
|
||||||
|
admins = await context.client.get_participants(context.chat, filter=ChannelParticipantsAdmins)
|
||||||
|
if context.sender in admins:
|
||||||
|
user = admins[admins.index(context.sender)]
|
||||||
|
if not user.participant.admin_rights.ban_users:
|
||||||
|
await context.edit('无封禁用户权限,停止查询。')
|
||||||
|
return
|
||||||
|
# 遍历列表
|
||||||
|
async for x in context.client.iter_participants(context.chat, filter=ChannelParticipantsKicked):
|
||||||
|
members += 1
|
||||||
|
if x.participant.kicked_by == reply.sender_id:
|
||||||
|
count += 1
|
||||||
|
if unban_mode:
|
||||||
|
try:
|
||||||
|
await context.client.edit_permissions(context.chat, x)
|
||||||
|
except FloodWaitError as e:
|
||||||
|
# Wait flood secs
|
||||||
|
await context.edit(f'触发 Flood ,暂停 {e.seconds + uniform(0.5, 1.0)} 秒。')
|
||||||
|
try:
|
||||||
|
await sleep(e.seconds + uniform(0.5, 1.0))
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Wait flood error: {e}")
|
||||||
|
return
|
||||||
|
except UserAdminInvalidError:
|
||||||
|
await context.edit('无管理员权限,停止查询。')
|
||||||
|
return
|
||||||
|
# 每一百人修改一次
|
||||||
|
if members == 100:
|
||||||
|
members_count += 1
|
||||||
|
members = 0
|
||||||
|
await context.edit(text + f'\n已查找 {members_count * 100} 人。')
|
||||||
|
text = ''
|
||||||
|
if count > 0:
|
||||||
|
text += f'查找到了 {count} 个被 Ta 封禁的用户。\n'
|
||||||
|
if unban_mode:
|
||||||
|
text += '解除完毕。'
|
||||||
|
else:
|
||||||
|
text += f'使用 `-unbanby yes` 开始解除封禁'
|
||||||
|
else:
|
||||||
|
text = f'没有发现被 Ta 封禁的用户呢。'
|
||||||
|
await context.edit(text)
|
Loading…
Reference in New Issue
Block a user