-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathyg_whales.py
408 lines (336 loc) Β· 18.1 KB
/
yg_whales.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
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
__version__ = (1, 4, 8, 8)
# This file is a part of Hikka Userbot
# Code is NOT licensed under CC-BY-NC-ND 4.0 unless otherwise specified.
# π https://github.com/hikariatama/Hikka
# You CAN edit this file without direct permission from the author.
# You can redistribute this file with any modifications.
# meta developer: @yg_modules
# scope: hikka_only
# scope: hikka_min 1.6.3
# ββββββββββββββββββββββββ βββββββββββββββββ
# ββββββββββββββββββββββββ βββββββββββββββββ
import asyncio
from urllib.parse import unquote
from telethon.tl.functions.messages import RequestWebViewRequest
from telethon.tl.functions.channels import JoinChannelRequest
import aiohttp
from aiohttp_proxy import ProxyConnector
from aiocfscrape import CloudflareScraper
import random
import json
import os
from datetime import datetime, timedelta, timezone
from .. import loader
@loader.tds
class yg_whales(loader.Module):
"""AutoTapper and receives daily check-ins in @WheelOfWhalesBot with proxy support!"""
strings = {"name": "yg_whales"}
def __init__(self):
self.file = "WheelOfWhales.json"
self.config = loader.ModuleConfig(
loader.ConfigValue(
"logs_username",
"",
"channel/chat @username for logs (if you want to save logs to favorites, specify 'me' here; do not include @)",
validator=loader.validators.Hidden(loader.validators.String()),
),
loader.ConfigValue(
"running_on",
False,
"script status",
validator=loader.validators.Boolean()
),
loader.ConfigValue(
"autotap",
False,
"autotap status",
validator=loader.validators.Boolean()
),
loader.ConfigValue(
"user_agent",
"",
"User-Agent string (leave empty to use random User-Agent) | Find out your User-Agent - t.me/YumUserAgentBot/app",
validator=loader.validators.String()
),
loader.ConfigValue(
"proxy",
"",
"Proxy (http) settings in various formats: ip:port:user:pass, ip:port",
validator=loader.validators.String()
)
)
def load_user_agent(self):
if self.config["user_agent"]:
return self.config["user_agent"]
if os.path.exists(self.file):
with open(self.file, 'r') as f:
data = json.load(f)
return data.get("user_agent", generate_random_user_agent(self))
return generate_random_user_agent(self)
def parse_proxy(self, proxy):
if not proxy:
return None
parts = proxy.split(':')
if len(parts) == 2:
host, port = parts
return {
'type': 'http',
'host': host,
'port': port,
'user': None,
'pass': None
}
elif len(parts) == 4:
host, port, user, password = parts
return {
'type': 'http',
'host': host,
'port': port,
'user': user,
'pass': password
}
else:
return None
async def check_proxy(self, proxy_config):
if not proxy_config:
return False
proxy_url = f"{proxy_config['type']}://"
if proxy_config['user'] and proxy_config['pass']:
proxy_url += f"{proxy_config['user']}:{proxy_config['pass']}@"
proxy_url += f"{proxy_config['host']}:{proxy_config['port']}"
try:
connector = ProxyConnector().from_url(proxy_url)
async with aiohttp.ClientSession(connector=connector) as session:
async with session.get('https://httpbin.org/ip') as response:
ip = (await response.json()).get('origin')
await self.log(f"<emoji document_id=5251203410396458957>π‘</emoji> <b>Proxy IP:</b> <code>{ip}</code>")
return True
except Exception as e:
await self.log(f"<emoji document_id=5251203410396458957>π‘</emoji> <b>Proxy:</b> <code>{proxy_url}</code>\n<emoji document_id=5237927129613614048>π‘</emoji> <b>Error:</b> <code>{e}</code>")
return False
return False
async def client_ready(self, client, db):
self.client = client
proxy = self.parse_proxy(self.config["proxy"])
if proxy:
if await self.check_proxy(proxy):
if proxy['user'] and proxy['pass']:
connector = ProxyConnector().from_url(proxy['type'] + '://' + f"{proxy['user']}:{proxy['pass']}@{proxy['host']}:{proxy['port']}")
else:
connector = ProxyConnector().from_url(proxy['type'] + '://' + f"{proxy['host']}:{proxy['port']}")
self.scraper = CloudflareScraper(connector=connector, timeout=aiohttp.ClientTimeout(total=60))
else:
self.scraper = CloudflareScraper(timeout=aiohttp.ClientTimeout(total=60))
else:
self.scraper = CloudflareScraper(timeout=aiohttp.ClientTimeout(total=60))
me = await self.client.get_me()
self.user_id = me.id
self.user_agent = self.load_user_agent()
asyncio.create_task(self.wheel())
asyncio.create_task(self.clicker())
async def data(self) -> str:
web = await self.client(RequestWebViewRequest(
peer='WheelOfWhalesBot',
bot='WheelOfWhalesBot',
platform='android',
from_bot_menu=False,
url='https://clicker.crashgame247.io/'
))
url = web.url
return unquote(url.split('tgWebAppData=')[1].split('&tgWebAppVersion')[0])
async def login(self):
data_check_chain = await self.data()
params = dict(item.split('=') for item in data_check_chain.split('&'))
user_data = json.loads(unquote(params['user']))
json_data = {
"dataCheckChain": data_check_chain,
"initData": {
"query_id": params['query_id'],
"user": user_data,
"auth_date": params['auth_date'],
"hash": params['hash']
}
}
headers = {
"accept": "application/json, text/plain, */*",
"content-type": "application/json",
"accept-language": "en,en-US;q=0.9",
"priority": "u=1, i",
"sec-ch-ua": "\"Chromium\";v=\"128\", \"Not;A=Brand\";v=\"24\", \"Android WebView\";v=\"128\"",
"sec-ch-ua-mobile": "?1",
"sec-ch-ua-platform": "\"Android\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"Referer": "https://clicker.crashgame247.io/",
"Referrer-Policy": "strict-origin-when-cross-origin",
"User-Agent": self.user_agent
}
resp = await self.scraper.post("https://clicker-api.crashgame247.io/user/sync", json=json_data, headers=headers)
resp_json = await resp.json()
token = resp_json.get("token")
whitelisted = resp_json.get("user", {}).get("whitelisted")
nanoid = resp_json.get("user", {}).get("nanoid")
balance = resp_json.get("balance", {}).get("amount")
streak = resp_json.get("meta", {}).get("dailyLoginStreak")
last_login = resp_json.get("meta", {}).get("lastFirstDailyLoginAt")
return (token, whitelisted, nanoid, balance, streak, last_login)
async def claim_daily_bonus(self, token):
url = "https://clicker-api.crashgame247.io/user/bonus/claim"
headers = {
"Origin": "https://clicker.crashgame247.io",
"Referer": "https://clicker.crashgame247.io/",
"User-Agent": self.user_agent,
"Accept": "application/json, text/plain,*/*",
"Authorization": f"Bearer {token}"
}
response = await self.scraper.patch(url, headers=headers)
if response.status_code == 200:
return True
else:
try:
error_data = response.json()
await self.log(f"<emoji document_id=5237927129613614048>π‘</emoji> <b>Error when claiming the daily bonus:</b> <code>{error_data}</code>")
except json.JSONDecodeError:
await self.log(f"<emoji document_id=5237927129613614048>π‘</emoji> <b>Failed to decode error response:</b> <code>{response.text}</code>")
if response.status_code == 500:
return False
async def send_clicks(self, token, click_count):
if self.config["autotap"]:
headers = {
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,pl;q=0.6",
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
"Origin": "https://clicker.crashgame247.io",
"Referer": "https://clicker.crashgame247.io/",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"User-Agent": self.user_agent
}
clicks = {"clicks": click_count}
response = await self.scraper.put(
"https://clicker-api.crashgame247.io/meta/clicks",
headers=headers,
json=clicks
)
if response.status != 200:
await self.log(f"<emoji document_id=5237927129613614048>π‘</emoji> <b>Error:</b> <code>{response.status}</code>")
async def clicker(self):
if self.config["autotap"]:
token, whitelisted, nanoid, balance, streak, last_login = await self.login()
if not token:
return
total_clicks = 0
while total_clicks < 1000:
for _ in range(1000):
click_count = random.randint(1, 5)
await self.send_clicks(token, click_count)
total_clicks += click_count
await asyncio.sleep(random.uniform(1, 2))
if total_clicks >= 1000:
break
sleep_time = random.randint(1100, 2000)
await self.log(f"<emoji document_id=5454132901371203117>π</emoji> <code>{total_clicks}</code> <b>clicks sent, going to sleep for</b> <code>{sleep_time // 60}</code> <b>minutes.</b>")
await asyncio.sleep(sleep_time)
async def log(self, message):
if self.config["logs_username"]:
await self.client.send_message(self.config["logs_username"], message)
async def wheel(self) -> None:
while self.config["running_on"]:
try:
token, whitelisted, nanoid, balance, streak, last_login = await self.login()
if not whitelisted:
await self.log(f"<emoji document_id=5237697597971378782>π’</emoji> <b>You is not whitelisted.</b>")
return
last_login_time = datetime.strptime(last_login, "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=timezone.utc)
if datetime.now(timezone.utc) - last_login_time > timedelta(hours=24):
bonus = await self.claim_daily_bonus(token)
if bonus:
new_streak = streak + 1
await self.log(f"<emoji document_id=5235630748039394997>π₯°</emoji> <b>Daily bonus successfully claimed!</b>\n<emoji document_id=5460961680328509338>π</emoji> <b>Current streak:</b> <code>{new_streak}</code>")
except Exception as e:
await self.log(f"<emoji document_id=5237927129613614048>π‘</emoji> <b>Error in the wheel function:</b> <code>{e}</code> <i>(please report this - @yummy1gay)</i>")
await asyncio.sleep(3600)
async def bwhalescmd(self, message):
"""show your balance, current streak, next whalespin, and time remaining until the next check-in in @WheelOfWhalesBot"""
await message.edit("<emoji document_id=5215484787325676090>π</emoji> <b>Fetching information...</b>")
token, whitelisted, nanoid, balance, streak, last_login = await self.login()
if not whitelisted:
await message.edit(f"<emoji document_id=5237697597971378782>π’</emoji> <b>You is not whitelisted.</b>")
return
if last_login:
last_login_time = datetime.strptime(last_login, "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=timezone.utc)
remaining_time = last_login_time + timedelta(hours=24) - datetime.now(timezone.utc)
hours_remaining = remaining_time.total_seconds() // 3600
minutes_remaining = (remaining_time.total_seconds() % 3600) // 60
else:
hours_remaining, minutes_remaining = "0", "0"
await message.edit(f"<emoji document_id=5395643160560948786>βοΈ</emoji> <b><a href='https://t.me/wheelofwhalesbot?start={nanoid}pub'>Wheel Of Whales π³</a></b>\n\n"
f"<emoji document_id=5237708627447396243>π€</emoji> <b>Balance:</b> <code>{balance}</code>\n"
f"<emoji document_id=5235630748039394997>π₯°</emoji> <b>Current Daily-Streak:</b> <code>{streak}</code>\n"
f"<emoji document_id=5460961680328509338>π</emoji> <b>Next check-in available in:</b> <code>{int(hours_remaining)}h {int(minutes_remaining)}m</code>")
async def whalescmd(self, message):
"""on/off running script"""
self.config["running_on"] = not self.config["running_on"]
if self.config["running_on"]:
asyncio.create_task(self.wheel())
await message.edit(f"<emoji document_id=5237708627447396243>π€</emoji> <b>Script for</b> <b><a href='https://t.me/wheelofwhalesbot'>Wheel Of Whales</a></b> {'<b>on</b>' if self.config['running_on'] else '<b>off</b>'}!</b>")
async def autotapcmd(self, message):
"""on/off AutoTapper"""
self.config["autotap"] = not self.config["autotap"]
if self.config["autotap"]:
asyncio.create_task(self.clicker())
await message.edit(f"<emoji document_id=5235462501285507881>π³</emoji> <b>AutoTapper for</b> <b><a href='https://t.me/wheelofwhalesbot'>Wheel Of Whales</a></b> {'<b>on</b>' if self.config['autotap'] else '<b>off</b>'}!</b>")
def generate_random_user_agent(self, device_type='android', browser_type='chrome'):
chrome_versions = list(range(110, 127))
firefox_versions = list(range(90, 100))
if browser_type == 'chrome':
major_version = random.choice(chrome_versions)
minor_version = random.randint(0, 9)
build_version = random.randint(1000, 9999)
patch_version = random.randint(0, 99)
browser_version = f"{major_version}.{minor_version}.{build_version}.{patch_version}"
elif browser_type == 'firefox':
browser_version = random.choice(firefox_versions)
if device_type == 'android':
android_versions = ['10.0', '11.0', '12.0', '13.0']
android_device = random.choice([
'SM-G960F', 'Pixel 5', 'SM-A505F', 'Pixel 4a', 'Pixel 6 Pro',
'SM-N975F', 'SM-G973F', 'Pixel 3', 'SM-G980F', 'Pixel 5a',
'SM-G998B', 'Pixel 4', 'SM-G991B', 'SM-G996B', 'SM-F711B',
'SM-F916B', 'SM-G781B', 'SM-N986B', 'SM-N981B', 'Pixel 2',
'Pixel 2 XL', 'Pixel 3 XL', 'Pixel 4 XL', 'Pixel 5 XL',
'Pixel 6', 'Pixel 6 XL', 'Pixel 6a', 'Pixel 7', 'Pixel 7 Pro',
'OnePlus 8', 'OnePlus 8 Pro', 'OnePlus 9', 'OnePlus 9 Pro',
'OnePlus Nord', 'OnePlus Nord 2', 'OnePlus Nord CE',
'OnePlus 10', 'OnePlus 10 Pro', 'OnePlus 10T',
'OnePlus 10T Pro', 'Xiaomi Mi 9', 'Xiaomi Mi 10',
'Xiaomi Mi 11', 'Xiaomi Redmi Note 8', 'Xiaomi Redmi Note 9',
'Huawei P30', 'Huawei P40', 'Huawei Mate 30',
'Huawei Mate 40', 'Sony Xperia 1', 'Sony Xperia 5',
'LG G8', 'LG V50', 'LG V60', 'Nokia 8.3', 'Nokia 9 PureView'
])
android_version = random.choice(android_versions)
user_agent = (f"Mozilla/5.0 (Linux; Android {android_version}; {android_device}) "
f"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{browser_version} Mobile Safari/537.36")
elif device_type == 'ios':
ios_versions = ['13.0', '14.0', '15.0', '16.0']
ios_version = random.choice(ios_versions)
user_agent = (f"Mozilla/5.0 (iPhone; CPU iPhone OS {ios_version.replace('.', '_')} like Mac OS X) "
f"AppleWebKit/537.36 (KHTML, like Gecko) CriOS/{browser_version} Mobile/15E148 Safari/604.1")
elif device_type == 'windows':
windows_versions = ['10.0', '11.0']
windows_version = random.choice(windows_versions)
user_agent = (f"Mozilla/5.0 (Windows NT {windows_version}; Win64; x64) "
f"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{browser_version} Safari/537.36")
elif device_type == 'ubuntu':
user_agent = (f"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) "
f"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{browser_version} Safari/537.36")
else:
return None
with open(self.file, 'w') as f:
json.dump({"user_agent": user_agent}, f)
return user_agent