-
Notifications
You must be signed in to change notification settings - Fork 33
/
kickanddm.py
97 lines (92 loc) · 5.08 KB
/
kickanddm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from pagermaid import bot, log, version
from pagermaid.listener import listener
from asyncio import sleep
from datetime import timedelta
from telethon.tl.types import ChannelParticipantsAdmins
from pagermaid.utils import alias_command
async def removemsg(context, last_name, count):
count_buffer = 0
target = await context.get_reply_message()
async for message in context.client.iter_messages(context.chat_id, from_user=target.from_id):
if count_buffer == count:
break
await message.delete()
count_buffer += 1
await log(f'删除【{last_name}】消息完成,共删除{count_buffer}条消息')
await context.edit(f'已删除【{last_name}】这个b最近{count_buffer}条污言秽语')
@listener(is_plugin=True, outgoing=True, command=alias_command("kickanddm"),
description="回复你要删除消息和踢的人或者要禁言的人\n指令:\n-k直接删除消息并踢人\n-k 10禁言10秒(tg不支持60秒以下的时间,少于60变成永久)并删除最近999条消息\n⚠️k后面带时间的只是禁言,不带时间的直接踢")
async def kickanddm(context):
# 是否在群组
if context.is_group:
reply = await context.get_reply_message()
# 是否回复了消息
if reply:
# 是否是管理员
try:
chat = await context.get_chat()
admins = await context.client.get_participants(chat, filter=ChannelParticipantsAdmins)
admins_ids = [a.id for a in admins]
if context.sender_id not in admins_ids:
await context.edit('你又不是管理员,玩呢?')
await sleep(5)
await context.delete()
return False
except:
await context.edit('发生错误,无法获取本群名单。')
await sleep(5)
await context.delete()
return False
else:
action = context.parameter
if reply.sender.last_name is None:
if reply.sender.first_name is None:
last_name = ''
else:
last_name = reply.sender.first_name
else:
last_name = reply.sender.last_name
if len(action) == 1:
try:
await context.client.edit_permissions(context.chat_id, reply.sender.id,
timedelta(seconds=int(action[0].replace(' ', ''))),
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)
await context.edit(f'已将【{last_name}】这个b的嘴堵住了!\n正在清理污言秽语...')
await removemsg(context, last_name, 999)
except:
await context.edit('🤏🏼给爷等着,迟早ban了你')
await sleep(5)
await context.delete()
return
else:
try:
await context.client.edit_permissions(context.chat_id, reply.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)
await context.edit(f'已将【{last_name}】这个b的嘴堵住了!\n正在清理存在痕迹...')
await removemsg(context, last_name, 999)
await context.client.edit_permissions(context.chat_id, reply.sender.id, view_messages=False)
await context.edit(f'已将【{last_name}】这个b飞了,江湖不见!')
except:
await context.edit('🤏🏼给爷等着,迟早ban了你')
await sleep(5)
await context.delete()
return
else:
await context.edit('你好蠢诶,都没有回复人,我哪知道你要搞谁……')
await sleep(5)
await context.delete()
else:
await context.edit('你好蠢诶,又不是群组,怎么搞人!')
await sleep(5)
await context.delete()