-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
486 lines (410 loc) · 17.5 KB
/
index.js
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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
import scheduleNextRun from "./schedule.js";
import { readFileSync } from "fs";
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";
import { SocksProxyAgent } from "socks-proxy-agent";
import UserAgentManager from "./userAgentManager.js";
const userAgentManager = new UserAgentManager();
const keywords = JSON.parse(readFileSync("./keyword.json", "utf-8"));
const randomDelay = () => Math.random() * 3000 + 1000;
///////////////////////////////////////// Config //////////////////////////////////////////////////
const config = {
attempts: 5, // Number of times the door is opened per cycle (1-10)
rewardInKeys: true, // false - get points, true - get keys in KnockGame
minPoints: 159, // Minimum number of points to win in KnockGame (1-398)
maxPoints: 400, // Maximum number of points to win in KnockGame (1-400)
processTasksEnabled: true, //Option to enable - true /disable - false task processing
baseUrl: "https://nordomgate-back-gua0c3cgh0aneacq.z02.azurefd.net/api/v1",
dataFile: "data.txt",
proxyFile: "proxy.txt",
taskToSkip: [
"Boost our Telegram channel",
"Join us on Telegram",
"Complete tasks in Earn section",
"Join Whale TG Channel",
"Start farming in BlockBits",
], // List of tasks to skip, tasks that can only be performed manually
};
///////////////////////////////////////////////////////////////////////////////////////////////////
const colors = {
reset: "\x1b[0m",
bright: "\x1b[1m",
red: "\x1b[31m",
green: "\x1b[32m",
yellow: "\x1b[33m",
blue: "\x1b[34m",
magenta: "\x1b[35m",
cyan: "\x1b[36m",
};
function loadData() {
try {
const data = readFileSync(config.dataFile, "utf8");
return data
.split("\n")
.map((line) => line.trim())
.filter((line) => line);
} catch (error) {
console.log(`${colors.red}Error loading data file: ${error}${colors.reset}`);
return [];
}
}
function loadProxies() {
try {
const data = readFileSync(config.proxyFile, "utf8");
return data.split("\n").filter((line) => line.trim());
} catch (error) {
console.log(`${colors.red}Error loading proxy file: ${error}${colors.reset}`);
return [];
}
}
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
function createAxiosInstance(telegramData, proxyUrl = null, userAgent = null) {
const axiosConfig = {
baseURL: config.baseUrl,
headers: {
"X-Telegram-Init-Data": telegramData,
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0",
},
};
if (userAgent) {
axiosConfig.headers["User-Agent"] = userAgent;
}
if (proxyUrl) {
if (proxyUrl.startsWith("socks4://") || proxyUrl.startsWith("socks5://")) {
axiosConfig.httpsAgent = new SocksProxyAgent(proxyUrl);
} else {
axiosConfig.httpsAgent = new HttpsProxyAgent(proxyUrl);
}
}
return axios.create(axiosConfig);
}
async function makeRequest(axiosInstance, url, method = "GET", data = null) {
try {
const response = await axiosInstance({
method,
url,
data,
});
await sleep(randomDelay());
return response.data;
} catch (error) {
console.log(`${colors.red}Request error: ${error.message}${colors.reset}`);
if (error.response) {
console.log(`${colors.red}Status: ${error.response.status}${colors.reset}`);
console.log(`${colors.red}Data: ${JSON.stringify(error.response.data)}${colors.reset}`);
}
return null;
}
}
async function checkin(axiosInstance) {
console.log(`${colors.blue}Checking in...${colors.reset}`);
return await makeRequest(axiosInstance, "/users/checkin", "POST");
}
async function claimStreak(axiosInstance) {
console.log(`${colors.blue}Claiming streak...${colors.reset}`);
return await makeRequest(axiosInstance, "/streak/claim", "POST");
}
async function getDashboard(axiosInstance) {
console.log(`${colors.blue}Getting dashboard...${colors.reset}`);
return await makeRequest(axiosInstance, "/dashboard");
}
async function getTasks(axiosInstance, source) {
console.log(`${colors.blue}Getting ${source} tasks...${colors.reset}`);
return await makeRequest(axiosInstance, `/tasks/by-source?taskSource=${source}`);
}
async function startTask(axiosInstance, taskId, name) {
console.log(`${colors.yellow}Starting task ${name}...${colors.reset}`);
return await makeRequest(axiosInstance, `/tasks/start/${taskId}`, "POST");
}
async function verifyTask(axiosInstance, name, payload = null) {
console.log(`${colors.green}Verifying task ${name}...${colors.reset}`);
return await makeRequest(axiosInstance, `tasks/verify`, "POST", payload);
}
async function claimTask(axiosInstance, taskId, name, payload = null) {
console.log(`${colors.green}Claiming task ${name}...${colors.reset}`);
return await makeRequest(axiosInstance, `/tasks/claim/${taskId}`, "POST", payload);
}
async function selectDoor(axiosInstance, door) {
console.log(`${colors.magenta}Selecting ${door} door...${colors.reset}`);
return await makeRequest(axiosInstance, `/nordgate/select/${door}`, "POST");
}
async function riskPoints(axiosInstance) {
console.log(`${colors.yellow}Risking points...${colors.reset}`);
return await makeRequest(axiosInstance, "/nordgate/risk", "POST");
}
async function claimPoints(axiosInstance) {
console.log(`${colors.green}Claiming points...${colors.reset}`);
return await makeRequest(axiosInstance, "/nordgate/claim", "POST");
}
async function startKnockGame(axiosInstance) {
console.log(`${colors.green}Starting knock game...${colors.reset}`);
return await makeRequest(axiosInstance, "/knockgame/start", "POST");
}
async function infoWheelGame(axiosInstance) {
console.log(`${colors.green}Getting info for wheel game...${colors.reset}`);
return await makeRequest(axiosInstance, "/wheel");
}
async function claimFreeSpinWheelGame(axiosInstance) {
console.log(`${colors.green}Claiming wheel game spin...${colors.reset}`);
return await makeRequest(axiosInstance, "/wheel/claim-spin", "POST");
}
async function spinWheelGame(axiosInstance) {
console.log(`${colors.green}Spinning wheel game...${colors.reset}`);
return await makeRequest(axiosInstance, "/wheel/spin", "POST");
}
async function claimRewardWheelGame(axiosInstance) {
console.log(`${colors.green}Claiming wheel game reward...${colors.reset}`);
return await makeRequest(axiosInstance, "/wheel/claim-reward", "POST");
}
async function claimKnockGamePoints(axiosInstance) {
console.log(`${colors.green}Claiming knock game points...${colors.reset}`);
return await makeRequest(
axiosInstance,
`/knockgame/claim/${randomPoints()}?rewardInKeys=${config.rewardInKeys}`,
"PUT"
);
}
async function getGameCenter(axiosInstance) {
console.log(`${colors.blue}Getting game center...${colors.reset}`);
return await makeRequest(axiosInstance, "/gamecenter");
}
function randomPoints() {
const points = Math.floor(Math.random() * (config.maxPoints - config.minPoints + 1)) + config.minPoints;
console.log(
`${colors.green}Knock game points: ${points} | ${config.rewardInKeys ? "get Keys" : "get Points"} ${
colors.reset
}`
);
return points;
}
async function processKnockGame(axiosInstance, gameCenter) {
await startKnockGame(axiosInstance);
console.log(`${colors.yellow}Waiting 10 seconds...${colors.reset}`);
await sleep(10 * 1000);
await claimKnockGamePoints(axiosInstance);
}
async function processTasks(axiosInstance) {
let taskProcessed = false;
const erroredTasks = new Set();
while (true) {
const tasksNordom = await getTasks(axiosInstance, "nordom");
if (!tasksNordom || !tasksNordom.data) {
console.log(`${colors.red}No tasks data found.${colors.reset}`);
return false;
}
const tasksActivity = await getTasks(axiosInstance, "activity");
if (!tasksActivity || !tasksActivity.data) {
console.log(`${colors.red}No tasks data found.${colors.reset}`);
return false;
}
const tasksPartner = await getTasks(axiosInstance, "partner");
if (!tasksPartner || !tasksPartner.data) {
console.log(`${colors.red}No tasks data found.${colors.reset}`);
return false;
}
let tasksToProcess = [
...tasksNordom.data.news,
...tasksNordom.data.recurring,
...tasksNordom.data.standard,
...tasksActivity.data.news,
...tasksActivity.data.recurring,
...tasksActivity.data.standard,
...tasksPartner.data.news,
...tasksPartner.data.recurring,
...tasksPartner.data.standard,
].filter((task) => !erroredTasks.has(task.id));
console.log(`${colors.yellow}Tasks to process: ${tasksToProcess.length}${colors.reset}`);
let currentTaskProcessed = false;
for (const task of tasksToProcess) {
if (config.taskToSkip.includes(task.name)) {
erroredTasks.add(task.id);
continue;
}
if (task.type === "keyword" && !availableKey(task.id)) {
console.log(`${colors.yellow}Skipping keyword task: ${task.name}${colors.reset}`);
continue;
}
try {
if (task.status === "notStarted") {
await startTask(axiosInstance, task.id, task.name);
currentTaskProcessed = true;
} else if (
task.type === "keyword" &&
task.status === "inProgress" &&
task.currentLevel >= task.maxLevel
) {
await verifyTask(axiosInstance, task.name, setupPayload(task));
currentTaskProcessed = true;
} else if (task.status === "completed") {
await claimTask(axiosInstance, task.id, task.name, setupPayload(task));
currentTaskProcessed = true;
}
} catch (error) {
console.log(`${colors.red}Error processing task ${task.id}: ${error.message}${colors.reset}`);
erroredTasks.add(task.id);
}
}
if (!currentTaskProcessed) {
console.log(`${colors.green}All tasks have been processed or no further tasks available!${colors.reset}`);
break;
}
taskProcessed = taskProcessed || currentTaskProcessed;
await sleep(randomDelay());
}
return taskProcessed;
}
function availableKey(taskId) {
return Object.keys(keywords).includes(taskId);
}
function setupPayload(task) {
if (task.type === "keyword") {
return {
taskId: task.id,
keyword: keywords[task.id],
};
} else {
return null;
}
}
async function processWheelGame(axiosInstance, gameCenter) {
await claimFreeSpinWheelGame(axiosInstance);
console.log(`${colors.green}Wheel game free spin claimed!${colors.reset}`);
let info = await infoWheelGame(axiosInstance);
while (info.data.spins > 0) {
try {
const spinResult = await spinWheelGame(axiosInstance);
console.log(
`${colors.magenta}Wheel game spin completed! Earned ${spinResult.data.type} = ${spinResult.data.quantity} ${colors.reset}`
);
await sleep(randomDelay() + 5000);
try {
await claimRewardWheelGame(axiosInstance);
console.log(`${colors.green}Wheel game reward claimed!${colors.reset}`);
} catch (error) {
console.log(`${colors.red}Error claiming wheel game reward: ${error.errorMessage}${colors.reset}`);
}
info = await infoWheelGame(axiosInstance);
console.log(`${colors.yellow}Wheel game spins remaining: ${info.data.spins}${colors.reset}`);
} catch (error) {
console.log(`${colors.red}Error spinning wheel game: ${error.errorMessage}${colors.reset}`);
}
}
}
let winCount = 0;
async function playGameSession(axiosInstance) {
const doors = ["first", "second", "third"];
let userName = "";
let sessionActive = true;
let totalWins = 0;
let totalLosses = 0;
const checkinResult = await checkin(axiosInstance);
if (checkinResult.data.firstLoginOfDay) {
await claimStreak(axiosInstance);
console.log(`${colors.green}Streak day ${checkinResult.data.dayStreak.dayStreak}!${colors.reset}`);
await processWheelGame(axiosInstance);
await processKnockGame(axiosInstance);
}
while (sessionActive) {
const dashboard = await getDashboard(axiosInstance);
if (!dashboard || !dashboard.data) return;
userName = dashboard.data.userName;
if (dashboard.data.nordGateGame.levelToRisk != null) {
await claimPoints(axiosInstance);
continue;
}
let keys = dashboard.data.nordGateGame.key;
console.log(`${colors.cyan}Available keys: ${keys}${colors.reset}`);
if (keys === 0) {
if (config.processTasksEnabled) {
console.log(`${colors.yellow}No keys available. Processing tasks...${colors.reset}`);
const tasksProcessed = await processTasks(axiosInstance);
if (!tasksProcessed) {
console.log(`${colors.yellow}No more tasks available. Session ended.${colors.reset}`);
break;
}
} else {
console.log(`${colors.yellow}Task processing is disabled. Skipping task processing.${colors.reset}`);
break;
}
continue;
}
console.log(`${colors.bright}\nStarting new game cycle${colors.reset}`);
console.log(`${colors.cyan}Total wins: ${totalWins}, Total losses: ${totalLosses}${colors.reset}`);
let currentLevel = 1;
let cycleActive = true;
while (cycleActive && keys > 0) {
const doorIndex = Math.floor(Math.random() * 3);
const result = await selectDoor(axiosInstance, doors[doorIndex]);
if (!result || !result.data) {
cycleActive = false;
continue;
}
if (result.data.result === "win") {
totalWins++;
winCount++;
keys = result.data.currentStateDto.key;
console.log(`${colors.green}Won! Level: ${result.data.currentStateDto.currentLevel}${colors.reset}`);
console.log(`${colors.green}Points: ${result.data.currentStateDto.accumulatedPoint}${colors.reset}`);
if (winCount >= config.attempts) {
await claimPoints(axiosInstance);
cycleActive = false;
winCount = 0;
} else if (result.data.currentStateDto.currentLevel < result.data.currentStateDto.maxLevel) {
await riskPoints(axiosInstance);
currentLevel++;
} else {
await claimPoints(axiosInstance);
cycleActive = false;
}
} else {
totalLosses++;
winCount = 0;
keys = result.data.currentStateDto.key;
console.log(`${colors.green}Lost! Starting new cycle...${colors.reset}`);
cycleActive = false;
}
}
if (keys === 0) {
if (config.processTasksEnabled) {
const tasksProcessed = await processTasks(axiosInstance);
if (!tasksProcessed) {
console.log(`${colors.yellow}No more tasks and keys available. Session ended.${colors.reset}`);
sessionActive = false;
}
} else {
console.log(`${colors.yellow}Task processing is disabled. Session ended.${colors.reset}`);
sessionActive = false;
}
}
}
console.log(`${colors.bright}\n${userName} Session Statistics:${colors.reset}`);
console.log(`${colors.green}Total wins: ${totalWins}${colors.reset}`);
console.log(`${colors.red}Total losses: ${totalLosses}${colors.reset}`);
console.log(
`${colors.cyan}Win rate: ${((totalWins / (totalWins + totalLosses)) * 100).toFixed(2)}%${colors.reset}`
);
}
async function main() {
const telegramData = loadData();
const proxies = loadProxies();
for (let i = 0; i < telegramData.length; i++) {
const proxyUrl = i < proxies.length ? proxies[i] : null;
const userAgent = userAgentManager.getUserAgent(telegramData[i]);
const axiosInstance = createAxiosInstance(telegramData[i], proxyUrl, userAgent);
console.log(`${colors.bright}\nStarting session ${i + 1}/${telegramData.length}${colors.reset}`);
console.log(`${colors.bright}Using proxy: ${proxyUrl || "none"}${colors.reset}`);
try {
await playGameSession(axiosInstance);
} catch (error) {
console.log(`${colors.red}Session error: ${error.message}${colors.reset}`);
}
}
scheduleNextRun(3, main);
}
process.on("unhandledRejection", (error) => {
console.log(`${colors.red}Unhandled rejection: ${error.message}${colors.reset}`);
});
main().catch((error) => {
console.log(`${colors.red}Fatal error: ${error.message}${colors.reset}`);
});