-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglobalban.py
247 lines (228 loc) Β· 9.62 KB
/
globalban.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
from telethon import events
from telethon.tl.functions.channels import EditAdminRequest
from telethon.tl.types import ChatAdminRights
import asyncio
from d3vilbot.sql.gban_sql import is_gbanned, gbaner, ungbaner, all_gbanned
from d3vilbot.sql import gmute_sql as gsql
from . import *
@bot.on(d3vil_cmd(pattern=r"gban ?(.*)"))
@bot.on(sudo_cmd(pattern=r"gban ?(.*)", allow_sudo=True))
async def _(event):
d3vil = await eor(event, "`Gbanning...`")
reason = ""
if event.reply_to_msg_id:
userid = (await event.get_reply_message()).sender_id
try:
reason = event.text.split(" ", maxsplit=1)[1]
except IndexError:
reason = ""
elif event.pattern_match.group(1):
usr = event.text.split(" ", maxsplit=2)[1]
userid = await get_user_id(usr)
try:
reason = event.text.split(" ", maxsplit=2)[2]
except IndexError:
reason = ""
elif event.is_private:
userid = (await event.get_chat()).id
try:
reason = event.text.split(" ", maxsplit=1)[1]
except IndexError:
reason = ""
else:
return await eod(d3vil, "**To gban a user i need a userid or reply to his/her message!!**")
name = (await event.client.get_entity(userid)).first_name
chats = 0
if userid == d3krish:
return await eod(d3vil, "π₯΄ **Nashe me hai kya lawde β½**")
if str(userid) in DEVLIST:
return await eod(d3vil, "π **GBan my creator ?ΒΏ Reallyβ½**")
if is_gbanned(userid):
return await eod(
d3vil,
"This kid is already gbanned and added to my **Gban Watch!!**",
)
async for gfuck in event.client.iter_dialogs():
if gfuck.is_group or gfuck.is_channel:
try:
await event.client.edit_permissions(gfuck.id, userid, view_messages=False)
chats += 1
except BaseException:
pass
gbaner(userid)
gmsg = f"π₯΄ ππ·πΈπ πππ΄π πΆπ»πΎπ±π°π» π±π°π½ γ[{name}](tg://user?id={userid})γ **π±π :** γ{d3vil_mention}γ\n\nπ π°ππππ ππ πΆπππ πππππ!!\n** πππππ π²ππππ :** `{chats}`"
if reason != "":
gmsg += f"\n**ππππππ β³β :** `{reason}`"
ogmsg = f"[{name}](tg://user?id={userid}) **πΈπ πππ πΆπ±πππππ ππ’** {d3vil_mention} **in** `{chats}` **π²ππππ!! π**\n\n**π π°πππ π°ππππ ππ πΆπππ πππππ!!**"
if reason != "":
ogmsg += f"\n**ππππππ β³β :** `{reason}`"
if Config.ABUSE == "ON":
await bot.send_file(event.chat_id, cjb, caption=gmsg)
else:
await d3vil.edit(ogmsg)
@bot.on(d3vil_cmd(pattern=r"ungban ?(.*)"))
@bot.on(sudo_cmd(pattern=r"ungban ?(.*)", allow_sudo=True))
async def _(event):
d3vil = await eor(event, "`Ungban in progress...`")
if event.reply_to_msg_id:
userid = (await event.get_reply_message()).sender_id
elif event.pattern_match.group(1):
userid = await get_user_id(event.pattern_match.group(1))
elif event.is_private:
userid = (await event.get_chat()).id
else:
return await eod(d3vil, "`Reply to a user or give their userid... `")
name = (await event.client.get_entity(userid)).first_name
chats = 0
if not is_gbanned(userid):
return await eod(d3vil, "`User is not gbanned.`")
async for gfuck in event.client.iter_dialogs():
if gfuck.is_group or gfuck.is_channel:
try:
await event.client.edit_permissions(gfuck.id, userid, view_messages=True)
chats += 1
except BaseException:
pass
ungbaner(userid)
await d3vil.edit(
f"π [{name}](tg://user?id={userid}) **ππ πππ πππππππππ ππππ `{chats}` πππππ πππ πππππππ ππππ πΆπππ πππππ!!**",
)
@bot.on(d3vil_cmd(pattern="listgban$"))
@bot.on(sudo_cmd(pattern="listgban$", allow_sudo=True))
async def already(event):
gbanned_users = all_gbanned()
GBANNED_LIST = "**Gbanned Users :**\n"
if len(gbanned_users) > 0:
for user in gbanned_users:
name = (await bot.get_entity(int(user))).first_name
GBANNED_LIST += f"π [{name}](tg://user?id={user.chat_id})\n"
else:
GBANNED_LIST = "No Gbanned Users!!"
await edit_or_reply(event, GBANNED_LIST)
@bot.on(events.ChatAction)
async def _(event):
if event.user_joined or event.added_by:
user = await event.get_user()
chat = await event.get_chat()
if is_gbanned(str(user.id)):
if chat.admin_rights:
try:
await event.client.edit_permissions(
chat.id,
user.id,
view_messages=False,
)
gban_watcher = f"β οΈβ οΈ**πππππππ**β οΈβ οΈ\n\n`Gbanned User Joined the chat!!`\n**βοΈ Victim Id :** [{user.first_name}](tg://user?id={user.id})\n"
gban_watcher += f"**π₯ π°πππππ π₯** \n`Banned this piece of shit....` **AGAIN!**"
await event.reply(gban_watcher)
except BaseException:
pass
@bot.on(d3vil_cmd(pattern=r"gkick ?(.*)"))
@bot.on(sudo_cmd(pattern=r"gkick ?(.*)", allow_sudo=True))
async def gkick(event):
d3vil = await eor(event, "`Kicking globally...`")
if event.reply_to_msg_id:
userid = (await event.get_reply_message()).sender_id
elif event.pattern_match.group(1):
userid = await get_user_id(event.pattern_match.group(1))
elif event.is_private:
userid = (await event.get_chat()).id
else:
return await eod(d3vil, "`Reply to some msg or add their id.`")
name = (await event.client.get_entity(userid)).first_name
chats = 0
if userid == d3krish:
return await eod(d3vil, "**π₯΄ Nashe me hai kya lawde!!**")
if str(userid) in DEVLIST:
return await eod(d3vil, "**πͺ I'm not going to gkick my developer!!**")
async for gkick in event.client.iter_dialogs():
if gkick.is_group or gkick.is_channel:
try:
await bot.kick_participant(gkick.id, userid)
chats += 1
except BaseException:
pass
gkmsg = f"π **Globally Kicked** [{name}](tg://user?id={userid})'s butts !! \n\nπ **Chats :** `{chats}`"
if Config.ABUSE == "ON":
await bot.send_file(event.chat_id, cjb, caption=gkmsg)
else:
await d3vil.edit(gkmsg)
@bot.on(d3vil_cmd(pattern=r"gmute ?(\d+)?"))
@bot.on(sudo_cmd(allow_sudo=True, pattern=r"gmute ?(\d+)?"))
async def gm(event):
private = False
if event.fwd_from:
return
elif event.is_private:
await eor(event, "`Trying to gmute user...`")
await asyncio.sleep(2)
private = True
reply = await event.get_reply_message()
if event.pattern_match.group(1) is not None:
userid = event.pattern_match.group(1)
elif reply is not None:
userid = reply.sender_id
elif private is True:
userid = event.chat_id
else:
return await eod(event, "Need a user to gmute. Reply or give userid to gmute them..")
event.chat_id
await event.get_chat()
if gsql.is_gmuted(userid, "gmute"):
return await eod(event, "This kid is already Gmuted.")
try:
if str(userid) in DEVLIST:
return await eod(event, "**Sorry I'm not going to gmute them..**")
except:
pass
try:
gsql.gmute(userid, "gmute")
except Exception as e:
await eod(event, "Error occured!\nError is " + str(e))
else:
await eor(event, "Shhh.... Now keep quiet !!")
@bot.on(d3vil_cmd(outgoing=True, pattern=r"ungmute ?(\d+)?"))
@bot.on(sudo_cmd(allow_sudo=True, pattern=r"ungmute ?(\d+)?"))
async def endgmute(event):
private = False
if event.fwd_from:
return
elif event.is_private:
await eor(event, "`Trying to ungmute !!`")
await asyncio.sleep(2)
private = True
reply = await event.get_reply_message()
if event.pattern_match.group(1) is not None:
userid = event.pattern_match.group(1)
elif reply is not None:
userid = reply.sender_id
elif private is True:
userid = event.chat_id
else:
return await eod(event,"Please reply to a user or add their into the command to ungmute them.")
event.chat_id
if not gsql.is_gmuted(userid, "gmute"):
return await eod(event, "I don't remember I gmuted him...")
try:
gsql.ungmute(userid, "gmute")
except Exception as e:
await eod(event, "Error occured!\nError is " + str(e))
else:
await eor(event, "Ok!! Speak")
@command(incoming=True)
async def watcher(event):
if gsql.is_gmuted(event.sender_id, "gmute"):
await event.delete()
CmdHelp("global_cmnd").add_command(
"gban", "<reply>/<userid>", "Globally Bans the mentioned user in 'X' chats you are admin with ban permission."
).add_command(
"ungban", "<reply>/<userid>", "Globally Unbans the user in 'X' chats you are admin!"
).add_command(
"listgban", None, "Gives the list of all GBanned Users."
).add_command(
"gkick", "<reply>/<userid>", "Globally Kicks the user in 'X' chats you are admin!"
).add_command(
"gmute", "<reply> or <userid>", "Globally Mutes the User."
).add_command(
"ungmute", "<reply> or <userid>", "Globally Unmutes the gmutes user."
).add()