2021-06-09 05:49:21 +00:00
|
|
|
""" Pagermaid Plugins Rape """
|
|
|
|
# ______ _
|
|
|
|
# | ___ \ | |
|
|
|
|
# | |_/ /__ _ __ | |_ __ _ ___ ___ _ __ ___
|
|
|
|
# | __/ _ \ '_ \| __/ _` |/ __/ _ \ '_ \ / _ \
|
|
|
|
# | | | __/ | | | || (_| | (_| __/ | | | __/
|
|
|
|
# \_| \___|_| |_|\__\__,_|\___\___|_| |_|\___|
|
|
|
|
#
|
|
|
|
|
|
|
|
from datetime import timedelta
|
|
|
|
from telethon.tl.types import ChannelParticipantsAdmins
|
2021-07-15 08:12:49 +00:00
|
|
|
from telethon.errors.rpcerrorlist import ChatAdminRequiredError
|
2021-06-09 05:49:21 +00:00
|
|
|
from pagermaid.listener import listener
|
2021-06-16 07:09:40 +00:00
|
|
|
from pagermaid.utils import alias_command
|
2021-06-09 05:49:21 +00:00
|
|
|
|
2021-06-16 07:09:40 +00:00
|
|
|
|
|
|
|
@listener(is_plugin=True, incoming=True, outgoing=True, command=alias_command("rape"),
|
2021-06-09 05:49:21 +00:00
|
|
|
description="回复你要踢出的人或-rape <TelegramID>")
|
|
|
|
async def rape(context):
|
|
|
|
reply = await context.get_reply_message()
|
|
|
|
if context.is_group:
|
|
|
|
if reply:
|
2021-12-15 05:10:56 +00:00
|
|
|
try:
|
|
|
|
if reply.sender.last_name is None:
|
|
|
|
reply_last_name = ''
|
|
|
|
else:
|
|
|
|
reply_last_name = reply.sender.last_name
|
|
|
|
except AttributeError:
|
|
|
|
try:
|
|
|
|
await context.edit('无法获取所回复的用户。')
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
return
|
2021-06-16 07:55:09 +00:00
|
|
|
if context.sender.last_name is None:
|
2021-06-09 05:49:21 +00:00
|
|
|
context_last_name = ''
|
|
|
|
else:
|
|
|
|
context_last_name = context.sender.last_name
|
|
|
|
admins = await context.client.get_participants(context.chat, filter=ChannelParticipantsAdmins)
|
|
|
|
if context.sender in admins:
|
2021-07-15 08:12:49 +00:00
|
|
|
user = admins[admins.index(context.sender)]
|
|
|
|
if not user.participant.admin_rights.ban_users:
|
|
|
|
await context.edit('无封禁用户权限。')
|
|
|
|
return
|
|
|
|
try:
|
|
|
|
await context.client.kick_participant(context.chat_id, reply.sender.id)
|
|
|
|
except ChatAdminRequiredError:
|
|
|
|
await context.edit('无管理员权限。')
|
|
|
|
return
|
2021-12-12 05:24:40 +00:00
|
|
|
except:
|
|
|
|
await context.edit('无法踢出。')
|
|
|
|
return
|
2021-06-09 05:49:21 +00:00
|
|
|
await context.client.send_message(
|
|
|
|
context.chat_id,
|
|
|
|
f'[{reply.sender.first_name} {reply_last_name}](tg://user?id={reply.sender.id}) 已被移出群聊',
|
2021-06-16 07:09:40 +00:00
|
|
|
reply_to=reply.id
|
2021-06-09 05:49:21 +00:00
|
|
|
)
|
|
|
|
try:
|
|
|
|
await context.delete()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
try:
|
2021-06-16 07:09:40 +00:00
|
|
|
await context.client.edit_permissions(context.chat_id, context.sender.id, timedelta(seconds=60),
|
|
|
|
send_messages=False, send_media=False, send_stickers=False,
|
|
|
|
send_gifs=False, send_games=False, send_inline=False,
|
|
|
|
send_polls=False, invite_users=False, change_info=False,
|
|
|
|
pin_messages=False)
|
2021-06-09 05:49:21 +00:00
|
|
|
await context.client.send_message(
|
|
|
|
context.chat_id,
|
2021-06-16 07:55:09 +00:00
|
|
|
f'[{context.sender.first_name} {context_last_name}](tg://user?id={context.sender.id}) '
|
|
|
|
f'由于乱玩管理员命令 已被禁言60秒',
|
2021-06-16 07:09:40 +00:00
|
|
|
reply_to=reply.id
|
2021-06-09 05:49:21 +00:00
|
|
|
)
|
|
|
|
await context.delete()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
else:
|
2021-12-15 05:10:56 +00:00
|
|
|
try:
|
|
|
|
if context.sender.last_name is None:
|
|
|
|
context_last_name = ''
|
|
|
|
else:
|
|
|
|
context_last_name = context.sender.last_name
|
|
|
|
except AttributeError:
|
|
|
|
try:
|
|
|
|
await context.edit('无法获取所回复的用户。')
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
return
|
2021-06-09 05:49:21 +00:00
|
|
|
if context.arguments == '':
|
|
|
|
return
|
|
|
|
else:
|
2021-07-02 12:04:08 +00:00
|
|
|
try:
|
|
|
|
userid = int(context.arguments)
|
|
|
|
except ValueError:
|
|
|
|
await context.edit('无法识别的账号 id 。')
|
|
|
|
return
|
2021-06-09 05:49:21 +00:00
|
|
|
admins = await context.client.get_participants(context.chat, filter=ChannelParticipantsAdmins)
|
|
|
|
if context.sender in admins:
|
|
|
|
try:
|
|
|
|
await context.client.kick_participant(context.chat_id, userid)
|
|
|
|
await context.client.send_message(
|
|
|
|
context.chat_id,
|
|
|
|
f'[{userid}](tg://user?id={userid}) 已被移出群聊',
|
2021-06-16 07:09:40 +00:00
|
|
|
reply_to=context.id
|
2021-06-09 05:49:21 +00:00
|
|
|
)
|
|
|
|
await context.delete()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
try:
|
2021-06-16 07:09:40 +00:00
|
|
|
await context.client.edit_permissions(context.chat_id, context.sender.id, timedelta(seconds=60),
|
|
|
|
send_messages=False, send_media=False,
|
|
|
|
send_stickers=False, send_gifs=False, send_games=False,
|
|
|
|
send_inline=False, send_polls=False, invite_users=False,
|
|
|
|
change_info=False, pin_messages=False)
|
2021-06-09 05:49:21 +00:00
|
|
|
await context.client.send_message(
|
|
|
|
context.chat_id,
|
2021-06-16 07:55:09 +00:00
|
|
|
f'[{context.sender.first_name}{context_last_name}](tg://user?id={context.sender.id}) '
|
|
|
|
f'由于乱玩管理员命令 已被禁言60秒',
|
2021-06-16 07:09:40 +00:00
|
|
|
reply_to=context.id
|
2021-06-09 05:49:21 +00:00
|
|
|
)
|
|
|
|
await context.delete()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
pass
|