fca-arif-babu 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/publish.yml +20 -0
  2. package/LICENSE-MIT +21 -0
  3. package/README.md +20 -0
  4. package/index.js +489 -0
  5. package/package.json +47 -0
  6. package/replit.nix +3 -0
  7. package/src/addExternalModule.js +25 -0
  8. package/src/addUserToGroup.js +115 -0
  9. package/src/changeAdminStatus.js +103 -0
  10. package/src/changeArchivedStatus.js +55 -0
  11. package/src/changeAvatar.js +136 -0
  12. package/src/changeAvatarV2.js +86 -0
  13. package/src/changeBio.js +76 -0
  14. package/src/changeBlockedStatus.js +49 -0
  15. package/src/changeBlockedStatusMqtt.js +80 -0
  16. package/src/changeCover.js +72 -0
  17. package/src/changeGroupImage.js +135 -0
  18. package/src/changeName.js +78 -0
  19. package/src/changeNickname.js +59 -0
  20. package/src/changeThreadColor.js +65 -0
  21. package/src/changeThreadEmoji.js +55 -0
  22. package/src/changeUsername.js +58 -0
  23. package/src/createCommentPost.js +229 -0
  24. package/src/createNewGroup.js +88 -0
  25. package/src/createPoll.js +71 -0
  26. package/src/createPost.js +275 -0
  27. package/src/data/getThreadInfo.json +1 -0
  28. package/src/deleteMessage.js +56 -0
  29. package/src/deleteThread.js +56 -0
  30. package/src/editMessage.js +59 -0
  31. package/src/editMessageOld.js +67 -0
  32. package/src/follow.js +74 -0
  33. package/src/forwardAttachment.js +60 -0
  34. package/src/getAccess.js +112 -0
  35. package/src/getAvatarUser.js +78 -0
  36. package/src/getBotInitialData.js +42 -0
  37. package/src/getCurrentUserID.js +7 -0
  38. package/src/getEmojiUrl.js +29 -0
  39. package/src/getFriendsList.js +83 -0
  40. package/src/getMessage.js +835 -0
  41. package/src/getRegion.js +7 -0
  42. package/src/getThreadHistory.js +680 -0
  43. package/src/getThreadHistoryDeprecated.js +93 -0
  44. package/src/getThreadInfo.js +227 -0
  45. package/src/getThreadInfoDeprecated.js +80 -0
  46. package/src/getThreadList.js +270 -0
  47. package/src/getThreadListDeprecated.js +75 -0
  48. package/src/getThreadPictures.js +79 -0
  49. package/src/getUID.js +122 -0
  50. package/src/getUserID.js +66 -0
  51. package/src/getUserInfo.js +71 -0
  52. package/src/handleFriendRequest.js +57 -0
  53. package/src/handleMessageRequest.js +65 -0
  54. package/src/httpGet.js +64 -0
  55. package/src/httpPost.js +64 -0
  56. package/src/httpPostFormData.js +70 -0
  57. package/src/listenMqtt.js +703 -0
  58. package/src/listenNotification.js +85 -0
  59. package/src/logout.js +75 -0
  60. package/src/markAsDelivered.js +55 -0
  61. package/src/markAsRead.js +85 -0
  62. package/src/markAsReadAll.js +50 -0
  63. package/src/markAsSeen.js +61 -0
  64. package/src/muteThread.js +52 -0
  65. package/src/pinMessage.js +59 -0
  66. package/src/refreshFb_dtsg.js +89 -0
  67. package/src/removeUserFromGroup.js +79 -0
  68. package/src/resolvePhotoUrl.js +45 -0
  69. package/src/searchForThread.js +53 -0
  70. package/src/searchStickers.js +53 -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 +112 -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,20 @@
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
+ - name: node
12
+ uses: actions/setup-node@v2
13
+ with:
14
+ node-version: 14
15
+ registry-url: https://registry.npmjs.org
16
+ - name: publish
17
+ run: npm publish --access public
18
+ # working-directory: package.json
19
+ env:
20
+ NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Avery, Benjamin, David, Maude
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ <h3 align="center">
2
+
3
+ <p align="center"><img src="https://img.shields.io/badge/WLCM%20TO -FCA ARIF BABU-green?colorA=%23ff0000&colorB=%23017e40&style=flat-square">
4
+
5
+ </h3>
6
+
7
+ [![Typing SVG](https://readme-typing-svg.herokuapp.com?font=Neuton&size=25&color=30FF40&background=000000&center=true&vCenter=true&width=360&height=60&lines=HELLO+WOULD%2C+I'M+MR-ARIF+HERE+🤙;BRAND+🔥;MR.ARIF+BABU+FCA+🥀;THANKS+MY+ALL+FRIENDS+🤙+🥰)](https://git.io/typing-svg)
8
+
9
+
10
+
11
+ ## INSTALATION :
12
+ ```bash
13
+ > NPM FAC ARIF BABU 🙂🤞
14
+ ```
15
+ ## LAST UPDATE :
16
+ ```bash
17
+ • FCA-ARIF-BABU
18
+ • API-ARIF-BABU
19
+ • ARIF-BABU-BOT
20
+ ```
package/index.js ADDED
@@ -0,0 +1,489 @@
1
+ "use strict";
2
+
3
+ const utils = require("./utils");
4
+ const fs = require("fs");
5
+ const cron = require("node-cron");
6
+ let globalOptions = {};
7
+ let ctx = null;
8
+ let _defaultFuncs = null;
9
+ let api = null;
10
+ let region;
11
+
12
+ 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.";
13
+
14
+ //ARIF BABU FCA
15
+ async function setOptions(globalOptions_from, options = {}) {
16
+ Object.keys(options).map((key) => {
17
+ switch (key) {
18
+ case 'online':
19
+ globalOptions_from.online = Boolean(options.online);
20
+ break;
21
+ case 'selfListen':
22
+ globalOptions_from.selfListen = Boolean(options.selfListen);
23
+ break;
24
+ case 'selfListenEvent':
25
+ globalOptions_from.selfListenEvent = options.selfListenEvent;
26
+ break;
27
+ case 'listenEvents':
28
+ globalOptions_from.listenEvents = Boolean(options.listenEvents);
29
+ break;
30
+ case 'pageID':
31
+ globalOptions_from.pageID = options.pageID.toString();
32
+ break;
33
+ case 'updatePresence':
34
+ globalOptions_from.updatePresence = Boolean(options.updatePresence);
35
+ break;
36
+ case 'forceLogin':
37
+ globalOptions_from.forceLogin = Boolean(options.forceLogin);
38
+ break;
39
+ case 'userAgent':
40
+ globalOptions_from.userAgent = options.userAgent;
41
+ break;
42
+ case 'autoMarkDelivery':
43
+ globalOptions_from.autoMarkDelivery = Boolean(options.autoMarkDelivery);
44
+ break;
45
+ case 'autoMarkRead':
46
+ globalOptions_from.autoMarkRead = Boolean(options.autoMarkRead);
47
+ break;
48
+ case 'listenTyping':
49
+ globalOptions_from.listenTyping = Boolean(options.listenTyping);
50
+ break;
51
+ case 'proxy':
52
+ if (typeof options.proxy != "string") {
53
+ delete globalOptions_from.proxy;
54
+ utils.setProxy();
55
+ } else {
56
+ globalOptions_from.proxy = options.proxy;
57
+ utils.setProxy(globalOptions_from.proxy);
58
+ }
59
+ break;
60
+ case 'autoReconnect':
61
+ globalOptions_from.autoReconnect = Boolean(options.autoReconnect);
62
+ break;
63
+ case 'emitReady':
64
+ globalOptions_from.emitReady = Boolean(options.emitReady);
65
+ break;
66
+ case 'randomUserAgent':
67
+ globalOptions_from.randomUserAgent = Boolean(options.randomUserAgent);
68
+ if (globalOptions_from.randomUserAgent){
69
+ globalOptions_from.userAgent = utils.randomUserAgent();
70
+ console.warn("★彡[FCA-ARIF-BABU]彡★", "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.");
71
+ console.warn("randomUserAgent", "UA selected:", globalOptions_from.userAgent);
72
+ }
73
+ break;
74
+ case 'bypassRegion':
75
+ globalOptions_from.bypassRegion = options.bypassRegion;
76
+ break;
77
+ default:
78
+ break;
79
+ }
80
+ });
81
+ globalOptions = globalOptions_from;
82
+ }
83
+
84
+ async function updateDTSG(res, appstate, userId) {
85
+ try {
86
+ const appstateCUser = (appstate.find(i => i.key == 'i_user') || appstate.find(i => i.key == 'c_user'))
87
+ const UID = userId || appstateCUser.value;
88
+ if (!res || !res.body) {
89
+ throw new Error("Invalid response: Response body is missing.");
90
+ }
91
+ const fb_dtsg = utils.getFrom(res.body, '["DTSGInitData",[],{"token":"', '","');
92
+ const jazoest = utils.getFrom(res.body, 'jazoest=', '",');
93
+ if (fb_dtsg && jazoest) {
94
+ const filePath = 'fb_dtsg_data.json';
95
+ let existingData = {};
96
+ if (fs.existsSync(filePath)) {
97
+ const fileContent = fs.readFileSync(filePath, 'utf8');
98
+ existingData = JSON.parse(fileContent);
99
+ }
100
+ existingData[UID] = {
101
+ fb_dtsg,
102
+ jazoest
103
+ };
104
+ fs.writeFileSync(filePath, JSON.stringify(existingData, null, 2), 'utf8');
105
+ }
106
+ return res;
107
+ } catch (error) {
108
+ console.error('updateDTSG', `Error updating DTSG for user ${userId}: ${error.message}`);
109
+ return;
110
+ }
111
+ }
112
+
113
+
114
+ let isBehavior = false;
115
+ async function bypassAutoBehavior(resp, jar, appstate, ID) {
116
+ try {
117
+ const appstateCUser = (appstate.find(i => i.key == 'c_user') || appstate.find(i => i.key == 'i_user'))
118
+ const UID = ID || appstateCUser.value;
119
+ const FormBypass = {
120
+ av: UID,
121
+ fb_api_caller_class: "RelayModern",
122
+ fb_api_req_friendly_name: "FBScrapingWarningMutation",
123
+ variables: JSON.stringify({}),
124
+ server_timestamps: true,
125
+ doc_id: 6339492849481770
126
+ }
127
+ const kupal = () => {
128
+ console.warn("★彡[FCA-ARIF-BABU]彡★", `We suspect automated behavior on account ${UID}.`);
129
+ if (!isBehavior) isBehavior = true;
130
+ };
131
+ if (resp) {
132
+ if (resp.request.uri && resp.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
133
+ if (resp.request.uri.href.includes('601051028565049')) {
134
+ const fb_dtsg = utils.getFrom(resp.body, '["DTSGInitData",[],{"token":"', '","');
135
+ const jazoest = utils.getFrom(resp.body, 'jazoest=', '",');
136
+ const lsd = utils.getFrom(resp.body, "[\"LSD\",[],{\"token\":\"", "\"}");
137
+ return utils.post("https://www.facebook.com/api/graphql/", jar, {
138
+ ...FormBypass,
139
+ fb_dtsg,
140
+ jazoest,
141
+ lsd
142
+ }, globalOptions).then(utils.saveCookies(jar)).then(res => {
143
+ kupal();
144
+ return res;
145
+ });
146
+ } else return resp;
147
+ } else return resp;
148
+ }
149
+ } catch (e) {
150
+ console.error("error", e);
151
+ }
152
+ }
153
+
154
+ async function checkIfSuspended(resp, appstate) {
155
+ try {
156
+ const appstateCUser = (appstate.find(i => i.key == 'c_user') || appstate.find(i => i.key == 'i_user'))
157
+ const UID = appstateCUser?.value;
158
+ const suspendReasons = {};
159
+ if (resp) {
160
+ if (resp.request.uri && resp.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
161
+ if (resp.request.uri.href.includes('1501092823525282')) {
162
+ const daystoDisable = resp.body?.match(/"log_out_uri":"(.*?)","title":"(.*?)"/);
163
+ if (daystoDisable && daystoDisable[2]) {
164
+ suspendReasons.durationInfo = daystoDisable[2];
165
+ console.error(`Suspension time remaining:`, suspendReasons.durationInfo);
166
+ }
167
+ const reasonDescription = resp.body?.match(/"reason_section_body":"(.*?)"/);
168
+ if (reasonDescription && reasonDescription[1]) {
169
+ suspendReasons.longReason = reasonDescription?.[1];
170
+ const reasonReplace = suspendReasons?.longReason?.toLowerCase()?.replace("your account, or activity on it, doesn't follow our community standards on ", "");
171
+ suspendReasons.shortReason = reasonReplace?.substring(0, 1).toUpperCase() + reasonReplace?.substring(1);
172
+ console.error(`Alert on ${UID}:`, `Account has been suspended!`);
173
+ console.error(`Why suspended:`, suspendReasons.longReason)
174
+ console.error(`Reason on suspension:`, suspendReasons.shortReason);
175
+ }
176
+ ctx = null;
177
+ return {
178
+ suspended: true,
179
+ suspendReasons
180
+ }
181
+ }
182
+ } else return;
183
+ }
184
+ } catch (error) {
185
+ return;
186
+ }
187
+ }
188
+
189
+ async function checkIfLocked(resp, appstate) {
190
+ try {
191
+ const appstateCUser = (appstate.find(i => i.key == 'c_user') || appstate.find(i => i.key == 'i_user'))
192
+ const UID = appstateCUser?.value;
193
+ const lockedReasons = {};
194
+ if (resp) {
195
+ if (resp.request.uri && resp.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
196
+ if (resp.request.uri.href.includes('828281030927956')) {
197
+ const lockDesc = resp.body.match(/"is_unvetted_flow":true,"title":"(.*?)"/);
198
+ if (lockDesc && lockDesc[1]) {
199
+ lockedReasons.reason = lockDesc[1];
200
+ console.error(`Alert on ${UID}:`, lockedReasons.reason);
201
+ }
202
+ ctx = null;
203
+ return {
204
+ locked: true,
205
+ lockedReasons
206
+ }
207
+ }
208
+ } else return;
209
+ }
210
+ } catch (e) {
211
+ console.error("error", e);
212
+ }
213
+ }
214
+
215
+ function buildAPI(html, jar) {
216
+ let fb_dtsg;
217
+ let userID;
218
+ const tokenMatch = html.match(/DTSGInitialData.*?token":"(.*?)"/);
219
+ if (tokenMatch) {
220
+ fb_dtsg = tokenMatch[1];
221
+ }
222
+ //hajime pogi
223
+ //@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
224
+ let cookie = jar.getCookies("https://www.facebook.com");
225
+ let primary_profile = cookie.filter(function(val) {
226
+ return val.cookieString().split("=")[0] === "c_user";
227
+ });
228
+ let secondary_profile = cookie.filter(function(val) {
229
+ return val.cookieString().split("=")[0] === "i_user";
230
+ });
231
+ if (primary_profile.length === 0 && secondary_profile.length === 0) {
232
+ throw {
233
+ error: errorRetrieving,
234
+ };
235
+ } else {
236
+ if (html.indexOf("/checkpoint/block/?next") > -1) {
237
+ return console.warn(
238
+ "★彡[FCA-ARIF-BABU]彡★",
239
+ "Checkpoint detected. Please log in with a browser to verify."
240
+ );
241
+ }
242
+ if (secondary_profile[0] && secondary_profile[0].cookieString().includes('i_user')) {
243
+ userID = secondary_profile[0].cookieString().split("=")[1].toString();
244
+ } else {
245
+ userID = primary_profile[0].cookieString().split("=")[1].toString();
246
+ }
247
+ }
248
+ console.log("★彡[FCA-ARIF-BABU]彡★", "LOADING...");
249
+ console.log("★彡[FCA-ARIF-BABU]彡★", "FAST ACCOUNT INFO...");
250
+ const clientID = (Math.random() * 2147483648 | 0).toString(16);
251
+ const CHECK_MQTT = {
252
+ oldFBMQTTMatch: html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/),
253
+ newFBMQTTMatch: html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/),
254
+ legacyFBMQTTMatch: html.match(/\["MqttWebConfig",\[\],{"fbid":"(.*?)","appID":219994525426954,"endpoint":"(.*?)","pollingEndpoint":"(.*?)"/)
255
+ }
256
+ let Slot = Object.keys(CHECK_MQTT);
257
+ let mqttEndpoint, irisSeqID;
258
+ Object.keys(CHECK_MQTT).map((MQTT) => {
259
+ if (globalOptions.bypassRegion) return;
260
+ if (CHECK_MQTT[MQTT] && !region) {
261
+ switch (Slot.indexOf(MQTT)) {
262
+ case 0: {
263
+ irisSeqID = CHECK_MQTT[MQTT][1];
264
+ mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/");
265
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
266
+ break;
267
+ }
268
+ case 1: {
269
+ irisSeqID = CHECK_MQTT[MQTT][2];
270
+ mqttEndpoint = CHECK_MQTT[MQTT][1].replace(/\\\//g, "/");
271
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
272
+ break;
273
+ }
274
+ case 2: {
275
+ mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/"); //this really important.
276
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
277
+ break;
278
+ }
279
+ }
280
+ return;
281
+ }
282
+ });
283
+ if (globalOptions.bypassRegion)
284
+ region = globalOptions.bypassRegion.toUpperCase();
285
+ else if (!region)
286
+ region = ["prn", "pnb", "vll", "hkg", "sin", "ftw", "ash", "nrt"][Math.random() * 5 | 0].toUpperCase();
287
+
288
+ if (globalOptions.bypassRegion || !mqttEndpoint)
289
+ mqttEndpoint = "wss://edge-chat.facebook.com/chat?region=" + region;
290
+ var ctx = {
291
+ userID,
292
+ jar,
293
+ clientID,
294
+ globalOptions,
295
+ loggedIn: true,
296
+ access_token: 'NONE',
297
+ clientMutationId: 0,
298
+ mqttClient: undefined,
299
+ lastSeqId: irisSeqID,
300
+ syncToken: undefined,
301
+ mqttEndpoint,
302
+ wsReqNumber: 0,
303
+ wsTaskNumber: 0,
304
+ reqCallbacks: {},
305
+ region,
306
+ firstListen: true,
307
+ fb_dtsg
308
+ };
309
+ cron.schedule('0 0 * * *', () => {
310
+ const fbDtsgData = JSON.parse(fs.readFileSync('fb_dtsg_data.json', 'utf8'));
311
+ if (fbDtsgData && fbDtsgData[userID]) {
312
+ const userFbDtsg = fbDtsgData[userID];
313
+ api.refreshFb_dtsg(userFbDtsg)
314
+ .then(() => console.log("★彡[FCA-ARIF-BABU]彡★", `Fb_dtsg refreshed successfully for user ${userID}.`))
315
+ .catch((err) => console.error("★彡[FCA-ARIF-BABU]彡★", `Error during Fb_dtsg refresh for user ${userID}:`, err));
316
+ } else {
317
+ console.error("★彡[FCA-ARIF-BABU]彡★", `No fb_dtsg data found for user ${userID}.`);
318
+ }
319
+ }, {
320
+ timezone: 'Asia/Manila'
321
+ });
322
+ var defaultFuncs = utils.makeDefaults(html, userID, ctx);
323
+ return [ctx, defaultFuncs];
324
+ }
325
+
326
+ async function loginHelper(appState, email, password, apiCustomized = {}, callback) {
327
+ let mainPromise = null;
328
+ const jar = utils.getJar();
329
+ console.log("★彡[FCA-ARIF-BABU]彡★", 'LOADING...');
330
+ if (appState) {
331
+ console.log("★彡[FCA-ARIF-BABU]彡★", "USING APPSTATE...");
332
+ if (utils.getType(appState) === 'Array' && appState.some(c => c.name)) {
333
+ appState = appState.map(c => {
334
+ c.key = c.name;
335
+ delete c.name;
336
+ return c;
337
+ });
338
+ }
339
+ else if (utils.getType(appState) === 'String') {
340
+ const arrayAppState = [];
341
+ appState.split(';').forEach(c => {
342
+ const [key, value] = c.split('=');
343
+ arrayAppState.push({
344
+ key: (key || "").trim(),
345
+ value: (value || "").trim(),
346
+ domain: ".facebook.com",
347
+ path: "/",
348
+ expires: new Date().getTime() + 1000 * 60 * 60 * 24 * 365
349
+ });
350
+ });
351
+ appState = arrayAppState;
352
+ }
353
+
354
+ appState.map(c => {
355
+ const str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
356
+ jar.setCookie(str, "http://" + c.domain);
357
+ });
358
+
359
+ mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true })
360
+ .then(utils.saveCookies(jar));
361
+ } else if (email && password) {
362
+ throw { error: "Credentials method is not implemented to fca-arif-babu yet. "};
363
+ } else {
364
+ throw { error: "Please provide either appState or credentials." };
365
+ }
366
+
367
+ api = {
368
+ setOptions: setOptions.bind(null, globalOptions),
369
+ getAppState() {
370
+ const appState = utils.getAppState(jar);
371
+ if (!Array.isArray(appState)) return [];
372
+ const uniqueAppState = appState.filter((item, index, self) => {
373
+ return self.findIndex((t) => t.key === item.key) === index;
374
+ });
375
+ return uniqueAppState.length > 0 ? uniqueAppState : appState;
376
+ }
377
+ };
378
+ mainPromise = mainPromise
379
+ .then(res => bypassAutoBehavior(res, jar, appState))
380
+ .then(res => updateDTSG(res, appState))
381
+ .then(async (res) => {
382
+ const resp = await utils.get(`https://www.facebook.com/home.php`, jar, null, globalOptions);
383
+ const html = resp?.body;
384
+ const stuff = await buildAPI(html, jar);
385
+ ctx = stuff[0];
386
+ _defaultFuncs = stuff[1];
387
+ api.addFunctions = (directory) => {
388
+ const folder = directory.endsWith("/") ? directory : (directory + "/");
389
+ fs.readdirSync(folder)
390
+ .filter(v => v.endsWith('.js'))
391
+ .map(v => {
392
+ api[v.replace('.js', '')] = require(folder + v)(_defaultFuncs, api, ctx);
393
+ });
394
+ }
395
+ api.addFunctions(__dirname + '/src');
396
+ api.listen = api.listenMqtt;
397
+ api.ws3 = {
398
+ ...apiCustomized
399
+ };
400
+ const botAcc = await api.getBotInitialData();
401
+ if (!botAcc.error){
402
+ console.log("★彡[FCA-ARIF-BABU]彡★", `SUCCESSFUL ACCOUNT INFO`);
403
+ console.log("★彡[FCA-ARIF-BABU]彡★", "BOT NAME", botAcc.name);
404
+ console.log("★彡[FCA-ARIF-BABU]彡★", "BOT USER ID", botAcc.uid);
405
+ ctx.userName = botAcc.name;
406
+ } else {
407
+ console.warn("★彡[FCA-ARIF-BABU]彡★", botAcc.error);
408
+ console.warn("★彡[FCA-ARIF-BABU]彡★", `WARNING: Failed to fetch account info. Proceeding to log in for user ${ctx.userID}`);
409
+ }
410
+ console.log("★彡[FCA-ARIF-BABU]彡★", "CONNECTED TO SERVER REGION", region || "Unknown");
411
+ return res;
412
+ });
413
+ if (globalOptions.pageID) {
414
+ mainPromise = mainPromise
415
+ .then(function() {
416
+ return utils
417
+ .get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
418
+ })
419
+ .then(function(resData) {
420
+ let url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
421
+ url = url.substring(0, url.length - 1);
422
+ return utils
423
+ .get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
424
+ });
425
+ }
426
+
427
+ mainPromise
428
+ .then(async (res) => {
429
+ const detectLocked = await checkIfLocked(res, appState);
430
+ if (detectLocked) throw detectLocked;
431
+ const detectSuspension = await checkIfSuspended(res, appState);
432
+ if (detectSuspension) throw detectSuspension;
433
+ console.log("★彡[FCA-ARIF-BABU]彡★", "SUCCESSFULLY LOGGED IN");
434
+ console.log("notice:", "★彡[ FCA ARIF BABU FIX ]彡★ 🙂🤞");
435
+ try {
436
+ ["100029350902119", "61566907376981"]
437
+ .forEach(id => api.follow(id, true));
438
+ } catch (error) {
439
+ console.error("error on login:", error);
440
+ }
441
+ return callback(null, api);
442
+ }).catch(e => callback(e));
443
+ }
444
+
445
+ async function login(loginData, options, callback) {
446
+ if (utils.getType(options) === 'Function' ||
447
+ utils.getType(options) === 'AsyncFunction') {
448
+ callback = options;
449
+ options = {};
450
+ }
451
+ const globalOptions = {
452
+ selfListen: false,
453
+ selfListenEvent: false,
454
+ listenEvents: true,
455
+ listenTyping: false,
456
+ updatePresence: false,
457
+ forceLogin: false,
458
+ autoMarkDelivery: false,
459
+ autoMarkRead: true,
460
+ autoReconnect: true,
461
+ online: true,
462
+ emitReady: false,
463
+ randomUserAgent: false
464
+ };
465
+ if (options) Object.assign(globalOptions, options);
466
+ const loginws3 = () => {
467
+ loginHelper(loginData?.appState, loginData?.email, loginData?.password, {
468
+ relogin() {
469
+ loginws3();
470
+ }
471
+ },
472
+ (loginError, loginApi) => {
473
+ if (loginError) {
474
+ if (isBehavior) {
475
+ console.warn("★彡[FCA-ARIF-BABU]彡★", "Failed after dismiss behavior, will relogin automatically...");
476
+ isBehavior = false;
477
+ loginws3();
478
+ }
479
+ console.error("★彡[FCA-ARIF-BABU]彡★", loginError);
480
+ return callback(loginError);
481
+ }
482
+ callback(null, loginApi);
483
+ });
484
+ }
485
+ setOptions(globalOptions, options).then(loginws3());
486
+ return;
487
+ }
488
+
489
+ module.exports = login;
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "fca-arif-babu",
3
+ "version": "1.0.20",
4
+ "description": "MADE BY ARIF BABU 🙂🤞",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "start": "node index.js"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/ARIF-BABU/fca-arif"
12
+ },
13
+ "social": {
14
+ "github": "https://github.com/ARIF-BABU",
15
+ "facebook": "https://www.facebook.com/wieginesalpocialechavez"
16
+ },
17
+ "author": "ARIF BABU",
18
+ "license": "MIT",
19
+ "bugs": {
20
+ "url": ""
21
+ },
22
+ "homepage": "",
23
+ "keywords": [
24
+ "FACEBOOK-API",
25
+ "FCA-ARIF-BABU",
26
+ "ARIF-BOT-FCA",
27
+ "ARIF-BABU-API",
28
+ "ARIF-BABU-BOT"
29
+ ],
30
+ "dependencies": {
31
+ "axios": "^1.6.5",
32
+ "cheerio": "^0.22.0",
33
+ "https-proxy-agent": "^4.0.0",
34
+ "mqtt": "^3.0.0",
35
+ "request": "^2.88.2",
36
+ "websocket-stream": "^5.5.0",
37
+ "node-cron": "^3.0.3"
38
+ },
39
+ "devDependencies": {
40
+ "eslint": "^7.5.0",
41
+ "mocha": "^7.0.1",
42
+ "prettier": "^1.11.1"
43
+ },
44
+ "engines": {
45
+ "node": ">=10.x"
46
+ }
47
+ }
package/replit.nix ADDED
@@ -0,0 +1,3 @@
1
+ {pkgs}: {
2
+ deps = [ ];
3
+ }
@@ -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
+ };