-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.js
More file actions
87 lines (77 loc) · 2.81 KB
/
setup.js
File metadata and controls
87 lines (77 loc) · 2.81 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
const fs = require("fs");
const path = require("path");
const printLogo = require("./src/logo");
const headers = require("./src/header");
const user_agents = require("./config/userAgents");
const settings = require("./config/config");
const { loadData } = require("./utils");
class DropeeAPIClient {
constructor(queryId, accountIndex, proxy) {
this.baseUrl = "https://dropee.clicker-game-api.tropee.com/api/game";
this.headers = headers;
this.today = new Date();
this.tokenFile = path.join(__dirname, "token.json");
this.queryId = queryId;
this.accountIndex = accountIndex;
this.proxy = proxy;
this.proxyIp = "Unknown IP";
this.session_name = null;
this.session_user_agents = this.#load_session_data();
this.skipTasks = settings.SKIP_TASKS;
}
#load_session_data() {
try {
const filePath = path.join(__dirname, "session_user_agents.json");
const data = fs.readFileSync(filePath, "utf8");
return JSON.parse(data);
} catch (error) {
if (error.code === "ENOENT") {
return {};
} else {
throw error;
}
}
}
#get_random_user_agent() {
const randomIndex = Math.floor(Math.random() * user_agents.length);
return user_agents[randomIndex];
}
#get_user_agent() {
if (this.session_user_agents[this.session_name]) {
return this.session_user_agents[this.session_name];
}
this.log(`Tạo user agent...`);
const newUserAgent = this.#get_random_user_agent();
this.session_user_agents[this.session_name] = newUserAgent;
this.#save_session_data(this.session_user_agents);
return newUserAgent;
}
#save_session_data(session_user_agents) {
const filePath = path.join(__dirname, "session_user_agents.json");
fs.writeFileSync(filePath, JSON.stringify(session_user_agents, null, 2));
}
createUserAgent() {
try {
const telegramauth = this.queryId;
const userData = JSON.parse(decodeURIComponent(telegramauth.split("user=")[1].split("&")[0]));
this.session_name = userData.id;
this.#get_user_agent();
} catch (error) {
this.log(`Kiểm tra lại query_id, hoặc thay query)id mới: ${error.message}`);
}
}
}
(async function main() {
printLogo();
const queryIds = loadData("data.txt");
const proxies = loadData("proxy.txt");
if (queryIds.length > proxies.length) {
console.log("Số lượng proxy và data phải bằng nhau.".red);
console.log(`Data: ${queryIds.length}`);
console.log(`Proxy: ${proxies.length}`);
process.exit(1);
}
queryIds.map((val, i) => new DropeeAPIClient(val, i, proxies[i]).createUserAgent());
console.log(`Created user agent ${queryIds.length} accounts successfully!, Run again to start bot...`.magenta);
process.exit(0);
})();