-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
424 lines (356 loc) · 13.3 KB
/
index.js
File metadata and controls
424 lines (356 loc) · 13.3 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
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
const axios = require('axios');
const fs = require('fs');
const path = require('path');
const moment = require('moment');
const readline = require('readline');
const { clear } = require('console');
const { HttpsProxyAgent } = require('https-proxy-agent');
const { SocksProxyAgent } = require('socks-proxy-agent');
const https = require('https');
const API_BASE_URL = 'https://prod.interlinklabs.ai/api/v1';
const TOKEN_FILE_PATH = path.join(__dirname, 'token.txt');
const PROXIES_FILE_PATH = path.join(__dirname, 'proxies.txt');
const CLAIM_INTERVAL_MS = 4 * 60 * 60 * 1000;
const colors = {
green: '\x1b[32m',
yellow: '\x1b[33m',
red: '\x1b[31m',
white: '\x1b[37m',
gray: '\x1b[90m',
cyan: '\x1b[36m',
reset: '\x1b[0m',
bold: '\x1b[1m'
};
const logger = {
info: (msg) => console.log(`${colors.green}[✓] ${msg}${colors.reset}`),
wallet: (msg) => console.log(`${colors.yellow}[➤] ${msg}${colors.reset}`),
warn: (msg) => console.log(`${colors.yellow}[⚠] ${msg}${colors.reset}`),
error: (msg) => console.log(`${colors.red}[✗] ${msg}${colors.reset}`),
success: (msg) => console.log(`${colors.green}[✅] ${msg}${colors.reset}`),
loading: (msg) => console.log(`${colors.cyan}[⟳] ${msg}${colors.reset}`),
step: (msg) => console.log(`${colors.white}[➤] ${msg}${colors.reset}`),
banner: () => {
console.log(`${colors.cyan}${colors.bold}`);
console.log(`---------------------------------------------`);
console.log(`Interlink Multi Bot - cryptodai3`);
console.log(`---------------------------------------------${colors.reset}`);
console.log();
}
};
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
function promptInput(question) {
return new Promise((resolve) => {
rl.question(`${colors.white}${question}${colors.reset}`, (answer) => {
resolve(answer.trim());
});
});
}
async function sendOtp(apiClient, loginId, passcode, email) {
try {
const payload = { loginId, passcode, email };
const response = await apiClient.post('/auth/send-otp-email-verify-login', payload);
if (response.data.statusCode === 200) {
logger.success(response.data.message);
logger.info(`If OTP doesn't arrive, stop the bot (Ctrl+C) and restart.`);
} else {
logger.error(`Failed to send OTP: ${JSON.stringify(response.data)}`);
}
} catch (error) {
logger.error(`Error sending OTP: ${error.response?.data?.message || error.message}`);
if (error.response?.data) {
logger.error(`Response details: ${JSON.stringify(error.response.data)}`);
}
}
}
async function verifyOtp(apiClient, loginId, otp) {
try {
const payload = { loginId, otp };
const response = await apiClient.post('/auth/check-otp-email-verify-login', payload);
if (response.data.statusCode === 200) {
logger.success(response.data.message);
const token = response.data.data.jwtToken;
saveToken(token);
return token;
} else {
logger.error(`Failed to verify OTP: ${JSON.stringify(response.data)}`);
return null;
}
} catch (error) {
logger.error(`Error verifying OTP: ${error.response?.data?.message || error.message}`);
if (error.response?.data) {
logger.error(`Response details: ${JSON.stringify(error.response.data)}`);
}
return null;
}
}
function saveToken(token) {
try {
fs.writeFileSync(TOKEN_FILE_PATH, token);
logger.info(`Token saved to ${TOKEN_FILE_PATH}`);
} catch (error) {
logger.error(`Error saving token: ${error.message}`);
}
}
async function login(proxies) {
const loginId = await promptInput('Enter your login ID (or email): ');
const passcode = await promptInput('Enter your passcode: ');
const email = await promptInput('Enter your email: ');
let apiClient;
const proxy = getRandomProxy(proxies);
if (proxy) {
logger.step(`Attempting to send OTP with proxy: ${proxy}`);
apiClient = createApiClient(null, proxy);
} else {
logger.step(`Attempting to send OTP without proxy...`);
apiClient = createApiClient(null);
}
await sendOtp(apiClient, loginId, passcode, email);
const otp = await promptInput('Enter OTP: ');
const token = await verifyOtp(apiClient, loginId, otp);
return token;
}
function readToken() {
try {
return fs.readFileSync(TOKEN_FILE_PATH, 'utf8').trim();
} catch (error) {
logger.warn(`Token file not found or invalid. Will attempt login.`);
return null;
}
}
function readProxies() {
try {
if (!fs.existsSync(PROXIES_FILE_PATH)) {
logger.warn(`Proxies file not found. Running without proxies.`);
return [];
}
const content = fs.readFileSync(PROXIES_FILE_PATH, 'utf8');
return content.split('\n')
.map(line => line.trim())
.filter(line => line && !line.startsWith('#'));
} catch (error) {
logger.error(`Error reading proxies file: ${error.message}`);
return [];
}
}
function getRandomProxy(proxies) {
if (!proxies.length) return null;
return proxies[Math.floor(Math.random() * proxies.length)];
}
function createProxyAgent(proxyUrl) {
if (!proxyUrl) return null;
if (proxyUrl.startsWith('socks://') || proxyUrl.startsWith('socks4://') || proxyUrl.startsWith('socks5://')) {
return new SocksProxyAgent(proxyUrl);
} else {
return new HttpsProxyAgent(proxyUrl);
}
}
function createApiClient(token, proxy = null) {
const config = {
baseURL: API_BASE_URL,
headers: {
'User-Agent': 'okhttp/4.12.0',
'Accept-Encoding': 'gzip'
},
timeout: 30000,
httpsAgent: new https.Agent({
rejectUnauthorized: false
})
};
if (token) {
config.headers['Authorization'] = `Bearer ${token}`;
}
if (proxy) {
try {
const proxyAgent = createProxyAgent(proxy);
config.httpsAgent = proxyAgent;
config.proxy = false;
logger.info(`Using proxy: ${proxy}`);
} catch (error) {
logger.error(`Error setting up proxy: ${error.message}`);
}
}
return axios.create(config);
}
function formatTimeRemaining(milliseconds) {
if (milliseconds <= 0) return '00:00:00';
const seconds = Math.floor((milliseconds / 1000) % 60);
const minutes = Math.floor((milliseconds / (1000 * 60)) % 60);
const hours = Math.floor((milliseconds / (1000 * 60 * 60)) % 24);
return [hours, minutes, seconds]
.map(val => val.toString().padStart(2, '0'))
.join(':');
}
async function getCurrentUser(apiClient) {
try {
const response = await apiClient.get('/auth/current-user');
return response.data.data;
} catch (error) {
logger.error(`Error getting user information: ${error.response?.data?.message || error.message}`);
return null;
}
}
async function getTokenBalance(apiClient) {
try {
const response = await apiClient.get('/token/get-token');
return response.data.data;
} catch (error) {
logger.error(`Error getting token balance: ${error.response?.data?.message || error.message}`);
return null;
}
}
async function checkIsClaimable(apiClient) {
try {
const response = await apiClient.get('/token/check-is-claimable');
return response.data.data;
} catch (error) {
logger.error(`Error checking if airdrop is claimable: ${error.response?.data?.message || error.message}`);
return { isClaimable: false, nextFrame: Date.now() + 1000 * 60 * 5 };
}
}
async function claimAirdrop(apiClient) {
try {
const response = await apiClient.post('/token/claim-airdrop');
logger.success(`Airdrop claimed successfully!`);
return response.data;
} catch (error) {
logger.error(`Error claiming airdrop: ${error.response?.data?.message || error.message}`);
return null;
}
}
function displayUserInfo(userInfo, tokenInfo) {
if (!userInfo || !tokenInfo) return;
console.log('\n' + '='.repeat(50));
console.log(`${colors.white}${colors.bold}USER INFORMATION${colors.reset}`);
console.log(`${colors.white}Username:${colors.reset} ${userInfo.username}`);
console.log(`${colors.white}Email:${colors.reset} ${userInfo.email}`);
console.log(`${colors.white}Wallet:${colors.reset} ${userInfo.connectedAccounts?.wallet?.address || 'Not connected'}`);
console.log(`${colors.white}User ID:${colors.reset} ${userInfo.loginId}`);
console.log(`${colors.white}Referral ID:${colors.reset} ${tokenInfo.userReferralId}`);
console.log('\n' + '='.repeat(50));
console.log(`${colors.yellow}${colors.bold}TOKEN BALANCE${colors.reset}`);
console.log(`${colors.yellow}Gold Tokens:${colors.reset} ${tokenInfo.interlinkGoldTokenAmount}`);
console.log(`${colors.yellow}Silver Tokens:${colors.reset} ${tokenInfo.interlinkSilverTokenAmount}`);
console.log(`${colors.yellow}Diamond Tokens:${colors.reset} ${tokenInfo.interlinkDiamondTokenAmount}`);
console.log(`${colors.yellow}Interlink Tokens:${colors.reset} ${tokenInfo.interlinkTokenAmount}`);
console.log(`${colors.yellow}Last Claim:${colors.reset} ${moment(tokenInfo.lastClaimTime).format('YYYY-MM-DD HH:mm:ss')}`);
console.log('='.repeat(50) + '\n');
}
async function tryConnect(token, proxies) {
let apiClient;
let userInfo = null;
let tokenInfo = null;
logger.step(`Attempting connection without proxy...`);
apiClient = createApiClient(token);
logger.loading(`Retrieving user information...`);
userInfo = await getCurrentUser(apiClient);
if (!userInfo && proxies.length > 0) {
let attempts = 0;
const maxAttempts = Math.min(proxies.length, 5);
while (!userInfo && attempts < maxAttempts) {
const proxy = proxies[attempts];
logger.step(`Trying with proxy ${attempts + 1}/${maxAttempts}: ${proxy}`);
apiClient = createApiClient(token, proxy);
logger.loading(`Retrieving user information...`);
userInfo = await getCurrentUser(apiClient);
attempts++;
if (!userInfo) {
logger.warn(`Proxy ${proxy} failed. Trying next...`);
}
}
}
if (userInfo) {
logger.loading(`Retrieving token balance...`);
tokenInfo = await getTokenBalance(apiClient);
}
return { apiClient, userInfo, tokenInfo };
}
async function runBot() {
try {
clear();
logger.banner();
const proxies = readProxies();
let token = readToken();
if (!token) {
logger.step(`No token found. Initiating login...`);
token = await login(proxies);
if (!token) {
logger.error(`Login failed. Exiting.`);
process.exit(1);
}
}
let { apiClient, userInfo, tokenInfo: initialTokenInfo } = await tryConnect(token, proxies);
if (!userInfo || !initialTokenInfo) {
logger.error(`Failed to retrieve necessary information. Attempting login...`);
token = await login(proxies);
if (!token) {
logger.error(`Login failed. Exiting.`);
process.exit(1);
}
const result = await tryConnect(token, proxies);
apiClient = result.apiClient;
userInfo = result.userInfo;
initialTokenInfo = result.tokenInfo;
if (!userInfo || !initialTokenInfo) {
logger.error(`Failed to retrieve necessary information after login. Check your credentials and proxies.`);
process.exit(1);
}
}
let tokenInfo = initialTokenInfo;
logger.success(`Connected as ${userInfo.username}`);
logger.info(`Started at: ${moment().format('YYYY-MM-DD HH:mm:ss')}`);
displayUserInfo(userInfo, tokenInfo);
async function attemptClaim() {
let currentApiClient = apiClient;
if (proxies.length > 0) {
const randomProxy = getRandomProxy(proxies);
currentApiClient = createApiClient(token, randomProxy);
}
const claimCheck = await checkIsClaimable(currentApiClient);
if (claimCheck.isClaimable) {
logger.loading(`Airdrop is claimable! Attempting to claim...`);
await claimAirdrop(currentApiClient);
logger.loading(`Updating token information...`);
const newTokenInfo = await getTokenBalance(currentApiClient);
if (newTokenInfo) {
tokenInfo = newTokenInfo;
displayUserInfo(userInfo, tokenInfo);
}
}
return claimCheck.nextFrame;
}
logger.step(`Checking if airdrop is claimable...`);
let nextClaimTime = await attemptClaim();
const updateCountdown = () => {
const now = Date.now();
const timeRemaining = Math.max(0, nextClaimTime - now);
process.stdout.write(`\r${colors.white}Next claim in: ${colors.bold}${formatTimeRemaining(timeRemaining)}${colors.reset} `);
if (timeRemaining <= 0) {
process.stdout.write('\n');
logger.step(`Claim time reached!`);
attemptClaim().then(newNextFrame => {
nextClaimTime = newNextFrame;
});
}
};
setInterval(updateCountdown, 1000);
const scheduleNextCheck = () => {
const now = Date.now();
const timeUntilNextCheck = Math.max(1000, nextClaimTime - now);
setTimeout(async () => {
logger.step(`Scheduled claim time reached.`);
nextClaimTime = await attemptClaim();
scheduleNextCheck();
}, timeUntilNextCheck);
};
scheduleNextCheck();
logger.success(`Bot is running! Airdrop claims will be attempted automatically.`);
logger.info(`Press Ctrl+C to exit`);
} catch (error) {
logger.error(`Unexpected error: ${error.message}`);
process.exit(1);
}
}
runBot().finally(() => rl.close());