-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauthcode.js
82 lines (74 loc) · 2.44 KB
/
authcode.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
const axios = require('axios');
const fs = require('fs');
const path = require('path');
const data = JSON.stringify({ "authcode": " " });
const config = {
method: 'post',
url: 'https://liaobots.work/api/user',
headers: {
'Content-Type': 'application/json',
'Referer': 'https://liaobots.work/',
'Origin': 'https://liaobots.work',
'cookie': 'gkp2=YgA62VmMKGEuVwkbz2HB'
},
data: data,
responseType: 'json' // Expecting a JSON response
};
async function fetchAndStoreAuthCodes() {
while (true) {
try {
const response = await axios.request(config);
const { authCode } = response.data;
let authCodes = [];
const filePath = path.join(__dirname, 'authCodes.json');
if (fs.existsSync(filePath)) {
const fileContent = fs.readFileSync(filePath, 'utf8');
try {
const parsedContent = JSON.parse(fileContent);
if (Array.isArray(parsedContent)) {
authCodes = parsedContent;
} else {
console.error('File content is not an array, initializing with an empty array.');
}
} catch (parseError) {
console.error('Error parsing JSON from file, initializing with an empty array:', parseError.message);
}
}
authCodes.push(authCode);
fs.writeFileSync(filePath, JSON.stringify(authCodes, null, 2), 'utf8');
console.log(`AuthCode ${authCode} saved.`);
} catch (error) {
if (error.response) {
if (error.response.status === 404) {
console.log('Received 404 error, sending data to gpt.anyvm.tech.');
await sendDataToGptAnyvmTech();
break;
} else if (error.response.status === 401) {
console.log('Received 401 error, stopping.');
break;
}
} else {
console.error('Error:', error.message);
}
}
}
}
async function sendDataToGptAnyvmTech() {
const filePath = path.join(__dirname, 'authCodes.json');
if (fs.existsSync(filePath)) {
const fileContent = fs.readFileSync(filePath, 'utf8');
try {
await axios.post('https://gpt.anyvm.tech', fileContent, {
headers: {
'Content-Type': 'application/json'
}
});
console.log('Data successfully sent to gpt.anyvm.tech');
} catch (error) {
console.error('Failed to send data to gpt.anyvm.tech:', error.message);
}
} else {
console.log('authCodes.json does not exist, no data sent.');
}
}
fetchAndStoreAuthCodes();