-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecks.py
255 lines (232 loc) · 12.3 KB
/
checks.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
248
249
250
251
252
253
254
255
import asyncio
import contextlib
from concurrent.futures import ThreadPoolExecutor
import regex as re
from telethon import events
from telethon.tl.functions.channels import JoinChannelRequest
from telethon.tl.functions.messages import ImportChatInviteRequest
from telethon.extensions import markdown
from telethon import types
from userbot import client
import pytesseract
from PIL import Image
import io
info = {'category': 'tools', 'pattern': '.checks', 'description': 'Статус ловца чеков'}
class ChecksModule:
def __init__(self):
"""
Initializes the attributes of the class instance, including client, channel_id, auto_withdraw, withdraw_to, auto_unfollow, anti_captcha, code_regex, url_regex, public_regex, custom_emoji, profit, replace_chars, translation, executor, crypto_black_list, checks, max_checks, channels, captches, and checks_count. Also calls the register_handlers function.
"""
self.client = client
self.channel_id = -1111111111
self.auto_withdraw = False
self.withdraw_to = 'ваш_тег'
self.auto_unfollow = True
self.anti_captcha = True
self.code_regex = re.compile(r"t\.me/(CryptoBot|send|tonRocketBot|wallet|xrocket|xJetSwapBot|torwalletbot)\?start=(CQ[A-Za-z0-9]{10}|C-[A-Za-z0-9]{10}|t_[A-Za-z0-9]{15}|mci_[A-Za-z0-9]{15}|c_[a-z0-9]{24}|[A-Za-z0-9]{10})", re.IGNORECASE)
self.url_regex = re.compile(r"https:\/\/t\.me\/\+(\w{12,})")
self.public_regex = re.compile(r"https:\/\/t\.me\/(\w{4,})")
self.custom_emoji = {
'CryptoBot': '<emoji id=5388654252337931124>👛</emoji>',
'send': '<emoji id=5388654252337931124>👛</emoji>',
'tonRocketBot': '<emoji id=5235575317191474172>🚀</emoji>',
'wallet': '<emoji id=5388812380148866813>👛</emoji>',
'xrocket': '<emoji id=5235575317191474172>🚀</emoji>'
}
self.profit = ['Вы получили ', 'Вы обналичили чек на сумму:']
self.replace_chars = ''' @#&+()*"'…;,!№•—–·±<{>}†★‡„“”«»‚‘’‹›¡¿‽~`|√π÷ק∆\\°^%©®™✓₤$₼€₸₾₶฿₳₥₦₫₿¤₲₩₮¥₽₻₷₱₧£₨¢₠₣₢₺₵₡₹₴₯₰₪'''
self.translation = str.maketrans('', '', self.replace_chars)
self.executor = ThreadPoolExecutor(max_workers=5)
self.crypto_black_list = [1622808649, 1559501630, 1985737506, 5014831088, 6014729293, 5794061503, 6314389409]
self.checks = set()
self.max_checks = 100
self.channels = []
self.captches = []
self.checks_count = 0
self.register_handlers()
def register_handlers(self) -> None:
"""
Registers various event handlers for the client.
"""
self.client.add_event_handler(self.func_checks, events.NewMessage(outgoing=True, pattern=r'^\.checks$'))
self.client.add_event_handler(self.handle_wallet, events.NewMessage(chats=[1985737506], pattern="⚠️ Вы не можете активировать этот чек, так как вы не являетесь подписчиком канала"))
self.client.add_event_handler(self.handle_cryptobot, events.NewMessage(chats=[1559501630, 1622808649], pattern="Чтобы"))
self.client.add_event_handler(self.handle_xrocket, events.NewMessage(chats=[5014831088], pattern="Для активации чека"))
self.client.add_event_handler(self.handle_info, events.NewMessage(chats=self.crypto_black_list, func=self.filter))
self.client.add_event_handler(self.handle_info, events.MessageEdited(chats=self.crypto_black_list, func=self.filter))
self.client.add_event_handler(self.handle_grabber, events.MessageEdited(outgoing=False, chats=self.crypto_black_list, blacklist_chats=True))
self.client.add_event_handler(self.handle_grabber, events.NewMessage(outgoing=False, chats=self.crypto_black_list, blacklist_chats=True))
if self.anti_captcha:
self.client.add_event_handler(self.handle_photo_message, events.NewMessage(chats=[1559501630], func=lambda e: e.photo))
if self.auto_withdraw:
self.withdraw()
def ocr_tesseract(self, file: bytes, language='eng') -> str:
"""
Perform OCR using Tesseract on the provided image file.
"""
loop = asyncio.get_running_loop()
return loop.run_in_executor(self.executor, pytesseract.image_to_string, Image.open(io.BytesIO(file)), lang=language)
async def func_checks(self, event) -> None:
"""
An asynchronous function that performs checks on an event.
"""
await event.edit(f"<emoji id=5345992170388070686>😍</emoji> <b>FULL WORK</b>\n\n<emoji id=5370956427277903406>😋</emoji> <b>Успешно активировано:</b> <code>{self.checks_count}</code>")
async def withdraw(self) -> None:
"""
Asynchronously withdraws funds.
"""
while True:
await asyncio.sleep(86400)
await self.client.send_message('CryptoBot', message='/wallet')
await asyncio.sleep(0.1)
messages = await self.client.get_messages('CryptoBot', limit=1)
message = messages[0].message
lines = message.split('\n\n')
for line in lines:
if ':' in line:
if 'Доступно' in line:
data = line.split('\n')[2].split('Доступно: ')[1].split(' (')[0].split(' ')
else:
data = line.split(': ')[1].split(' (')[0].split(' ')
curency, summ = data[1], data[0]
try:
if summ == '0':
continue
result = (await self.client.inline_query('send', f'{summ} {curency}'))[0]
if 'Создать чек' in result.title:
await result.click(self.withdraw_to)
except Exception:
pass
async def handle_wallet(self, event) -> None:
"""
Handle the wallet event.
"""
code = None
try:
for row in event.message.reply_markup.rows:
for button in row.buttons:
try:
check = self.code_regex.search(button.url)
if check:
code = check.group(2)
channel = self.url_regex.search(button.url)
public_channel = self.public_regex.search(button.url)
if channel:
await self.client(ImportChatInviteRequest(channel.group(1)))
if public_channel:
await self.client(JoinChannelRequest(public_channel.group(1)))
except Exception:
pass
except AttributeError:
pass
if code not in self.checks:
await self.client.send_message('wallet', message=f'/start {code}')
self.checks.add(code)
async def handle_cryptobot(self, event) -> None:
"""
Asynchronously handles the cryptobot event.
"""
try:
for row in event.message.reply_markup.rows:
for button in row.buttons:
try:
channel = self.url_regex.search(button.url)
if channel:
await self.client(ImportChatInviteRequest(channel.group(1)))
except Exception:
pass
except AttributeError:
pass
await event.message.click(data=b'check-subscribe')
async def handle_xrocket(self, event) -> None:
"""
Asynchronously handles the 'xrocket' event.
"""
try:
for row in event.message.reply_markup.rows:
for button in row.buttons:
try:
channel = self.url_regex.search(button.url)
public_channel = self.public_regex.search(button.url)
if channel:
await self.client(ImportChatInviteRequest(channel.group(1)))
if public_channel:
await self.client(JoinChannelRequest(public_channel.group(1)))
except Exception:
pass
except AttributeError:
pass
await event.message.click(data=b'Check')
async def filter(self, event) -> bool:
"""
Filter the event based on the presence of certain words in the message text.
"""
return any(
word in event.message.text and 'отзыв' not in event.message.text and 'пополнение' not in event.message.text
for word in self.profit
)
async def handle_info(self, event) -> None:
"""
Handles the "info" event.
"""
try:
bot = (await self.client.get_entity(event.message.peer_id.user_id))
if bot.usernames:
username = bot.usernames[0]
else:
username = bot.username
except AttributeError:
username = bot.username
summ = event.raw_text
for i in self.profit:
summ = summ.replace(i, '')
self.checks_count += 1
emoji = self.custom_emoji[username] if username in self.custom_emoji else '<emoji id=5463046637842608206>🪙</emoji>'
await self.client.send_message(self.channel_id,
message=f'{emoji} <b>Активирован чек на сумму:</b> <code>{summ}</code>\n\n'
f'<b>Бот:</b> @{username}\n'
f'<b>Всего чеков после запуска активировано:</b> <code>{self.checks_count}</code>\n',
)
async def handle_grabber(self, event) -> None:
"""
Asynchronously handles the grabber event.
"""
message_text = event.message.text.translate(self.translation)
if codes := self.code_regex.findall(message_text):
for bot_name, code in codes:
if code not in self.checks:
await self.client.send_message(bot_name, message=f'/start {code}')
self.checks.add(code)
if len(self.checks) > self.max_checks:
self.checks.pop()
with contextlib.suppress(AttributeError):
for row in event.message.reply_markup.rows:
for button in row.buttons:
with contextlib.suppress(AttributeError):
matches = self.code_regex.findall(button.url)
for match in matches:
bot_name, code = match[0], match[1]
if code not in self.checks:
await self.client.send_message(bot_name, message=f'/start {code}')
self.checks.add(code)
if len(self.checks) > self.max_checks:
self.checks.pop()
async def handle_photo_message(self, event) -> None:
"""
Handles a photo message event.
"""
photo = await event.download_media(bytes)
recognized_text = await self.ocr_tesseract(file=photo)
if recognized_text and recognized_text not in self.captches:
await self.client.send_message('CryptoBot', message=recognized_text)
await asyncio.sleep(0.1)
message = (await self.client.get_messages('CryptoBot', limit=1))[0].message
if 'Incorrect answer.' in message or 'Неверный ответ.' in message:
await self.client.send_message(
self.channel_id,
message='<b>❌ Не удалось разгадать капчу, решите ее сами.</b>',
)
print('[!] Ошибка антикаптчи > Не удалось разгадать каптчу, решите ее сами.')
self.captches.append(recognized_text)
print(f'[$] Антикаптча подключена!')
checks = ChecksModule()