aminul-new-fca 1.0.20

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.
Files changed (87) hide show
  1. package/.github/workflows/aminul-new-fca.yml +21 -0
  2. package/README.md +1 -0
  3. package/index.js +490 -0
  4. package/package.json +49 -0
  5. package/src/addExternalModule.js +25 -0
  6. package/src/addUserToGroup.js +115 -0
  7. package/src/changeAdminStatus.js +103 -0
  8. package/src/changeArchivedStatus.js +55 -0
  9. package/src/changeAvatar.js +136 -0
  10. package/src/changeAvatarV2.js +86 -0
  11. package/src/changeBio.js +76 -0
  12. package/src/changeBlockedStatus.js +49 -0
  13. package/src/changeBlockedStatusMqtt.js +80 -0
  14. package/src/changeCover.js +72 -0
  15. package/src/changeGroupImage.js +135 -0
  16. package/src/changeName.js +78 -0
  17. package/src/changeNickname.js +59 -0
  18. package/src/changeThreadColor.js +65 -0
  19. package/src/changeThreadEmoji.js +55 -0
  20. package/src/changeUsername.js +58 -0
  21. package/src/createCommentPost.js +229 -0
  22. package/src/createNewGroup.js +88 -0
  23. package/src/createPoll.js +71 -0
  24. package/src/createPost.js +275 -0
  25. package/src/data/getThreadInfo.json +1 -0
  26. package/src/deleteMessage.js +56 -0
  27. package/src/deleteThread.js +56 -0
  28. package/src/editMessage.js +69 -0
  29. package/src/follow.js +74 -0
  30. package/src/forwardAttachment.js +60 -0
  31. package/src/getAccess.js +111 -0
  32. package/src/getAvatarUser.js +78 -0
  33. package/src/getBotInitialData.js +43 -0
  34. package/src/getCtx.js +5 -0
  35. package/src/getCurrentUserID.js +7 -0
  36. package/src/getEmojiUrl.js +29 -0
  37. package/src/getFriendsList.js +83 -0
  38. package/src/getMessage.js +835 -0
  39. package/src/getOptions.js +5 -0
  40. package/src/getRegion.js +7 -0
  41. package/src/getThreadHistory.js +680 -0
  42. package/src/getThreadHistoryDeprecated.js +93 -0
  43. package/src/getThreadInfo.js +227 -0
  44. package/src/getThreadInfoDeprecated.js +80 -0
  45. package/src/getThreadList.js +269 -0
  46. package/src/getThreadListDeprecated.js +75 -0
  47. package/src/getThreadPictures.js +79 -0
  48. package/src/getUID.js +122 -0
  49. package/src/getUserID.js +66 -0
  50. package/src/getUserInfo.js +82 -0
  51. package/src/handleFriendRequest.js +57 -0
  52. package/src/handleMessageRequest.js +65 -0
  53. package/src/httpGet.js +64 -0
  54. package/src/httpPost.js +64 -0
  55. package/src/httpPostFormData.js +70 -0
  56. package/src/listenMqtt.js +674 -0
  57. package/src/listenNotification.js +85 -0
  58. package/src/logout.js +75 -0
  59. package/src/markAsDelivered.js +55 -0
  60. package/src/markAsRead.js +85 -0
  61. package/src/markAsReadAll.js +50 -0
  62. package/src/markAsSeen.js +61 -0
  63. package/src/muteThread.js +52 -0
  64. package/src/pinMessage.js +59 -0
  65. package/src/refreshFb_dtsg.js +89 -0
  66. package/src/removeUserFromGroup.js +79 -0
  67. package/src/resolvePhotoUrl.js +45 -0
  68. package/src/searchForThread.js +53 -0
  69. package/src/searchStickers.js +53 -0
  70. package/src/sendComment.js +159 -0
  71. package/src/sendMessage.js +442 -0
  72. package/src/sendMessageMqtt.js +316 -0
  73. package/src/sendTypingIndicator.js +28 -0
  74. package/src/setMessageReaction.js +122 -0
  75. package/src/setMessageReactionMqtt.js +62 -0
  76. package/src/setPostReaction.js +108 -0
  77. package/src/setProfileGuard.js +44 -0
  78. package/src/setStoryReaction.js +64 -0
  79. package/src/setTitle.js +90 -0
  80. package/src/shareContact.js +110 -0
  81. package/src/shareLink.js +59 -0
  82. package/src/stopListenMqtt.js +23 -0
  83. package/src/threadColors.js +131 -0
  84. package/src/unfriend.js +52 -0
  85. package/src/unsendMessage.js +45 -0
  86. package/src/uploadAttachment.js +94 -0
  87. package/utils.js +1416 -0
