forked from TheTeamAlexa/VerificationBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeamAlexa.py
More file actions
335 lines (324 loc) · 13.4 KB
/
TeamAlexa.py
File metadata and controls
335 lines (324 loc) · 13.4 KB
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# TeamAlexa Verification Bot Property Of TeamAlexa
# Indian Largest Chatting Group
# Without Credit (Mother Fucker)
# TeamAlexa © @Dr_Asad_Ali © TeamAlexa
# Owner Asad + Harshit
import random
import aiohttp
import asyncio
from configs import Config
from pyrogram import Client, filters
from pyrogram.errors import UserNotParticipant
from TeamAlexa.markup_maker import MakeCaptchaMarkup
from pyrogram.types import (
InlineKeyboardMarkup,
InlineKeyboardButton,
Message,
CallbackQuery,
ChatPermissions,
)
CaptchaBot = Client(
session_name=Config.SESSION_NAME,
api_id=Config.API_ID,
api_hash=Config.API_HASH,
bot_token=Config.BOT_TOKEN,
)
CaptchaDB = {}
@CaptchaBot.on_message(filters.command("start"))
async def start_handler(_, event: Message):
await event.reply_text(
"**ʜᴇʟʟᴏ sᴡᴇᴇᴛ ʜᴇᴀʀᴛ ɪ ᴀᴍ ʀᴏᴄᴋs ᴠᴇʀɪғɪᴄᴀᴛɪᴏɴ ʙᴏᴛ ᴛᴏ ᴠᴇʀɪғʏ ᴛʜᴇ ɴᴇᴡ ɢʀᴏᴜᴘ ᴍᴇᴍʙᴇʀs ɪɴ ᴛᴇʟᴇɢʀᴀᴍ**👻\n\n**ɢɪᴠᴇ ᴍᴇ ʜᴇᴀʀᴛ** [ʟᴏᴠᴇ](https://t.me/Give_Me_Heart) [ᴊᴏɪɴ](t.me/Shayri_Music_Lovers) **ᴛʜᴀɴᴋs ғᴏʀ ᴜsɪɴɢ**.",
disable_web_page_preview=True,
)
@CaptchaBot.on_chat_member_updated()
async def welcome_handler(bot: Client, event: Message):
if (event.chat.id != Config.GROUP_CHAT_ID) or (event.from_user.is_bot is True):
return
try:
user_ = await bot.get_chat_member(event.chat.id, event.from_user.id)
if (user_.is_member is False) and (
CaptchaDB.get(event.from_user.id, None) is not None
):
try:
await bot.delete_messages(
chat_id=event.chat.id,
message_ids=CaptchaDB[event.from_user.id]["message_id"],
)
except:
pass
return
elif (user_.is_member is False) and (
CaptchaDB.get(event.from_user.id, None) is None
):
return
except UserNotParticipant:
return
try:
if CaptchaDB.get(event.from_user.id, None) is not None:
try:
await bot.send_message(
chat_id=event.chat.id,
text=f"{event.from_user.mention} 🙄 **ᴏʏᴇ ɴᴏᴏʙ ʙɪɴᴀ ᴠᴇʀɪғɪᴄᴀᴛɪᴏɴ ɢʀᴏᴜᴘ ᴊᴏɪɴ ᴋɪʏᴀ**!\n\n"
f"😜 **ʜᴇ ᴄᴀɴ ᴛʀʏ ᴀɢᴀɪɴ ᴀғᴛᴇʀ 10ᴍ**.",
disable_web_page_preview=True,
)
await bot.restrict_chat_member(
chat_id=event.chat.id,
user_id=event.from_user.id,
permissions=ChatPermissions(can_send_messages=False),
)
await bot.delete_messages(
chat_id=event.chat.id,
message_ids=CaptchaDB[event.from_user.id]["message_id"],
)
except:
pass
await asyncio.sleep(600)
del CaptchaDB[event.from_user.id]
else:
await bot.restrict_chat_member(
chat_id=event.chat.id,
user_id=event.from_user.id,
permissions=ChatPermissions(can_send_messages=False),
)
await bot.send_message(
chat_id=event.chat.id,
text=f"{event.from_user.mention}, ❤️ **ʜᴏᴡ ᴀʀᴇ ʏᴏᴜ ᴛᴏ ᴄʜᴀᴛ ʜᴇʀᴇ ᴘʟᴇᴀsᴇ ᴠɪʀɪғʏ ᴛʜᴀᴛ ʏᴏᴜ ᴀʀᴇ ɴᴏᴛ ᴀ ʙᴏᴛ**",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"ᴠᴇʀɪғʏ ɴᴏᴡ",
callback_data=f"startVerify_{str(event.from_user.id)}",
)
]
]
),
)
except:
pass
@CaptchaBot.on_callback_query()
async def buttons_handlers(bot: Client, cb: CallbackQuery):
if cb.data.startswith("startVerify_"):
__user = cb.data.split("_", 1)[-1]
if cb.from_user.id != int(__user):
await cb.answer(
"🙄 𝗧𝗵𝗶𝘀 𝗠𝗲𝘀𝘀𝗮𝗴𝗲 𝗜𝘀 𝗡𝗼𝘁 𝗙𝗼𝗿 𝗬𝗼𝘂 𝗜𝘁𝘁𝘂 🤏 𝗦𝗲𝘆 𝗡𝗼𝗼𝗯!", show_alert=True
)
return
await cb.message.edit("😏 **ɢᴇɴᴇʀᴀᴛɪɴɢ ᴄᴀᴘᴛᴄʜᴇ** ...")
print("Fetching Captcha JSON Data ...")
async with aiohttp.ClientSession() as session:
async with session.get(
f"https://api.abirhasan.wtf/captcha?token={Config.CAPTCHA_API_TOKEN}"
) as res:
if res.status != 200:
try:
UserOnChat = await bot.get_chat_member(
user_id=cb.from_user.id, chat_id=cb.message.chat.id
)
if UserOnChat.restricted_by.id == (await bot.get_me()).id:
await bot.unban_chat_member(
chat_id=cb.message.chat.id, user_id=cb.from_user.id
)
except:
pass
await cb.message.edit("😢 𝗨𝗻𝗮𝗯𝗹𝗲 𝗧𝗼 𝗚𝗲𝘁 𝗖𝗮𝗽𝘁𝗰𝗵𝗲!")
return
data = await res.json()
print("Done!")
markup = [[], [], []]
__emojis = data["CaptchaAnswer"].split(": ", 1)[-1].split()
print(__emojis)
_emojis = [
"🐻",
"🐔",
"☁️",
"🔮",
"🌀",
"🌚",
"💎",
"🐶",
"🍩",
"🌏",
"🐸",
"🌕",
"🍏",
"🐵",
"🌙",
"🐧",
"🍎",
"😀",
"🐍",
"❄️",
"🥺",
"🐢",
"🌝",
"🍺",
"🍔",
"🍒",
"🍫",
"🍡",
"🌑",
"🍟",
"☕️",
"🍑",
"🍷",
"🍧",
"🍕",
"🍵",
"🐋",
"🐱",
"💄",
"👠",
"💰",
"💸",
"🎹",
"📦",
"📍",
"🐊",
"🦕",
"🐬",
"💋",
"🦎",
"🦈",
"🦷",
"🦖",
"🐠",
"🐟",
"💀",
"🎃",
"👮",
"⛑",
"👨🔧",
"🧶",
"🧵",
"😢",
"🧥",
"🥼",
"🥻",
"🤏",
"👑",
"🎒",
"🙊",
"🐗",
"🦋",
"🦐",
"🐀",
"🐿",
"🦔",
"🦦",
"💖",
"🦡",
"🦨",
"🐇",
]
print("Cleaning Answer Emojis from Emojis List ...")
for a in range(len(__emojis)):
if __emojis[a] in _emojis:
_emojis.remove(__emojis[a])
show = __emojis
print("Appending New Emoji List ...")
for b in range(9):
show.append(_emojis[b])
print("Randomizing ...")
random.shuffle(show)
count = 0
print("Appending to ROW - 1")
for _ in range(5):
markup[0].append(
InlineKeyboardButton(
f"{show[count]}",
callback_data=f"verify_{str(cb.from_user.id)}_{show[count]}",
)
)
count += 1
print("Appending to ROW - 2")
for _ in range(5):
markup[1].append(
InlineKeyboardButton(
f"{show[count]}",
callback_data=f"verify_{str(cb.from_user.id)}_{show[count]}",
)
)
count += 1
print("Appending to ROW - 3")
for _ in range(5):
markup[2].append(
InlineKeyboardButton(
f"{show[count]}",
callback_data=f"verify_{str(cb.from_user.id)}_{show[count]}",
)
)
count += 1
print("Setting Up in Database ...")
CaptchaDB[cb.from_user.id] = {
"emojis": data["CaptchaAnswer"].split(": ", 1)[-1].split(),
"mistakes": 0,
"group_id": cb.message.chat.id,
"message_id": None,
}
print("Sending Captcha ...")
__message = await bot.send_photo(
chat_id=cb.message.chat.id,
photo=data["DownloadURL"],
caption=f"{cb.from_user.mention}, 😉 **sᴇʟᴇᴄᴛ ᴀʟʟ ᴛʜᴇ ᴇᴍᴏᴊɪᴇs ᴄᴀɴ sᴇᴇ ɪɴ ᴛʜɪs ᴘɪᴄᴛᴜʀᴇ**. "
f"🤗 **ʏᴏᴜ ᴀʀᴇ ᴀʟʟᴏᴡᴇᴅ ᴏɴʟʏ** (3) **ᴍɪsᴛᴀᴄᴋᴇs**.",
reply_markup=InlineKeyboardMarkup(markup),
)
CaptchaDB[cb.from_user.id]["message_id"] = __message.message_id
await cb.message.delete(revoke=True)
elif cb.data.startswith("verify_"):
__emoji = cb.data.rsplit("_", 1)[-1]
__user = cb.data.split("_")[1]
if cb.from_user.id != int(__user):
await cb.answer("😜 𝗨𝗹𝗼 𝗬𝗲 𝗠𝗲𝘀𝘀𝗮𝗴𝗲 𝗧𝗲𝗿𝗲 𝗟𝗶𝘆𝗲 𝗡𝗶 𝗛𝗮𝗶!", show_alert=True)
return
if cb.from_user.id not in CaptchaDB:
await cb.answer("😉 𝗧𝗿𝘆 𝗔𝗴𝗮𝗶𝗻 𝗔𝗳𝘁𝗲𝗿 𝗥𝗲_𝗝𝗼𝗶𝗻𝗶𝗻𝗴!", show_alert=True)
if __emoji not in CaptchaDB.get(cb.from_user.id).get("emojis"):
CaptchaDB[cb.from_user.id]["mistakes"] += 1
await cb.answer("🙄 𝗬𝗼𝘂 𝗣𝗿𝗲𝘀𝘀𝗲𝗱 𝗔 𝗪𝗿𝗼𝗻𝗴 𝗘𝗺𝗼𝗷𝗶!", show_alert=True)
n = 3 - CaptchaDB[cb.from_user.id]["mistakes"]
if n == 0:
await cb.message.edit_caption(
f"{cb.from_user.mention}, **😢 **ʏᴏᴜ ғᴀɪʟᴇᴅ ᴛᴏ ᴘᴀss ᴛʜᴇ ᴄᴀᴘᴛᴄʜᴇ**!\n\n"
f"❤️ **ʏᴏᴜ ᴄᴀɴ ᴛʀʏ ᴀɢᴀɪɴ ᴀғᴛᴇʀ 10ᴍ ᴏʀ ᴄᴏɴᴛᴀᴄᴛ** @Dr_Asad_Ali.",
reply_markup=None,
)
await asyncio.sleep(600)
del CaptchaDB[cb.from_user.id]
return
markup = await MakeCaptchaMarkup(
cb.message["reply_markup"]["inline_keyboard"], __emoji, "❌"
)
await cb.message.edit_caption(
caption=f"{cb.from_user.mention}, select all the emojis you can see in the picture. "
f"😜 **ʏᴏᴜ ᴀʀᴇ ᴀʟʟᴏᴡᴇᴅ ᴏɴʟʏ** ({n}) **ᴍɪsᴛᴀᴄᴋᴇs**.",
reply_markup=InlineKeyboardMarkup(markup),
)
return
else:
CaptchaDB.get(cb.from_user.id).get("emojis").remove(__emoji)
markup = await MakeCaptchaMarkup(
cb.message["reply_markup"]["inline_keyboard"], __emoji, "✅"
)
await cb.message.edit_reply_markup(
reply_markup=InlineKeyboardMarkup(markup)
)
if not CaptchaDB.get(cb.from_user.id).get("emojis"):
await cb.answer("❤️ 𝗬𝗼𝘂 𝗣𝗮𝘀𝘀𝗲𝗱 𝗧𝗵𝗲 𝗖𝗮𝗽𝘁𝗰𝗵𝗲", show_alert=True)
del CaptchaDB[cb.from_user.id]
try:
UserOnChat = await bot.get_chat_member(
user_id=cb.from_user.id, chat_id=cb.message.chat.id
)
if UserOnChat.restricted_by.id == (await bot.get_me()).id:
await bot.unban_chat_member(
chat_id=cb.message.chat.id, user_id=cb.from_user.id
)
except:
pass
await cb.message.delete(True)
await cb.answer()
CaptchaBot.run()