fca-shankar-bot 20.2.0 → 20.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.replit +14 -1
- package/Extra/Balancer.js +49 -0
- package/Extra/ExtraAddons.js +4 -4
- package/Extra/ExtraGetThread.js +27 -27
- package/Extra/ExtraScreenShot.js +3 -3
- package/Extra/ExtraUptimeRobot.js +4 -4
- package/Extra/Src/Change_Environment.js +2 -2
- package/Extra/Src/Check_Update.js +3 -3
- package/Extra/Src/Instant_Update.js +2 -2
- package/Extra/Src/Premium.js +7 -7
- package/Extra/Src/Release_Memory.js +7 -7
- package/Extra/Src/Websocket.js +12 -12
- package/Func/ClearCache.js +2 -2
- package/LICENSE +21 -0
- package/Language/index.json +22 -16
- package/Main.js +515 -349
- package/README.md +198 -0
- package/SECURITY.md +17 -0
- package/broadcast.js +44 -0
- package/index.js +215 -31
- package/logger.js +51 -122
- package/package.json +17 -15
- package/src/Dev_Horizon_Data.js +2 -2
- package/src/editMessage.js +45 -38
- package/src/listenMqtt.js +395 -373
- package/src/listenMqttV1.js +11 -11
- package/src/sendMessage.js +2 -2
- package/src/sendMqttMessage.js +51 -251
- package/src/setMessageReaction.js +64 -66
- package/src/shareContact.js +50 -75
- package/src/unsendMessage.js +32 -126
- package/src/unsendMqttMessage.js +66 -0
- package/test/data/shareAttach.js +146 -0
- package/test/data/something.mov +0 -0
- package/test/data/test.png +0 -0
- package/test/data/test.txt +7 -0
- package/test/example-config.json +18 -0
- package/test/test-page.js +140 -0
- package/test/test.js +385 -0
- package/test/testv2.js +3 -0
- package/utils.js +50 -11
- package/.cache/replit/env/latest +0 -49
- package/.cache/replit/env/latest.json +0 -1
- package/.cache/replit/modules/nodejs-20.res +0 -1
- package/.cache/replit/modules/replit.res +0 -1
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/replit/toolchain.json +0 -1
- package/CountTime.json +0 -1
- package/src/followUser.js +0 -171
- package/src/getFacebookInfo.js +0 -69
- package/src/listenMqtt.jk +0 -732
- package/src/postStory.js +0 -122
- package/src/refreshFb_dtsg.js +0 -81
package/Main.js
CHANGED
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
//-[ Require config and use ]-!/
|
4
4
|
|
5
|
-
if (global.Fca.Require.
|
5
|
+
if (global.Fca.Require.Shankar.Config != 'default') {
|
6
6
|
//do ssth
|
7
7
|
}
|
8
|
-
|
9
|
-
const Language = global.Fca.Require.languageFile.find((/** @type {{ Language: string; }} */i) => i.Language == global.Fca.Require.
|
8
|
+
|
9
|
+
const Language = global.Fca.Require.languageFile.find((/** @type {{ Language: string; }} */i) => i.Language == global.Fca.Require.Shankar.Language).Folder.Index;
|
10
|
+
|
10
11
|
//-[ Require All Package Need Use ]-!/
|
11
12
|
|
12
13
|
var utils = global.Fca.Require.utils,
|
@@ -29,7 +30,6 @@ var utils = global.Fca.Require.utils,
|
|
29
30
|
ws = require('ws'),
|
30
31
|
Websocket = require('./Extra/Src/Websocket'),
|
31
32
|
Convert = require('ansi-to-html');
|
32
|
-
|
33
33
|
|
34
34
|
//-[ Set Variable For Process ]-!/
|
35
35
|
|
@@ -37,78 +37,6 @@ log.maxRecordSize = 100;
|
|
37
37
|
var checkVerified = null;
|
38
38
|
const Boolean_Option = ['online','selfListen','listenEvents','updatePresence','forceLogin','autoMarkDelivery','autoMarkRead','listenTyping','autoReconnect','emitReady'];
|
39
39
|
|
40
|
-
//-[ Set And Check Template HTML ]-!/
|
41
|
-
|
42
|
-
const css = readFileSync(join(__dirname, 'Extra', 'Html', 'Classic', 'style.css'));
|
43
|
-
const js = readFileSync(join(__dirname, 'Extra', 'Html', 'Classic', 'script.js'));
|
44
|
-
|
45
|
-
//-[ Function Generate HTML Template ]-!/
|
46
|
-
|
47
|
-
/**
|
48
|
-
* It returns a string of HTML code.
|
49
|
-
* @param UserName - The username of the user
|
50
|
-
* @param Type - The type of user, either "Free" or "Premium"
|
51
|
-
* @param link - The link to the music you want to play
|
52
|
-
* @returns A HTML file
|
53
|
-
*/
|
54
|
-
|
55
|
-
function ClassicHTML(UserName,Type,link) {
|
56
|
-
return `<!DOCTYPE html>
|
57
|
-
<html lang="en" >
|
58
|
-
<head>
|
59
|
-
<meta charset="UTF-8">
|
60
|
-
<title>Shankar</title>
|
61
|
-
<link rel="stylesheet" href="./style.css">
|
62
|
-
</head>
|
63
|
-
<body>
|
64
|
-
<center>
|
65
|
-
<marquee><b>waiting for u :d</b></marquee>
|
66
|
-
<h2>Shankar User Infomation</h2>
|
67
|
-
<h3>UserName: ${UserName} | Type: ${Type}</h3>
|
68
|
-
<canvas id="myCanvas"></canvas>
|
69
|
-
<script src="./script.js"></script>
|
70
|
-
<footer class="footer">
|
71
|
-
<div id="music">
|
72
|
-
<audio autoplay="false" controls="true" loop="true" src="${link}" __idm_id__="5070849">Your browser does not support the audio element.</audio>
|
73
|
-
<br><b>Session ID:</b> ${global.Fca.Require.Security.create().uuid}<br>
|
74
|
-
<br>Thanks For Using <b>fca-shankar-bot</b> - From <b>Kanzu</b> <3<br>
|
75
|
-
</div>
|
76
|
-
</footer>
|
77
|
-
</div>
|
78
|
-
</center>
|
79
|
-
</html>
|
80
|
-
</body>`
|
81
|
-
//lazy to change
|
82
|
-
}
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
//-[ Stating Http Infomation ]-!/
|
87
|
-
|
88
|
-
express.set('DFP', (process.env.PORT || process.env.port || 80));
|
89
|
-
|
90
|
-
express.use(function(req, res, next) {
|
91
|
-
switch (req.url.split('?')[0]) {
|
92
|
-
case '/script.js': {
|
93
|
-
res.writeHead(200, { 'Content-Type': 'text/javascript' });
|
94
|
-
res.write(js);
|
95
|
-
break;
|
96
|
-
}
|
97
|
-
case '/style.css': {
|
98
|
-
res.writeHead(200, { 'Content-Type': 'text/css' });
|
99
|
-
res.write(css);
|
100
|
-
break;
|
101
|
-
}
|
102
|
-
default: {
|
103
|
-
res.writeHead(200, "OK", { "Content-Type": "text/html" });
|
104
|
-
res.write(ClassicHTML(global.Fca.Require.ShankarConfig.HTML.UserName, "Premium Access", global.Fca.Require.ShankarConfig.HTML.MusicLink));
|
105
|
-
}
|
106
|
-
}
|
107
|
-
res.end();
|
108
|
-
})
|
109
|
-
var Server;
|
110
|
-
if (global.Fca.Require.ShankarConfig.HTML.HTML) Server= express.listen(express.get('DFP'));
|
111
|
-
|
112
40
|
function setOptions(globalOptions, options) {
|
113
41
|
Object.keys(options).map(function(key) {
|
114
42
|
switch (Boolean_Option.includes(key)) {
|
@@ -162,228 +90,315 @@ function setOptions(globalOptions, options) {
|
|
162
90
|
});
|
163
91
|
}
|
164
92
|
|
165
|
-
function
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
}
|
174
|
-
match = html.match(/{"token":"([^"]+)","async_get_token"/);
|
175
|
-
if (match) {
|
176
|
-
logger.Normal("Found fb_dtsg in async_get_token pattern");
|
177
|
-
return match[1];
|
93
|
+
function BypassAutomationNotification(resp, jar, globalOptions, appstate,ID) {
|
94
|
+
global.Fca.BypassAutomationNotification = BypassAutomationNotification
|
95
|
+
try {
|
96
|
+
let UID;
|
97
|
+
if (ID) UID = ID
|
98
|
+
else {
|
99
|
+
UID = (appstate.find(i => i.key == 'c_user') || appstate.find(i => i.key == 'i_user'))
|
100
|
+
UID = UID.value;
|
178
101
|
}
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
102
|
+
if (resp !== undefined) {
|
103
|
+
if (resp.request.uri && resp.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
|
104
|
+
if (resp.request.uri.href.includes('601051028565049')) {
|
105
|
+
const fb_dtsg = utils.getFrom(resp.body, '["DTSGInitData",[],{"token":"', '","');
|
106
|
+
const jazoest = utils.getFrom(resp.body, 'jazoest=', '",');
|
107
|
+
const lsd = utils.getFrom(resp.body, "[\"LSD\",[],{\"token\":\"", "\"}");
|
108
|
+
|
109
|
+
const FormBypass = {
|
110
|
+
av: UID,
|
111
|
+
fb_dtsg, jazoest, lsd,
|
112
|
+
fb_api_caller_class: "RelayModern",
|
113
|
+
fb_api_req_friendly_name: "FBScrapingWarningMutation",
|
114
|
+
variables: JSON.stringify({}),
|
115
|
+
server_timestamps: true,
|
116
|
+
doc_id: 6339492849481770
|
117
|
+
}
|
118
|
+
return utils.post("https://www.facebook.com/api/graphql/", jar, FormBypass, globalOptions)
|
119
|
+
.then(utils.saveCookies(jar)).then(function(res) {
|
120
|
+
global.Fca.Require.logger.Warning(global.Fca.Require.Language.Index.Bypass_AutoNoti);
|
121
|
+
return process.exit(1);
|
122
|
+
});
|
123
|
+
}
|
124
|
+
else {
|
125
|
+
return resp;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
else {
|
129
|
+
return resp
|
130
|
+
}
|
183
131
|
}
|
132
|
+
else {
|
133
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(function(res) {
|
134
|
+
if (res.request.uri && res.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
|
135
|
+
if (res.request.uri.href.includes('601051028565049')) return { Status: true, Body: res.body }
|
136
|
+
else return { Status: false, Body: res.body }
|
137
|
+
}
|
138
|
+
else return { Status: false, Body: res.body }
|
139
|
+
}).then(function(res) {
|
140
|
+
if (res.Status === true) {
|
141
|
+
const fb_dtsg = utils.getFrom(res.Body, '["DTSGInitData",[],{"token":"', '","');
|
142
|
+
const jazoest = utils.getFrom(res.Body, 'jazoest=', '",');
|
143
|
+
const lsd = utils.getFrom(res.Body, "[\"LSD\",[],{\"token\":\"", "\"}");
|
144
|
+
|
145
|
+
const FormBypass = {
|
146
|
+
av: UID,
|
147
|
+
fb_dtsg, jazoest, lsd,
|
148
|
+
fb_api_caller_class: "RelayModern",
|
149
|
+
fb_api_req_friendly_name: "FBScrapingWarningMutation",
|
150
|
+
variables: JSON.stringify({}),
|
151
|
+
server_timestamps: true,
|
152
|
+
doc_id: 6339492849481770
|
153
|
+
}
|
154
|
+
return utils.post("https://www.facebook.com/api/graphql/", jar, FormBypass, globalOptions).then(utils.saveCookies(jar))
|
155
|
+
.then(res => {
|
156
|
+
global.Fca.Require.logger.Warning(global.Fca.Require.Language.Index.Bypass_AutoNoti);
|
157
|
+
return res
|
158
|
+
})
|
159
|
+
}
|
160
|
+
else return res;
|
184
161
|
|
185
|
-
|
186
|
-
|
162
|
+
})
|
163
|
+
.then(function(res) {
|
164
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar))
|
165
|
+
})
|
166
|
+
.then(function(res) {
|
167
|
+
return process.exit(1)
|
168
|
+
})
|
169
|
+
}
|
187
170
|
}
|
171
|
+
catch (e) {
|
172
|
+
console.log(e)
|
173
|
+
}
|
174
|
+
}
|
188
175
|
|
189
|
-
|
190
|
-
irisSeqID = (html.match(/irisSeqID":"([^"]+)"/) || [])[1];
|
191
|
-
|
192
|
-
if (fb_dtsg) logger.Normal("Process OnLogin");
|
176
|
+
//-[ Function BuildAPI ]-!/
|
193
177
|
|
194
|
-
|
195
|
-
|
196
|
-
|
178
|
+
/**
|
179
|
+
* @param {any} globalOptions
|
180
|
+
* @param {string} html
|
181
|
+
* @param {{ getCookies: (arg0: string) => any[]; }} jar
|
182
|
+
*/
|
197
183
|
|
198
|
-
|
199
|
-
|
184
|
+
function buildAPI(globalOptions, html, jar, bypass_region) {
|
185
|
+
//new feat
|
186
|
+
const fb_dtsg = utils.getFroms(html, '["DTSGInitData",[],{"token":"', '","')[0]; //nhăm nhăm nhăm nhăm
|
187
|
+
|
188
|
+
//check tiktik
|
189
|
+
var userID;
|
190
|
+
var cookie = jar.getCookies("https://www.facebook.com");
|
191
|
+
//.log(cookie)
|
192
|
+
var maybeUser = cookie.filter(function(val) { return val.cookieString().split("=")[0] === "c_user"; });
|
193
|
+
var maybeTiktik = cookie.filter(function(val) { return val.cookieString().split("=")[0] === "i_user"; });
|
194
|
+
if (maybeUser.length === 0 && maybeTiktik.length === 0) {
|
195
|
+
if (global.Fca.Require.Shankar.AutoLogin) {
|
200
196
|
return global.Fca.Require.logger.Warning(global.Fca.Require.Language.Index.AutoLogin, function() {
|
201
|
-
global.Fca.Action('AutoLogin')
|
197
|
+
global.Fca.Action('AutoLogin')
|
202
198
|
});
|
203
|
-
}
|
199
|
+
}
|
200
|
+
else if (!global.Fca.Require.Shankar.AutoLogin) {
|
204
201
|
return global.Fca.Require.logger.Error(global.Fca.Require.Language.Index.ErrAppState);
|
205
202
|
}
|
206
203
|
}
|
204
|
+
else {
|
205
|
+
if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", Language.CheckPointLevelI);
|
207
206
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
const endpointMatch = html.match(/"endpoint":"([^"]+)"/);
|
213
|
-
if (endpointMatch) {
|
214
|
-
mqttEndpoint = endpointMatch[1].replace(/\\\//g, '/');
|
215
|
-
const url = new URL(mqttEndpoint);
|
216
|
-
region = url.searchParams.get('region')?.toUpperCase() || "PRN";
|
217
|
-
|
218
|
-
logger.Normal(`MQTT Region: ${region}`);
|
219
|
-
|
220
|
-
if (endpointMatch.input.includes("601051028565049")) {
|
221
|
-
logger.Warning("The account has been caught by the auto system!");
|
222
|
-
needWarningHandle = true;
|
207
|
+
if (maybeTiktik[0] && maybeTiktik[0].cookieString().includes('i_user')) {
|
208
|
+
userID = maybeTiktik[0].cookieString().split("=")[1].toString();
|
209
|
+
|
223
210
|
}
|
224
|
-
|
225
|
-
|
226
|
-
mqttEndpoint = `wss://edge-chat.facebook.com/chat?region=prn&sid=${userID}`;
|
227
|
-
region = "PRN";
|
228
|
-
}
|
229
|
-
|
230
|
-
var ctx = {
|
231
|
-
userID,
|
232
|
-
jar,
|
233
|
-
clientID: utils.getGUID(),
|
234
|
-
globalOptions,
|
235
|
-
loggedIn: true,
|
236
|
-
access_token: 'NONE',
|
237
|
-
clientMutationId: 0,
|
238
|
-
mqttClient: undefined,
|
239
|
-
lastSeqId: irisSeqID,
|
240
|
-
syncToken: undefined,
|
241
|
-
mqttEndpoint,
|
242
|
-
region,
|
243
|
-
firstListen: true,
|
244
|
-
fb_dtsg,
|
245
|
-
req_ID: 0,
|
246
|
-
lastPresence: Date.now(),
|
247
|
-
debug: false
|
248
|
-
};
|
211
|
+
else userID = maybeUser[0].cookieString().split("=")[1].toString();
|
212
|
+
process.env['UID'] = logger.Normal(getText(Language.UID,userID), userID);
|
249
213
|
|
250
|
-
var defaultFuncs = utils.makeDefaults(html, userID, ctx);
|
251
|
-
|
252
|
-
async function clearWarning(retries = 0) {
|
253
214
|
try {
|
254
|
-
|
255
|
-
av: userID,
|
256
|
-
fb_api_caller_class: "RelayModern",
|
257
|
-
fb_api_req_friendly_name: "FBScrapingWarningMutation",
|
258
|
-
doc_id: "6339492849481770",
|
259
|
-
variables: JSON.stringify({}),
|
260
|
-
server_timestamps: true,
|
261
|
-
fb_dtsg: ctx.fb_dtsg
|
262
|
-
};
|
263
|
-
|
264
|
-
const res = await defaultFuncs.post("https://www.facebook.com/api/graphql/", jar, form, globalOptions);
|
265
|
-
const data = JSON.parse(res.body);
|
266
|
-
|
267
|
-
if (data.data?.fb_scraping_warning_clear?.success) {
|
268
|
-
logger.Normal("Successfully handled the account warning!");
|
269
|
-
logger.Normal("Restarting the bot...");
|
270
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
271
|
-
const { execSync } = require('child_process');
|
272
|
-
execSync('node index.js', {
|
273
|
-
stdio: 'inherit'
|
274
|
-
});
|
275
|
-
process.exit(1);
|
276
|
-
}
|
277
|
-
|
278
|
-
if (retries < 2) {
|
279
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
280
|
-
return await clearWarning(retries + 1);
|
281
|
-
}
|
282
|
-
|
283
|
-
return false;
|
284
|
-
|
215
|
+
clearInterval(checkVerified);
|
285
216
|
} catch (e) {
|
286
|
-
|
287
|
-
return false;
|
217
|
+
console.log(e);
|
288
218
|
}
|
289
|
-
}
|
290
219
|
|
291
|
-
|
292
|
-
setOptions: setOptions.bind(null, globalOptions),
|
293
|
-
getAppState: () => utils.getAppState(jar),
|
294
|
-
|
295
|
-
refreshDTSG: async function() {
|
296
|
-
try {
|
297
|
-
const res = await defaultFuncs.get('https://www.facebook.com/settings', jar, null, globalOptions);
|
298
|
-
let newDtsg = null;
|
220
|
+
var clientID = (Math.random() * 2147483648 | 0).toString(16);
|
299
221
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
222
|
+
var CHECK_MQTT = {
|
223
|
+
oldFBMQTTMatch: html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/),
|
224
|
+
newFBMQTTMatch: html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/),
|
225
|
+
legacyFBMQTTMatch: html.match(/\["MqttWebConfig",\[\],{"fbid":"(.*?)","appID":219994525426954,"endpoint":"(.*?)","pollingEndpoint":"(.*?)"/)
|
226
|
+
}
|
305
227
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
228
|
+
// tổng hợp danh sách region never die của Kanzu =))
|
229
|
+
/**
|
230
|
+
* PRN = Pacific Northwest Region (Khu vực Tây Bắc Thái Bình Dương)
|
231
|
+
* VLL = Valley Region
|
232
|
+
* ASH = Ashburn Region
|
233
|
+
* DFW = Dallas/Fort Worth Region
|
234
|
+
* LLA = Los Angeles Region
|
235
|
+
* FRA = Frankfurt
|
236
|
+
* SIN = Singapore
|
237
|
+
* NRT = Tokyo (Japan)
|
238
|
+
* HKG = Hong Kong
|
239
|
+
* SYD = Sydney
|
240
|
+
*/
|
241
|
+
|
242
|
+
let Slot = Object.keys(CHECK_MQTT);
|
243
|
+
var mqttEndpoint,region,irisSeqID;
|
244
|
+
Object.keys(CHECK_MQTT).map(function(MQTT) {
|
245
|
+
if (CHECK_MQTT[MQTT] && !region) {
|
246
|
+
switch (Slot.indexOf(MQTT)) {
|
247
|
+
case 0: {
|
248
|
+
irisSeqID = CHECK_MQTT[MQTT][1];
|
249
|
+
mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/");
|
250
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
251
|
+
return;
|
311
252
|
}
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
253
|
+
case 1: {
|
254
|
+
irisSeqID = CHECK_MQTT[MQTT][2];
|
255
|
+
mqttEndpoint = CHECK_MQTT[MQTT][1].replace(/\\\//g, "/");
|
256
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
257
|
+
return;
|
258
|
+
}
|
259
|
+
case 2: {
|
260
|
+
mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/"); //is important lmao f?
|
261
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
262
|
+
return;
|
319
263
|
}
|
320
264
|
}
|
321
|
-
|
322
|
-
if (!newDtsg) {
|
323
|
-
logger.Warning("Failed to refresh fb_dtsg - no pattern matched");
|
324
|
-
return ctx.fb_dtsg;
|
325
|
-
}
|
326
|
-
|
327
|
-
logger.Normal("Successfully refreshed fb_dtsg");
|
328
|
-
ctx.fb_dtsg = newDtsg;
|
329
|
-
return newDtsg;
|
330
|
-
|
331
|
-
} catch (error) {
|
332
|
-
logger.Warning("Error while refreshing fb_dtsg:", error.message);
|
333
|
-
return ctx.fb_dtsg;
|
265
|
+
return;
|
334
266
|
}
|
335
|
-
}
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
267
|
+
});
|
268
|
+
|
269
|
+
const regions = [
|
270
|
+
{
|
271
|
+
code: "PRN",
|
272
|
+
name: "Pacific Northwest Region",
|
273
|
+
location: "Khu vực Tây Bắc Thái Bình Dương"
|
274
|
+
},
|
275
|
+
{
|
276
|
+
code: "VLL",
|
277
|
+
name: "Valley Region",
|
278
|
+
location: "Valley"
|
279
|
+
},
|
280
|
+
{
|
281
|
+
code: "ASH",
|
282
|
+
name: "Ashburn Region",
|
283
|
+
location: "Ashburn"
|
284
|
+
},
|
285
|
+
{
|
286
|
+
code: "DFW",
|
287
|
+
name: "Dallas/Fort Worth Region",
|
288
|
+
location: "Dallas/Fort Worth"
|
289
|
+
},
|
290
|
+
{
|
291
|
+
code: "LLA",
|
292
|
+
name: "Los Angeles Region",
|
293
|
+
location: "Los Angeles"
|
294
|
+
},
|
295
|
+
{
|
296
|
+
code: "FRA",
|
297
|
+
name: "Frankfurt",
|
298
|
+
location: "Frankfurt"
|
299
|
+
},
|
300
|
+
{
|
301
|
+
code: "SIN",
|
302
|
+
name: "Singapore",
|
303
|
+
location: "Singapore"
|
304
|
+
},
|
305
|
+
{
|
306
|
+
code: "NRT",
|
307
|
+
name: "Tokyo",
|
308
|
+
location: "Japan"
|
309
|
+
},
|
310
|
+
{
|
311
|
+
code: "HKG",
|
312
|
+
name: "Hong Kong",
|
313
|
+
location: "Hong Kong"
|
314
|
+
},
|
315
|
+
{
|
316
|
+
code: "SYD",
|
317
|
+
name: "Sydney",
|
318
|
+
location: "Sydney"
|
319
|
+
},
|
320
|
+
{
|
321
|
+
code: "PNB",
|
322
|
+
name: "Pacific Northwest - Beta",
|
323
|
+
location: "Pacific Northwest "
|
340
324
|
}
|
325
|
+
];
|
341
326
|
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
327
|
+
if (!region) {
|
328
|
+
region = ['prn',"pnb","vll","hkg","sin"][Math.random()*5|0];
|
329
|
+
|
330
|
+
}
|
331
|
+
if (!mqttEndpoint) {
|
332
|
+
mqttEndpoint = "wss://edge-chat.facebook.com/chat?region=" + region;
|
333
|
+
}
|
334
|
+
|
335
|
+
const Location = regions.find(r => r.code === region.toUpperCase());
|
336
|
+
logger.Normal(getText(Language.Area,(Location == undefined ? region.toUpperCase() : Location.name)));
|
337
|
+
|
338
|
+
var ctx = {
|
339
|
+
userID: userID,
|
340
|
+
jar: jar,
|
341
|
+
clientID: clientID,
|
342
|
+
globalOptions: globalOptions,
|
343
|
+
loggedIn: true,
|
344
|
+
access_token: 'NONE',
|
345
|
+
clientMutationId: 0,
|
346
|
+
mqttClient: undefined,
|
347
|
+
lastSeqId: irisSeqID,
|
348
|
+
syncToken: undefined,
|
349
|
+
mqttEndpoint: mqttEndpoint,
|
350
|
+
region: region,
|
351
|
+
firstListen: true,
|
352
|
+
req_ID: 0,
|
353
|
+
callback_Task: {},
|
354
|
+
fb_dtsg //i love u
|
355
|
+
};
|
353
356
|
|
354
|
-
|
355
|
-
|
357
|
+
var api = {
|
358
|
+
setOptions: setOptions.bind(null, globalOptions),
|
359
|
+
getAppState: function getAppState() {
|
360
|
+
return utils.getAppState(jar);
|
361
|
+
}
|
362
|
+
};
|
363
|
+
if (region && mqttEndpoint) {
|
364
|
+
//do sth
|
365
|
+
}
|
366
|
+
else {
|
367
|
+
if (bypass_region) {
|
368
|
+
logger.Normal(Language.NoAreaDataBypass);
|
369
|
+
}
|
370
|
+
else {
|
371
|
+
log.warn("login", getText(Language.NoAreaData));
|
372
|
+
api["htmlData"] = html;
|
356
373
|
}
|
357
|
-
},
|
358
|
-
|
359
|
-
postFormData: function(url, body) {
|
360
|
-
return defaultFuncs.postFormData(url, ctx.jar, body);
|
361
|
-
},
|
362
|
-
|
363
|
-
clearWarning: async function() {
|
364
|
-
return await clearWarning();
|
365
374
|
}
|
366
|
-
};
|
367
375
|
|
368
|
-
|
369
|
-
clearWarning().catch(e => logger.Warning("Unable to handle the warning:", e));
|
370
|
-
}
|
376
|
+
var defaultFuncs = utils.makeDefaults(html, userID, ctx);
|
371
377
|
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
const name = f.split('.')[0];
|
376
|
-
if ((f === 'getThreadInfo.js' && !global.Fca.Require.ShankarConfig.AntiGetInfo.AntiGetThreadInfo) ||
|
377
|
-
(f === 'getUserInfo.js' && !global.Fca.Require.ShankarConfig.AntiGetInfo.AntiGetUserInfo)) {
|
378
|
-
api[name] = require(`./src/${f.includes('getThreadInfo') ? 'getThreadMain.js' : 'getUserInfoMain.js'}`)(defaultFuncs, api, ctx);
|
379
|
-
} else {
|
380
|
-
api[name] = require(`./src/${f}`)(defaultFuncs, api, ctx);
|
381
|
-
}
|
378
|
+
fs.readdirSync(__dirname + "/src").filter((/** @type {string} */File) => File.endsWith(".js") && !File.includes('Dev_')).map((/** @type {string} */File) => {
|
379
|
+
if (File == 'getThreadInfo.js' && global.Fca.Require.Shankar.AntiGetInfo.AntiGetThreadInfo != true || File == 'getUserInfo.js' && global.Fca.Require.Shankar.AntiGetInfo.AntiGetUserInfo != true) api[File.split('.').slice(0, -1).join('.')] = require('./src/' + (File.includes('getThreadInfo') ? 'getThreadMain.js' : 'getUserInfoMain.js'))(defaultFuncs, api, ctx)
|
380
|
+
else api[File.split('.').slice(0, -1).join('.')] = require('./src/' + File)(defaultFuncs, api, ctx)
|
382
381
|
});
|
383
382
|
|
384
|
-
|
383
|
+
return {
|
384
|
+
ctx,
|
385
|
+
defaultFuncs,
|
386
|
+
api
|
387
|
+
};
|
388
|
+
}
|
385
389
|
}
|
386
390
|
|
391
|
+
//-[ Function makeLogin ]-!/
|
392
|
+
|
393
|
+
/**
|
394
|
+
* @param {{ setCookie: (arg0: any, arg1: string) => void; }} jar
|
395
|
+
* @param {any} email
|
396
|
+
* @param {any} password
|
397
|
+
* @param {{ forceLogin: any; }} loginOptions
|
398
|
+
* @param {(err: any, api: any) => any} callback
|
399
|
+
* @param {any} prCallback
|
400
|
+
*/
|
401
|
+
|
387
402
|
function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
388
403
|
return function(res) {
|
389
404
|
var html = res.body,$ = cheerio.load(html),arr = [];
|
@@ -406,6 +421,8 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
406
421
|
html.split("\"_js_").slice(1).map((val) => {
|
407
422
|
jar.setCookie(utils.formatCookie(JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]"), "facebook"),"https://www.facebook.com")
|
408
423
|
});
|
424
|
+
|
425
|
+
logger.Normal(Language.OnLogin);
|
409
426
|
return utils
|
410
427
|
.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
|
411
428
|
.then(utils.saveCookies(jar))
|
@@ -445,7 +462,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
445
462
|
dpr: 1
|
446
463
|
});
|
447
464
|
}, 2500);
|
448
|
-
switch (global.Fca.Require.
|
465
|
+
switch (global.Fca.Require.Shankar.Login2Fa) {
|
449
466
|
case true: {
|
450
467
|
const question = question => {
|
451
468
|
const rl = readline.createInterface({
|
@@ -554,7 +571,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
554
571
|
Database().delete('Through2Fa');
|
555
572
|
}
|
556
573
|
const Otp_code = require('totp-generator');
|
557
|
-
const Code = global.Fca.Require.
|
574
|
+
const Code = global.Fca.Require.Shankar.AuthString.includes('|') == false ? Otp_code(global.Fca.Require.Shankar.AuthString.includes(" ") ? global.Fca.Require.Shankar.AuthString.replace(RegExp(" ", 'g'), "") : global.Fca.Require.Shankar.AuthString) : question(Language.EnterSecurityCode);
|
558
575
|
try {
|
559
576
|
const approvals = function(N_Code) {
|
560
577
|
form.approvals_code = N_Code;
|
@@ -800,13 +817,24 @@ function backup(data,globalOptions, callback, prCallback) {
|
|
800
817
|
}
|
801
818
|
}
|
802
819
|
|
820
|
+
//-[ function loginHelper ]-!/
|
821
|
+
|
822
|
+
/**
|
823
|
+
* @param {string | any[]} appState
|
824
|
+
* @param {any} email
|
825
|
+
* @param {any} password
|
826
|
+
* @param {{ selfListen?: boolean; listenEvents?: boolean; listenTyping?: boolean; updatePresence?: boolean; forceLogin?: boolean; autoMarkDelivery?: boolean; autoMarkRead?: boolean; autoReconnect?: boolean; logRecordSize?: number; online?: boolean; emitReady?: boolean; userAgent?: string; pageID?: any; }} globalOptions
|
827
|
+
* @param {(arg0: any, arg1: undefined) => void} callback
|
828
|
+
* @param {(error: any, api: any) => any} [prCallback]
|
829
|
+
*/
|
830
|
+
|
803
831
|
function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
|
804
832
|
var mainPromise = null;
|
805
833
|
var jar = utils.getJar();
|
806
834
|
|
807
|
-
|
808
|
-
|
809
|
-
|
835
|
+
try {
|
836
|
+
if (appState) {
|
837
|
+
logger.Normal(Language.OnProcess);
|
810
838
|
switch (Database().has("FBKEY")) {
|
811
839
|
case true: {
|
812
840
|
process.env.FBKEY = Database().get("FBKEY");
|
@@ -825,7 +853,7 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
|
|
825
853
|
}
|
826
854
|
}
|
827
855
|
try {
|
828
|
-
switch (global.Fca.Require.
|
856
|
+
switch (global.Fca.Require.Shankar.EncryptFeature) {
|
829
857
|
case true: {
|
830
858
|
appState = JSON.parse(JSON.stringify(appState, null, "\t"));
|
831
859
|
switch (utils.getType(appState)) {
|
@@ -883,7 +911,7 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
|
|
883
911
|
}
|
884
912
|
break;
|
885
913
|
default: {
|
886
|
-
logger.Warning(getText(Language.IsNotABoolean,global.Fca.Require.
|
914
|
+
logger.Warning(getText(Language.IsNotABoolean,global.Fca.Require.Shankar.EncryptFeature))
|
887
915
|
process.exit(0);
|
888
916
|
}
|
889
917
|
}
|
@@ -892,102 +920,159 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
|
|
892
920
|
console.log(e);
|
893
921
|
}
|
894
922
|
|
923
|
+
try {
|
924
|
+
appState = JSON.parse(appState);
|
925
|
+
}
|
926
|
+
catch (e) {
|
895
927
|
try {
|
896
|
-
appState =
|
928
|
+
appState = appState;
|
897
929
|
}
|
898
930
|
catch (e) {
|
899
|
-
|
900
|
-
appState = appState;
|
901
|
-
}
|
902
|
-
catch (e) {
|
903
|
-
return logger.Error();
|
904
|
-
}
|
931
|
+
return logger.Error();
|
905
932
|
}
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
appState.map(function(c) {
|
933
|
+
}
|
934
|
+
try {
|
935
|
+
global.Fca.Data.AppState = appState;
|
936
|
+
appState.map(function(/** @type {{ key: string; value: string; expires: string; domain: string; path: string; }} */c) {
|
910
937
|
var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
|
911
938
|
jar.setCookie(str, "http://" + c.domain);
|
912
939
|
});
|
913
940
|
Database().set('Backup', appState);
|
914
|
-
|
915
|
-
|
916
|
-
|
941
|
+
mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
|
942
|
+
}
|
943
|
+
catch (e) {
|
944
|
+
try {
|
917
945
|
if (Database().has('Backup')) {
|
918
|
-
return backup(Database().get('Backup'),
|
946
|
+
return backup(Database().get('Backup'),globalOptions, callback, prCallback);
|
919
947
|
}
|
920
948
|
else {
|
921
949
|
logger.Warning(Language.ErrBackup);
|
922
950
|
process.exit(0);
|
923
951
|
}
|
924
952
|
}
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
953
|
+
catch (e) {
|
954
|
+
logger.Warning(Language.ErrBackup);
|
955
|
+
process.exit(0);
|
956
|
+
}
|
957
|
+
}
|
958
|
+
}
|
959
|
+
|
960
|
+
else {
|
961
|
+
mainPromise = utils
|
962
|
+
.get("https://www.facebook.com/Lazic.Kanzu", null, null, globalOptions, { noRef: true }) // for fixing
|
963
|
+
.then(utils.saveCookies(jar))
|
964
|
+
.then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
|
965
|
+
.then(function() {
|
966
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
|
967
|
+
});
|
934
968
|
}
|
935
969
|
} catch (e) {
|
936
970
|
console.log(e);
|
937
971
|
}
|
938
972
|
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
973
|
+
function CheckAndFixErr(res, fastSwitch) {
|
974
|
+
if (fastSwitch) return res;
|
975
|
+
let reg_antierr = /7431627028261359627/gs; // =))))))
|
976
|
+
if (reg_antierr.test(res.body)) {
|
977
|
+
const Data = JSON.stringify(res.body);
|
978
|
+
const Dt_Check = Data.split('2Fhome.php&gfid=')[1];
|
979
|
+
if (Dt_Check == undefined) return res
|
980
|
+
const fid = Dt_Check.split("\\\\")[0];//fix sau
|
981
|
+
if (Dt_Check == undefined || Dt_Check == "") return res
|
982
|
+
const final_fid = fid.split(`\\`)[0];
|
983
|
+
if (final_fid == undefined || final_fid == '') return res;
|
984
|
+
const redirectlink = redirect[1] + "a/preferences.php?basic_site_devices=m_basic&uri=" + encodeURIComponent("https://m.facebook.com/home.php") + "&gfid=" + final_fid;
|
985
|
+
bypass_region_err = true;
|
986
|
+
return utils.get(redirectlink, jar, null, globalOptions).then(utils.saveCookies(jar));
|
945
987
|
}
|
946
|
-
return res
|
988
|
+
else return res
|
947
989
|
}
|
948
990
|
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
.
|
953
|
-
|
954
|
-
|
955
|
-
globalOptions.userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36";
|
956
|
-
return utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
|
957
|
-
}
|
958
|
-
return res;
|
959
|
-
})
|
960
|
-
.then(handleRedirect)
|
961
|
-
.then(function(res) {
|
962
|
-
var html = res.body;
|
963
|
-
var Obj = buildAPI(globalOptions, html, jar);
|
964
|
-
ctx = Obj.ctx;
|
965
|
-
api = Obj.api;
|
966
|
-
return res;
|
967
|
-
});
|
968
|
-
|
969
|
-
if (globalOptions.pageID) {
|
970
|
-
mainPromise = mainPromise
|
971
|
-
.then(function() {
|
972
|
-
return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
|
973
|
-
})
|
974
|
-
.then(function(resData) {
|
975
|
-
var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
|
976
|
-
url = url.substring(0, url.length - 1);
|
977
|
-
return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
|
978
|
-
});
|
991
|
+
function Redirect(res,fastSwitch) {
|
992
|
+
if (fastSwitch) return res;
|
993
|
+
var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
|
994
|
+
redirect = reg.exec(res.body);
|
995
|
+
if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions)
|
996
|
+
return res;
|
979
997
|
}
|
980
998
|
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
999
|
+
let redirect = [1, "https://m.facebook.com/"];
|
1000
|
+
let bypass_region_err = false;
|
1001
|
+
var ctx,api;
|
1002
|
+
mainPromise = mainPromise
|
1003
|
+
.then(res => Redirect(res))
|
1004
|
+
.then(res => CheckAndFixErr(res))
|
1005
|
+
//fix via login with defaut UA return WWW.facebook.com not m.facebook.com
|
1006
|
+
.then(function(res) {
|
1007
|
+
if (global.OnAutoLoginProcess) return res;
|
1008
|
+
else {
|
1009
|
+
let Regex_Via = /MPageLoadClientMetrics/gs; //default for normal account, can easily get region, without this u can't get region in some case but u can run normal
|
1010
|
+
if (!Regex_Via.test(res.body)) {
|
1011
|
+
//www.facebook.com
|
1012
|
+
globalOptions.userAgent = "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.2849.68";
|
1013
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true })
|
1014
|
+
}
|
1015
|
+
else return res
|
1016
|
+
}
|
1017
|
+
})
|
1018
|
+
.then(res => BypassAutomationNotification(res, jar, globalOptions, appState))
|
1019
|
+
.then(res => Redirect(res, global.OnAutoLoginProcess))
|
1020
|
+
.then(res => CheckAndFixErr(res, global.OnAutoLoginProcess))
|
1021
|
+
// .then(res => {
|
1022
|
+
// return utils.get('https://www.facebook.com/', jar, null, globalOptions, {}).then(utils.saveCookies(jar));
|
1023
|
+
// })
|
1024
|
+
// .then(function(res) {
|
1025
|
+
// let reg_old_web = /Switch Default Site/gs;
|
1026
|
+
// if (reg_old_web.test(res.body)) {
|
1027
|
+
// let Data_Resp = JSON.stringify(res.body);
|
1028
|
+
// const link = Data_Resp.split('settings/site')[1].split("\"")[0].replace('\\', '')
|
1029
|
+
// const redirect_link2 = redirect[1] + "settings/site" + utils.cleanHTML(link)
|
1030
|
+
// console.log(redirect_link2)
|
1031
|
+
// return utils.get("https://www.facebook.com/", jar, null, globalOptions).then(utils.saveCookies(jar)); // try ag
|
1032
|
+
// }
|
1033
|
+
// else return res;
|
1034
|
+
// })
|
1035
|
+
// .then(function(res) {
|
1036
|
+
// var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
|
1037
|
+
// redirect = reg.exec(res.body);
|
1038
|
+
// if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
|
1039
|
+
// return res;
|
1040
|
+
// })
|
1041
|
+
.then(function(res){
|
1042
|
+
var html = res.body,Obj = buildAPI(globalOptions, html, jar,bypass_region_err);
|
1043
|
+
ctx = Obj.ctx;
|
1044
|
+
api = Obj.api;
|
1045
|
+
return res;
|
1046
|
+
});
|
1047
|
+
if (globalOptions.pageID) {
|
1048
|
+
mainPromise = mainPromise
|
1049
|
+
.then(function() {
|
1050
|
+
return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
|
1051
|
+
})
|
1052
|
+
.then(function(resData) {
|
1053
|
+
var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
|
1054
|
+
url = url.substring(0, url.length - 1);
|
1055
|
+
return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
|
1056
|
+
});
|
1057
|
+
}
|
1058
|
+
mainPromise
|
1059
|
+
.then(async() => {
|
1060
|
+
logger.Normal(getText(Language.LocalVersion,global.Fca.Version));
|
1061
|
+
logger.Normal(getText(Language.CountTime,global.Fca.Data.CountTime()))
|
1062
|
+
logger.Normal(Language.WishMessage[Math.floor(Math.random()*Language.WishMessage.length)]);
|
1063
|
+
require('./Extra/ExtraUptimeRobot')();
|
1064
|
+
callback(null, api);
|
1065
|
+
}).catch(function(/** @type {{ error: any; }} */e) {
|
986
1066
|
log.error("login", e.error || e);
|
987
|
-
|
988
|
-
|
1067
|
+
callback(e);
|
1068
|
+
});
|
989
1069
|
}
|
990
1070
|
|
1071
|
+
|
1072
|
+
/**
|
1073
|
+
* It asks the user for their account and password, and then saves it to the database.
|
1074
|
+
*/
|
1075
|
+
|
991
1076
|
function setUserNameAndPassWord() {
|
992
1077
|
let rl = readline.createInterface({
|
993
1078
|
input: process.stdin,
|
@@ -995,7 +1080,7 @@ function setUserNameAndPassWord() {
|
|
995
1080
|
});
|
996
1081
|
|
997
1082
|
console.clear();
|
998
|
-
console.log(
|
1083
|
+
console.log(figlet.textSync('Horizon', {font: 'ANSI Shadow',horizontalLayout: 'default',verticalLayout: 'default',width: 0,whitespaceBreak: true }));
|
999
1084
|
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Operating System: " + chalk.bold.red(os.type()));
|
1000
1085
|
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Machine Version: " + chalk.bold.red(os.version()));
|
1001
1086
|
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Fca Version: " + chalk.bold.red(global.Fca.Version) + '\n');
|
@@ -1013,9 +1098,9 @@ function setUserNameAndPassWord() {
|
|
1013
1098
|
logger.Error();
|
1014
1099
|
process.exit(0);
|
1015
1100
|
}
|
1016
|
-
if (global.Fca.Require.
|
1017
|
-
global.Fca.Require.
|
1018
|
-
global.Fca.Require.fs.writeFileSync(process.cwd() + '/
|
1101
|
+
if (global.Fca.Require.Shankar.ResetDataLogin) {
|
1102
|
+
global.Fca.Require.Shankar.ResetDataLogin = false;
|
1103
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + '/ShankarFca.json', JSON.stringify(global.Fca.Require.Shankar, null, 4));
|
1019
1104
|
}
|
1020
1105
|
logger.Success(Language.SuccessSetData);
|
1021
1106
|
process.exit(1);
|
@@ -1027,6 +1112,11 @@ function setUserNameAndPassWord() {
|
|
1027
1112
|
}
|
1028
1113
|
}
|
1029
1114
|
|
1115
|
+
/**
|
1116
|
+
* @param {{ email: any; password: any; appState: any; }} loginData
|
1117
|
+
* @param {{}} options
|
1118
|
+
* @param {(error: any, api: any) => any} callback
|
1119
|
+
*/
|
1030
1120
|
|
1031
1121
|
function login(loginData, options, callback) {
|
1032
1122
|
if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
|
@@ -1046,7 +1136,7 @@ function login(loginData, options, callback) {
|
|
1046
1136
|
logRecordSize: 100,
|
1047
1137
|
online: false,
|
1048
1138
|
emitReady: false,
|
1049
|
-
userAgent: "Mozilla/5.0 (
|
1139
|
+
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8"
|
1050
1140
|
};
|
1051
1141
|
|
1052
1142
|
var prCallback = null;
|
@@ -1068,20 +1158,95 @@ function login(loginData, options, callback) {
|
|
1068
1158
|
setOptions(globalOptions, {
|
1069
1159
|
logLevel: "silent",
|
1070
1160
|
forceLogin: true,
|
1071
|
-
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/
|
1161
|
+
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36"
|
1072
1162
|
});
|
1073
1163
|
loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
|
1074
1164
|
}
|
1075
|
-
|
1165
|
+
else if (loginData.appState) {
|
1076
1166
|
setOptions(globalOptions, options);
|
1077
|
-
let All = (getAll()).filter(i => i.data
|
1167
|
+
let All = (getAll()).filter(i => i.data !== null);
|
1168
|
+
All = All.filter(i => i.data.messageCount !== undefined)
|
1078
1169
|
if (All.length >= 1) {
|
1079
1170
|
deleteAll(All.map(obj => obj.data.threadID));
|
1080
1171
|
}
|
1081
|
-
|
1082
|
-
|
1172
|
+
/*
|
1173
|
+
if (global.Fca.Require.FastConfig.Websocket_Extension.Status) {
|
1174
|
+
const UserName = Database().get('Ws_UserName');
|
1175
|
+
const PassWord = Database().get("Ws_PassWord");
|
1176
|
+
if (!UserName || !PassWord || global.Fca.Require.FastConfig.Websocket_Extension.ResetData) {
|
1177
|
+
const question = question => {
|
1178
|
+
const rl = readline.createInterface({
|
1179
|
+
input: process.stdin,
|
1180
|
+
output: process.stdout
|
1181
|
+
});
|
1182
|
+
var done,answ;
|
1183
|
+
rl.question(question, answer => {
|
1184
|
+
rl.close();
|
1185
|
+
answ = answer;
|
1186
|
+
done = true
|
1187
|
+
})
|
1188
|
+
deasync.loopWhile(function(){
|
1189
|
+
return !done;
|
1190
|
+
});
|
1191
|
+
return answ;
|
1192
|
+
};
|
1193
|
+
console.clear();
|
1194
|
+
console.log(figlet.textSync('Horizon', {font: 'ANSI Shadow',horizontalLayout: 'default',verticalLayout: 'default',width: 0,whitespaceBreak: true }));
|
1195
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Operating System: " + chalk.bold.red(os.type()));
|
1196
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Machine Version: " + chalk.bold.red(os.version()));
|
1197
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Fca Version: " + chalk.bold.red(global.Fca.Version) + '\n');
|
1198
|
+
const UserName = question(Language.Ws_TypeUserName);
|
1199
|
+
const PassWord = question(Language.Ws_TypePassWord);
|
1200
|
+
if (!UserName || !PassWord) {
|
1201
|
+
logger.Warning("Dangerous action detected! Proceeding to automatically disable websocket_extension.");
|
1202
|
+
global.Fca.Require.FastConfig.Websocket_Extension.Status = false;
|
1203
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/ShankarFca.json", JSON.stringify(global.Fca.Require.FastConfig, null, "\t"));
|
1204
|
+
}
|
1205
|
+
else {
|
1206
|
+
try {
|
1207
|
+
Database().set('Ws_UserName', UserName);
|
1208
|
+
Database().set('Ws_PassWord', PassWord);
|
1209
|
+
logger.Success(Language.Ws_Success, function() {
|
1210
|
+
const speakeasy = require('speakeasy');
|
1211
|
+
const secret = (speakeasy.generateSecret({ length: 20 }));
|
1212
|
+
logger.Warning(getText(Language.Ws_2Fa, secret.base32))
|
1213
|
+
Database().set('Ws_2Fa', secret.base32);
|
1214
|
+
if (global.Fca.Require.FastConfig.Websocket_Extension.ResetData) {
|
1215
|
+
global.Fca.Require.FastConfig.Websocket_Extension.ResetData = false;
|
1216
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + '/Fca.json', JSON.stringify(global.Fca.Require.FastConfig, null, 4));
|
1217
|
+
}
|
1218
|
+
question("Enter To Continue!");
|
1219
|
+
const ask = function() {
|
1220
|
+
const TFa_Check = question(Language.Ws_2Fa_Check)
|
1221
|
+
if (TFa_Check != speakeasy.totp({
|
1222
|
+
secret: secret.base32,
|
1223
|
+
encoding: 'base32'
|
1224
|
+
})) {
|
1225
|
+
logger.Warning("Mã Không Đúng vui lòng nhập lại(Incorrect code, please enter again.)")
|
1226
|
+
ask();
|
1227
|
+
}
|
1228
|
+
else {
|
1229
|
+
logger.Success("Success!");
|
1230
|
+
process.exit(1);
|
1231
|
+
}
|
1232
|
+
}
|
1233
|
+
return ask();
|
1234
|
+
});
|
1235
|
+
}
|
1236
|
+
catch (e) {
|
1237
|
+
console.log(e)
|
1238
|
+
logger.Warning("Error, auto turn off Websocket_extension");
|
1239
|
+
global.Fca.Require.FastConfig.Websocket_Extension.Status = false;
|
1240
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/ShankarFca.json", JSON.stringify(global.Fca.Require.FastConfig, null, "\t"));
|
1241
|
+
process.exit(1);
|
1242
|
+
}
|
1243
|
+
}
|
1244
|
+
}
|
1245
|
+
}
|
1246
|
+
**/
|
1247
|
+
switch (global.Fca.Require.Shankar.AutoLogin) {
|
1083
1248
|
case true: {
|
1084
|
-
if (global.Fca.Require.
|
1249
|
+
if (global.Fca.Require.Shankar.ResetDataLogin) return setUserNameAndPassWord();
|
1085
1250
|
else {
|
1086
1251
|
try {
|
1087
1252
|
const TempState = Database().get("TempState")
|
@@ -1121,4 +1286,5 @@ function login(loginData, options, callback) {
|
|
1121
1286
|
}
|
1122
1287
|
return returnPromise;
|
1123
1288
|
}
|
1124
|
-
|
1289
|
+
|
1290
|
+
module.exports = login;
|