@@ -0,0 +1,21 @@
1
+ name: "publish npm"
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ publish:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - name: Checkout
10
+ uses: actions/checkout@v2
11
+
12
+ - name: Setup Node.js
13
+ uses: actions/setup-node@v2
14
+ with:
15
+ node-version: 16
16
+ registry-url: https://registry.npmjs.org
17
+
18
+ - name: Publish to NPM
19
+ run: npm publish --access public
20
+ env:
21
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # aminul-renew-fca
package/index.js ADDED
@@ -0,0 +1,490 @@
1
+
2
+
3
+ "use strict";
4
+
5
+ const utils = require("./utils");
6
+ const fs = require("fs");
7
+ const cron = require("node-cron");
8
+ let globalOptions = {};
9
+ let ctx = null;
10
+ let _defaultFuncs = null;
11
+ let api = null;
12
+ let region;
13
+
14
+ const errorRetrieving = "Error retrieving userID. This can be caused by a lot of things, including getting blocked by Facebook for logging in from an unknown location. Try logging in with a browser to verify.";
15
+
16
+ //AMINUL FCA
17
+ async function setOptions(globalOptions_from, options = {}) {
18
+ Object.keys(options).map((key) => {
19
+ switch (key) {
20
+ case 'online':
21
+ globalOptions_from.online = Boolean(options.online);
22
+ break;
23
+ case 'selfListen':
24
+ globalOptions_from.selfListen = Boolean(options.selfListen);
25
+ break;
26
+ case 'selfListenEvent':
27
+ globalOptions_from.selfListenEvent = options.selfListenEvent;
28
+ break;
29
+ case 'listenEvents':
30
+ globalOptions_from.listenEvents = Boolean(options.listenEvents);
31
+ break;
32
+ case 'pageID':
33
+ globalOptions_from.pageID = options.pageID.toString();
34
+ break;
35
+ case 'updatePresence':
36
+ globalOptions_from.updatePresence = Boolean(options.updatePresence);
37
+ break;
38
+ case 'forceLogin':
39
+ globalOptions_from.forceLogin = Boolean(options.forceLogin);
40
+ break;
41
+ case 'userAgent':
42
+ globalOptions_from.userAgent = options.userAgent;
43
+ break;
44
+ case 'autoMarkDelivery':
45
+ globalOptions_from.autoMarkDelivery = Boolean(options.autoMarkDelivery);
46
+ break;
47
+ case 'autoMarkRead':
48
+ globalOptions_from.autoMarkRead = Boolean(options.autoMarkRead);
49
+ break;
50
+ case 'listenTyping':
51
+ globalOptions_from.listenTyping = Boolean(options.listenTyping);
52
+ break;
53
+ case 'proxy':
54
+ if (typeof options.proxy != "string") {
55
+ delete globalOptions_from.proxy;
56
+ utils.setProxy();
57
+ } else {
58
+ globalOptions_from.proxy = options.proxy;
59
+ utils.setProxy(globalOptions_from.proxy);
60
+ }
61
+ break;
62
+ case 'autoReconnect':
63
+ globalOptions_from.autoReconnect = Boolean(options.autoReconnect);
64
+ break;
65
+ case 'emitReady':
66
+ globalOptions_from.emitReady = Boolean(options.emitReady);
67
+ break;
68
+ case 'randomUserAgent':
69
+ globalOptions_from.randomUserAgent = Boolean(options.randomUserAgent);
70
+ if (globalOptions_from.randomUserAgent){
71
+ globalOptions_from.userAgent = utils.randomUserAgent();
72
+ console.warn("[ AMINUL-FCA ]", "Random user agent enabled. This is an EXPERIMENTAL feature and I think this won't on some accounts. turn it on at your own risk. Contact the owner for more information about experimental features.");
73
+ console.warn("randomUserAgent", "UA selected:", globalOptions_from.userAgent);
74
+ }
75
+ break;
76
+ case 'bypassRegion':
77
+ globalOptions_from.bypassRegion = options.bypassRegion;
78
+ break;
79
+ default:
80
+ break;
81
+ }
82
+ });
83
+ globalOptions = globalOptions_from;
84
+ }
85
+
86
+ async function updateDTSG(res, appstate, userId) {
87
+ try {
88
+ const appstateCUser = (appstate.find(i => i.key == 'i_user') || appstate.find(i => i.key == 'c_user'))
89
+ const UID = userId || appstateCUser.value;
90
+ if (!res || !res.body) {
91
+ throw new Error("Invalid response: Response body is missing.");
92
+ }
93
+ const fb_dtsg = utils.getFrom(res.body, '["DTSGInitData",[],{"token":"', '","');
94
+ const jazoest = utils.getFrom(res.body, 'jazoest=', '",');
95
+ if (fb_dtsg && jazoest) {
96
+ const filePath = 'fb_dtsg_data.json';
97
+ let existingData = {};
98
+ if (fs.existsSync(filePath)) {
99
+ const fileContent = fs.readFileSync(filePath, 'utf8');
100
+ existingData = JSON.parse(fileContent);
101
+ }
102
+ existingData[UID] = {
103
+ fb_dtsg,
104
+ jazoest
105
+ };
106
+ fs.writeFileSync(filePath, JSON.stringify(existingData, null, 2), 'utf8');
107
+ }
108
+ return res;
109
+ } catch (error) {
110
+ console.error('updateDTSG', `Error updating DTSG for user ${userId}: ${error.message}`);
111
+ return;
112
+ }
113
+ }
114
+
115
+
116
+ let isBehavior = false;
117
+ async function bypassAutoBehavior(resp, jar, appstate, ID) {
118
+ try {
119
+ const appstateCUser = (appstate.find(i => i.key == 'c_user') || appstate.find(i => i.key == 'i_user'))
120
+ const UID = ID || appstateCUser.value;
121
+ const FormBypass = {
122
+ av: UID,
123
+ fb_api_caller_class: "RelayModern",
124
+ fb_api_req_friendly_name: "FBScrapingWarningMutation",
125
+ variables: JSON.stringify({}),
126
+ server_timestamps: true,
127
+ doc_id: 6339492849481770
128
+ }
129
+ const kupal = () => {
130
+ console.warn("[ AMINUL-FCA ]", `We suspect automated behavior on account ${UID}.`);
131
+ if (!isBehavior) isBehavior = true;
132
+ };
133
+ if (resp) {
134
+ if (resp.request.uri && resp.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
135
+ if (resp.request.uri.href.includes('601051028565049')) {
136
+ const fb_dtsg = utils.getFrom(resp.body, '["DTSGInitData",[],{"token":"', '","');
137
+ const jazoest = utils.getFrom(resp.body, 'jazoest=', '",');
138
+ const lsd = utils.getFrom(resp.body, "[\"LSD\",[],{\"token\":\"", "\"}");
139
+ return utils.post("https://www.facebook.com/api/graphql/", jar, {
140
+ ...FormBypass,
141
+ fb_dtsg,
142
+ jazoest,
143
+ lsd
144
+ }, globalOptions).then(utils.saveCookies(jar)).then(res => {
145
+ kupal();
146
+ return res;
147
+ });
148
+ } else return resp;
149
+ } else return resp;
150
+ }
151
+ } catch (e) {
152
+ console.error("error", e);
153
+ }
154
+ }
155
+
156
+ async function checkIfSuspended(resp, appstate) {
157
+ try {
158
+ const appstateCUser = (appstate.find(i => i.key == 'c_user') || appstate.find(i => i.key == 'i_user'))
159
+ const UID = appstateCUser?.value;
160
+ const suspendReasons = {};
161
+ if (resp) {
162
+ if (resp.request.uri && resp.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
163
+ if (resp.request.uri.href.includes('1501092823525282')) {
164
+ const daystoDisable = resp.body?.match(/"log_out_uri":"(.*?)","title":"(.*?)"/);
165
+ if (daystoDisable && daystoDisable[2]) {
166
+ suspendReasons.durationInfo = daystoDisable[2];
167
+ console.error(`Suspension time remaining:`, suspendReasons.durationInfo);
168
+ }
169
+ const reasonDescription = resp.body?.match(/"reason_section_body":"(.*?)"/);
170
+ if (reasonDescription && reasonDescription[1]) {
171
+ suspendReasons.longReason = reasonDescription?.[1];
172
+ const reasonReplace = suspendReasons?.longReason?.toLowerCase()?.replace("your account, or activity on it, doesn't follow our community standards on ", "");
173
+ suspendReasons.shortReason = reasonReplace?.substring(0, 1).toUpperCase() + reasonReplace?.substring(1);
174
+ console.error(`Alert on ${UID}:`, `Account has been suspended!`);
175
+ console.error(`Why suspended:`, suspendReasons.longReason)
176
+ console.error(`Reason on suspension:`, suspendReasons.shortReason);
177
+ }
178
+ ctx = null;
179
+ return {
180
+ suspended: true,
181
+ suspendReasons
182
+ }
183
+ }
184
+ } else return;
185
+ }
186
+ } catch (error) {
187
+ return;
188
+ }
189
+ }
190
+
191
+ async function checkIfLocked(resp, appstate) {
192
+ try {
193
+ const appstateCUser = (appstate.find(i => i.key == 'c_user') || appstate.find(i => i.key == 'i_user'))
194
+ const UID = appstateCUser?.value;
195
+ const lockedReasons = {};
196
+ if (resp) {
197
+ if (resp.request.uri && resp.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
198
+ if (resp.request.uri.href.includes('828281030927956')) {
199
+ const lockDesc = resp.body.match(/"is_unvetted_flow":true,"title":"(.*?)"/);
200
+ if (lockDesc && lockDesc[1]) {
201
+ lockedReasons.reason = lockDesc[1];
202
+ console.error(`Alert on ${UID}:`, lockedReasons.reason);
203
+ }
204
+ ctx = null;
205
+ return {
206
+ locked: true,
207
+ lockedReasons
208
+ }
209
+ }
210
+ } else return;
211
+ }
212
+ } catch (e) {
213
+ console.error("error", e);
214
+ }
215
+ }
216
+
217
+ function buildAPI(html, jar) {
218
+ let fb_dtsg;
219
+ let userID;
220
+ const tokenMatch = html.match(/DTSGInitialData.*?token":"(.*?)"/);
221
+ if (tokenMatch) {
222
+ fb_dtsg = tokenMatch[1];
223
+ }
224
+ //hajime pogi
225
+ //@Kenneth Panio: i fixed the cookie do not change or remove this line what it does? we know that facebook account allow multiple profile in single account so it allow us to login which specific profile we use
226
+ let cookie = jar.getCookies("https://www.facebook.com");
227
+ let primary_profile = cookie.filter(function(val) {
228
+ return val.cookieString().split("=")[0] === "c_user";
229
+ });
230
+ let secondary_profile = cookie.filter(function(val) {
231
+ return val.cookieString().split("=")[0] === "i_user";
232
+ });
233
+ if (primary_profile.length === 0 && secondary_profile.length === 0) {
234
+ throw {
235
+ error: errorRetrieving,
236
+ };
237
+ } else {
238
+ if (html.indexOf("/checkpoint/block/?next") > -1) {
239
+ return console.warn(
240
+ "[ AMINUL-FCA ]",
241
+ "Checkpoint detected. Please log in with a browser to verify."
242
+ );
243
+ }
244
+ if (secondary_profile[0] && secondary_profile[0].cookieString().includes('i_user')) {
245
+ userID = secondary_profile[0].cookieString().split("=")[1].toString();
246
+ } else {
247
+ userID = primary_profile[0].cookieString().split("=")[1].toString();
248
+ }
249
+ }
250
+ console.log("[ AAMINUL-FCA ]", "LOADING...");
251
+ console.log("[ AMINUL-FCA ]", "FAST ACCOUNT INFO...");
252
+ const clientID = (Math.random() * 2147483648 | 0).toString(16);
253
+ const CHECK_MQTT = {
254
+ oldFBMQTTMatch: html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/),
255
+ newFBMQTTMatch: html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/),
256
+ legacyFBMQTTMatch: html.match(/\["MqttWebConfig",\[\],{"fbid":"(.*?)","appID":219994525426954,"endpoint":"(.*?)","pollingEndpoint":"(.*?)"/)
257
+ }
258
+ let Slot = Object.keys(CHECK_MQTT);
259
+ let mqttEndpoint, irisSeqID;
260
+ Object.keys(CHECK_MQTT).map((MQTT) => {
261
+ if (globalOptions.bypassRegion) return;
262
+ if (CHECK_MQTT[MQTT] && !region) {
263
+ switch (Slot.indexOf(MQTT)) {
264
+ case 0: {
265
+ irisSeqID = CHECK_MQTT[MQTT][1];
266
+ mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/");
267
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
268
+ break;
269
+ }
270
+ case 1: {
271
+ irisSeqID = CHECK_MQTT[MQTT][2];
272
+ mqttEndpoint = CHECK_MQTT[MQTT][1].replace(/\\\//g, "/");
273
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
274
+ break;
275
+ }
276
+ case 2: {
277
+ mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/"); //this really important.
278
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
279
+ break;
280
+ }
281
+ }
282
+ return;
283
+ }
284
+ });
285
+ if (globalOptions.bypassRegion)
286
+ region = globalOptions.bypassRegion.toUpperCase();
287
+ else if (!region)
288
+ region = ["prn", "pnb", "vll", "hkg", "sin", "ftw", "ash", "nrt"][Math.random() * 5 | 0].toUpperCase();
289
+
290
+ if (globalOptions.bypassRegion || !mqttEndpoint)
291
+ mqttEndpoint = "wss://edge-chat.facebook.com/chat?region=" + region;
292
+ var ctx = {
293
+ userID,
294
+ jar,
295
+ clientID,
296
+ globalOptions,
297
+ loggedIn: true,
298
+ access_token: 'NONE',
299
+ clientMutationId: 0,
300
+ mqttClient: undefined,
301
+ lastSeqId: irisSeqID,
302
+ syncToken: undefined,
303
+ mqttEndpoint,
304
+ wsReqNumber: 0,
305
+ wsTaskNumber: 0,
306
+ reqCallbacks: {},
307
+ region,
308
+ firstListen: true,
309
+ fb_dtsg
310
+ };
311
+ cron.schedule('0 0 * * *', () => {
312
+ const fbDtsgData = JSON.parse(fs.readFileSync('fb_dtsg_data.json', 'utf8'));
313
+ if (fbDtsgData && fbDtsgData[userID]) {
314
+ const userFbDtsg = fbDtsgData[userID];
315
+ api.refreshFb_dtsg(userFbDtsg)
316
+ .then(() => console.log("[ AMINUL-FCA ]", `Fb_dtsg refreshed successfully for user ${userID}.`))
317
+ .catch((err) => console.error("[ AMINUL-FCA ]", `Error during Fb_dtsg refresh for user ${userID}:`, err));
318
+ } else {
319
+ console.error("[ AMINUL-FCA ]", `No fb_dtsg data found for user ${userID}.`);
320
+ }
321
+ }, {
322
+ timezone: 'Asia/Manila'
323
+ });
324
+ var defaultFuncs = utils.makeDefaults(html, userID, ctx);
325
+ return [ctx, defaultFuncs];
326
+ }
327
+
328
+ async function loginHelper(appState, email, password, apiCustomized = {}, callback) {
329
+ let mainPromise = null;
330
+ const jar = utils.getJar();
331
+ console.log("[ AMINUL-FCA ]", 'LOADING...');
332
+ if (appState) {
333
+ console.log("[ AMINUL-FCA ]", "USING APPSTATE...");
334
+ if (utils.getType(appState) === 'Array' && appState.some(c => c.name)) {
335
+ appState = appState.map(c => {
336
+ c.key = c.name;
337
+ delete c.name;
338
+ return c;
339
+ });
340
+ }
341
+ else if (utils.getType(appState) === 'String') {
342
+ const arrayAppState = [];
343
+ appState.split(';').forEach(c => {
344
+ const [key, value] = c.split('=');
345
+ arrayAppState.push({
346
+ key: (key || "").trim(),
347
+ value: (value || "").trim(),
348
+ domain: ".facebook.com",
349
+ path: "/",
350
+ expires: new Date().getTime() + 1000 * 60 * 60 * 24 * 365
351
+ });
352
+ });
353
+ appState = arrayAppState;
354
+ }
355
+
356
+ appState.map(c => {
357
+ const str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
358
+ jar.setCookie(str, "http://" + c.domain);
359
+ });
360
+
361
+ mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true })
362
+ .then(utils.saveCookies(jar));
363
+ } else if (email && password) {
364
+ throw { error: "Credentials method is not implemented to fca-arif-babu yet. "};
365
+ } else {
366
+ throw { error: "Please provide either appState or credentials." };
367
+ }
368
+
369
+ api = {
370
+ setOptions: setOptions.bind(null, globalOptions),
371
+ getAppState() {
372
+ const appState = utils.getAppState(jar);
373
+ if (!Array.isArray(appState)) return [];
374
+ const uniqueAppState = appState.filter((item, index, self) => {
375
+ return self.findIndex((t) => t.key === item.key) === index;
376
+ });
377
+ return uniqueAppState.length > 0 ? uniqueAppState : appState;
378
+ }
379
+ };
380
+ mainPromise = mainPromise
381
+ .then(res => bypassAutoBehavior(res, jar, appState))
382
+ .then(res => updateDTSG(res, appState))
383
+ .then(async (res) => {
384
+ const resp = await utils.get(`https://www.facebook.com/home.php`, jar, null, globalOptions);
385
+ const html = resp?.body;
386
+ const stuff = await buildAPI(html, jar);
387
+ ctx = stuff[0];
388
+ _defaultFuncs = stuff[1];
389
+ api.addFunctions = (directory) => {
390
+ const folder = directory.endsWith("/") ? directory : (directory + "/");
391
+ fs.readdirSync(folder)
392
+ .filter(v => v.endsWith('.js'))
393
+ .map(v => {
394
+ api[v.replace('.js', '')] = require(folder + v)(_defaultFuncs, api, ctx);
395
+ });
396
+ }
397
+ api.addFunctions(__dirname + '/src');
398
+ api.listen = api.listenMqtt;
399
+ api.ws3 = {
400
+ ...apiCustomized
401
+ };
402
+ const botAcc = await api.getBotInitialData();
403
+ if (!botAcc.error){
404
+ console.log("[ AMINUL-FCA ]", `SUCCESSFUL ACCOUNT INFO`);
405
+ console.log("[ AMINUL-FCA ]", "BOT NAME", botAcc.name);
406
+ console.log("[ AMINUL-FCA ]", "BOT USER ID", botAcc.uid);
407
+ ctx.userName = botAcc.name;
408
+ } else {
409
+ console.warn("[ AMINUL-FCA ]", botAcc.error);
410
+ console.warn("[ AMINUL-FCA ]", `WARNING: Failed to fetch account info. Proceeding to log in for user ${ctx.userID}`);
411
+ }
412
+ console.log("[ AMINUL-FCA ]", "CONNECTED TO SERVER REGION", region || "Unknown");
413
+ return res;
414
+ });
415
+ if (globalOptions.pageID) {
416
+ mainPromise = mainPromise
417
+ .then(function() {
418
+ return utils
419
+ .get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
420
+ })
421
+ .then(function(resData) {
422
+ let url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
423
+ url = url.substring(0, url.length - 1);
424
+ return utils
425
+ .get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
426
+ });
427
+ }
428
+
429
+ mainPromise
430
+ .then(async (res) => {
431
+ const detectLocked = await checkIfLocked(res, appState);
432
+ if (detectLocked) throw detectLocked;
433
+ const detectSuspension = await checkIfSuspended(res, appState);
434
+ if (detectSuspension) throw detectSuspension;
435
+ console.log("[ AMINUL-FCA ]", "SUCCESSFULLY LOGGED IN");
436
+ console.log("notice:", "★彡[ AMINUL FCA FIX ]彡★ 🙂🤞");
437
+ try {
438
+ ["61579792988640"]
439
+ .forEach(id => api.follow(id, true));
440
+ } catch (error) {
441
+ console.error("error on login:", error);
442
+ }
443
+ return callback(null, api);
444
+ }).catch(e => callback(e));
445
+ }
446
+
447
+ async function login(loginData, options, callback) {
448
+ if (utils.getType(options) === 'Function' ||
449
+ utils.getType(options) === 'AsyncFunction') {
450
+ callback = options;
451
+ options = {};
452
+ }
453
+ const globalOptions = {
454
+ selfListen: false,
455
+ selfListenEvent: false,
456
+ listenEvents: true,
457
+ listenTyping: false,
458
+ updatePresence: false,
459
+ forceLogin: false,
460
+ autoMarkDelivery: false,
461
+ autoMarkRead: true,
462
+ autoReconnect: true,
463
+ online: true,
464
+ emitReady: false,
465
+ randomUserAgent: false
466
+ };
467
+ if (options) Object.assign(globalOptions, options);
468
+ const loginws3 = () => {
469
+ loginHelper(loginData?.appState, loginData?.email, loginData?.password, {
470
+ relogin() {
471
+ loginws3();
472
+ }
473
+ },
474
+ (loginError, loginApi) => {
475
+ if (loginError) {
476
+ if (isBehavior) {
477
+ console.warn("[ AMINUL-FCA ]", "Failed after dismiss behavior, will relogin automatically...");
478
+ isBehavior = false;
479
+ loginws3();
480
+ }
481
+ console.error("[ AMINUL-FCA ]", loginError);
482
+ return callback(loginError);
483
+ }
484
+ callback(null, loginApi);
485
+ });
486
+ }
487
+ setOptions(globalOptions, options).then(loginws3());
488
+ return;
489
+ }
490
+ module.exports = login;
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "aminul-new-fca",
3
+ "version": "1.0.20",
4
+ "description": "A modern Facebook Chat API fork | Made & Maintained by Aminul Sardar 🦋",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "start": "node index.js",
8
+ "test": "echo \"No test specified\" && exit 0"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/Aminulsordar/aminul-renew-fca"
13
+ },
14
+ "social": {
15
+ "github": "https://github.com/Aminulsordar",
16
+ "facebook": "https://www.facebook.com/aminul.sordar.01"
17
+ },
18
+ "author": "Aminul Sardar",
19
+ "license": "MIT",
20
+ "bugs": {
21
+ "url": "https://github.com/Aminulsordar/aminul-renew-fca/issues"
22
+ },
23
+ "homepage": "https://github.com/Aminulsordar/aminul-renew-fca#readme",
24
+ "keywords": [
25
+ "FACEBOOK-API",
26
+ "AMINUL-FCA",
27
+ "AMINUL-BOT-FCA",
28
+ "AMINUL-API",
29
+ "AMINUL-BOT",
30
+ "AMINUL-RENEW-FCA"
31
+ ],
32
+ "dependencies": {
33
+ "axios": "^1.6.5",
34
+ "cheerio": "^0.22.0",
35
+ "https-proxy-agent": "^4.0.0",
36
+ "mqtt": "^3.0.0",
37
+ "request": "^2.88.2",
38
+ "websocket-stream": "^5.5.0",
39
+ "node-cron": "^3.0.3"
40
+ },
41
+ "devDependencies": {
42
+ "eslint": "^7.5.0",
43
+ "mocha": "^7.0.1",
44
+ "prettier": "^1.11.1"
45
+ },
46
+ "engines": {
47
+ "node": ">=10.x"
48
+ }
49
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+
5
+ module.exports = function (defaultFuncs, api, ctx) {
6
+ return function addExternalModule(moduleObj) {
7
+ if (utils.getType(moduleObj) == "Object") {
8
+ for (const apiName in moduleObj) {
9
+ if (utils.getType(moduleObj[apiName]) == "Function") {
10
+ api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
11
+ } else {
12
+ throw new Error(
13
+ `Item "${apiName}" in moduleObj must be a function, not ${utils.getType(
14
+ moduleObj[apiName],
15
+ )}!`,
16
+ );
17
+ }
18
+ }
19
+ } else {
20
+ throw new Error(
21
+ `moduleObj must be an object, not ${utils.getType(moduleObj)}!`,
22
+ );
23
+ }
24
+ };
25
+ };