-
Notifications
You must be signed in to change notification settings - Fork 5
/
gban.py
213 lines (200 loc) · 7.25 KB
/
gban.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
from telethon.tl.functions.contacts import BlockRequest, UnblockRequest
from ULTRA import CMD_HELP
from ULTRA.utils import admin_cmd
import html
from telethon import events
from telethon.tl.functions.photos import GetUserPhotosRequest
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.types import MessageEntityMentionName
from telethon.utils import get_input_location
from telethon.events import ChatAction
async def get_full_user(event):
args = event.pattern_match.group(1).split(':', 1)
extra = None
if event.reply_to_msg_id and not len(args) == 2:
previous_message = await event.get_reply_message()
user_obj = await event.client.get_entity(previous_message.sender_id)
extra = event.pattern_match.group(1)
elif len(args[0]) > 0:
user = args[0]
if len(args) == 2:
extra = args[1]
if user.isnumeric():
user = int(user)
if not user:
await event.edit("`User ID Is Required")
return
if event.message.entities is not None:
probable_user_mention_entity = event.message.entities[0]
if isinstance(probable_user_mention_entity,
MessageEntityMentionName):
user_id = probable_user_mention_entity.user_id
user_obj = await event.client.get_entity(user_id)
return user_obj
try:
user_obj = await event.client.get_entity(user)
except Exception as err:
return await event.edit("Something Went Wrong", str(err))
return user_obj, extra
async def get_user_sender_id(user, event):
if isinstance(user, str):
user = int(user)
try:
user_obj = await event.client.get_entity(user)
except (TypeError, ValueError) as err:
await event.edit(str(err))
return None
return user_obj
@borg.on(admin_cmd(pattern="gban ?(.*)"))
async def gspider(ULTRA):
lol = ULTRA
sender = await lol.get_sender()
me = await lol.client.get_me()
if not sender.id == me.id:
friday = await lol.reply("Gbanning This Retard DumbAss😁😁")
else:
friday = await lol.edit("Wait Processing.....")
me = await ULTRA.client.get_me()
await friday.edit(f"Global Ban Is Coming ! Wait And Watch You bitch😎🔥")
my_mention = "[{}](tg://user?id={})".format(me.first_name, me.id)
f"@{me.username}" if me.username else my_mention
await ULTRA.get_chat()
a = b = 0
if ULTRA.is_private:
user = ULTRA.chat
reason = ULTRA.pattern_match.group(1)
else:
ULTRA.chat.title
try:
user, reason = await get_full_user(ULTRA)
except:
pass
try:
if not reason:
reason = "Private"
except:
return await friday.edit(f"**Something W3NT Wrong 🤔**")
if user:
if user.id == 1100231654:
return await friday.edit(
f"**Didn't , Your Father Teach You ? That You Cant Gban your creator😑😑🖕**"
)
try:
from ULTRA.modules.sql_helper.gmute_sql import gmute
except:
pass
try:
await ULTRA.client(BlockRequest(user))
except:
pass
testULTRA = [
d.entity.id
for d in await ULTRA.client.get_dialogs()
if (d.is_group or d.is_channel)
]
for i in testULTRA:
try:
await ULTRA.client.edit_permissions(i, user, view_messages=False)
a += 1
await friday.edit(f"**GBANNED // Total Affected Chats **: `{a}`")
except:
b += 1
else:
await friday.edit(f"**Reply to a user !!**")
try:
if gmute(user.id) is False:
return await friday.edit(f"**Error! User probably already gbanned.**")
except:
pass
return await friday.edit(
f"**Gbanned [{user.first_name}](tg://user?id={user.id}) Affected Chats : {a} **"
)
@borg.on(admin_cmd(pattern="ungban ?(.*)"))
async def gspider(ULTRA):
lol = ULTRA
sender = await lol.get_sender()
me = await lol.client.get_me()
if not sender.id == me.id:
friday = await lol.reply("`Wait Let Me Process`")
else:
friday = await lol.edit("Just a Second ")
me = await ULTRA.client.get_me()
await friday.edit(f"Trying To Ungban User !")
my_mention = "[{}](tg://user?id={})".format(me.first_name, me.id)
f"@{me.username}" if me.username else my_mention
await ULTRA.get_chat()
a = b = 0
if ULTRA.is_private:
user = ULTRA.chat
reason = ULTRA.pattern_match.group(1)
else:
ULTRA.chat.title
try:
user, reason = await get_full_user(ULTRA)
except:
pass
try:
if not reason:
reason = "Private"
except:
return await friday.edit("Someting Went Wrong 🤔")
if user:
if user.id == 1100231654:
return await friday.edit("**You Cant gban him... as a result you can not ungban him... He is My Creator!**")
try:
from ULTRA.modules.sql_helper.gmute_sql import ungmute
except:
pass
try:
await ULTRA.client(UnblockRequest(user))
except:
pass
testULTRA = [
d.entity.id
for d in await ULTRA.client.get_dialogs()
if (d.is_group or d.is_channel)
]
for i in testULTRA:
try:
await ULTRA.client.edit_permissions(i, user, send_messages=True)
a += 1
await friday.edit(f"**UNGBANNING // AFFECTED CHATS - {a} **")
except:
b += 1
else:
await friday.edit("**Reply to a user !!**")
try:
if ungmute(user.id) is False:
return await friday.edit("**Error! User probably already ungbanned.**")
except:
pass
return await friday.edit(
f"**UNGBANNED // USER - [{user.first_name}](tg://user?id={user.id}) CHATS : {a} **"
)
@borg.on(ChatAction)
async def handler(rkG):
if rkG.user_joined or rkG.user_added:
try:
from ULTRA.modules.sql_helper.gmute_sql import is_gmuted
guser = await rkG.get_user()
gmuted = is_gmuted(guser.id)
except:
return
if gmuted:
for i in gmuted:
if i.sender == str(guser.id):
chat = await rkG.get_chat()
admin = chat.admin_rights
creator = chat.creator
if admin or creator:
try:
await client.edit_permissions(rkG.chat_id, guser.id, view_messages=False)
await rkG.reply(
f"**Gbanned User Joined!!** \n"
f"**Victim Id**: [{guser.id}](tg://user?id={guser.id})\n"
f"**Action ** : `Banned`")
except:
rkG.reply("`No Permission To Ban`")
return
CMD_HELP.update({
"gban":"gban any user using username or tag dont use id "})