rapido-fca 0.0.3 → 0.0.5

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 (80) hide show
  1. package/index.js +16 -23
  2. package/package.json +16 -15
  3. package/src/addExternalModule.js +19 -23
  4. package/src/addUserToGroup.js +99 -97
  5. package/src/changeAdminStatus.js +86 -62
  6. package/src/changeArchivedStatus.js +49 -49
  7. package/src/changeAvatar.js +118 -108
  8. package/src/changeAvatarV2.js +86 -0
  9. package/src/changeAvt.js +85 -0
  10. package/src/changeBio.js +63 -64
  11. package/src/changeBlockedStatus.js +40 -38
  12. package/src/changeBlockedStatusMqtt.js +80 -0
  13. package/src/changeCover.js +72 -0
  14. package/src/changeGroupImage.js +129 -126
  15. package/src/changeName.js +79 -0
  16. package/src/changeNickname.js +49 -49
  17. package/src/changeThreadColor.js +53 -53
  18. package/src/changeThreadEmoji.js +45 -45
  19. package/src/changeUsername.js +59 -0
  20. package/src/createCommentPost.js +230 -0
  21. package/src/createNewGroup.js +74 -72
  22. package/src/createPoll.js +59 -59
  23. package/src/createPost.js +276 -0
  24. package/src/deleteMessage.js +50 -50
  25. package/src/deleteThread.js +50 -50
  26. package/src/editMessage.js +51 -49
  27. package/src/editMessageOld.js +67 -0
  28. package/src/follow.js +74 -0
  29. package/src/forwardAttachment.js +54 -54
  30. package/src/getAccess.js +112 -0
  31. package/src/getAvatarUser.js +78 -0
  32. package/src/getCurrentUserID.js +3 -3
  33. package/src/getEmojiUrl.js +17 -17
  34. package/src/getFriendsList.js +67 -67
  35. package/src/getMessage.js +806 -767
  36. package/src/getRegion.js +7 -0
  37. package/src/getThreadHistory.js +656 -642
  38. package/src/getThreadHistoryDeprecated.js +71 -0
  39. package/src/getThreadInfo.js +1 -1
  40. package/src/getThreadInfoDeprecated.js +56 -0
  41. package/src/getThreadList.js +199 -227
  42. package/src/getThreadListDeprecated.js +46 -0
  43. package/src/getThreadPictures.js +51 -71
  44. package/src/getUID.js +119 -0
  45. package/src/getUserID.js +53 -58
  46. package/src/getUserInfo.js +52 -60
  47. package/src/handleFriendRequest.js +41 -65
  48. package/src/handleMessageRequest.js +42 -60
  49. package/src/httpGet.js +49 -57
  50. package/src/httpPost.js +48 -57
  51. package/src/listenMqtt.js +827 -895
  52. package/src/logout.js +61 -61
  53. package/src/markAsDelivered.js +42 -53
  54. package/src/markAsRead.js +59 -69
  55. package/src/markAsReadAll.js +32 -42
  56. package/src/markAsSeen.js +43 -54
  57. package/src/muteThread.js +40 -47
  58. package/src/refreshFb_dtsg.js +77 -69
  59. package/src/removeUserFromGroup.js +67 -67
  60. package/src/resolvePhotoUrl.js +34 -34
  61. package/src/searchForThread.js +43 -43
  62. package/src/searchStickers.js +53 -0
  63. package/src/sendMessage.js +80 -228
  64. package/src/sendMessageMqtt.js +322 -0
  65. package/src/sendTypingIndicator.js +86 -88
  66. package/src/sendTypingIndicatorV2.js +28 -0
  67. package/src/setMessageReaction.js +110 -109
  68. package/src/setMessageReactionMqtt.js +62 -0
  69. package/src/setPostReaction.js +90 -87
  70. package/src/setStoryReaction.js +64 -0
  71. package/src/setTitle.js +76 -72
  72. package/src/shareContact.js +110 -0
  73. package/src/shareLink.js +59 -0
  74. package/src/stopListenMqtt.js +23 -0
  75. package/src/threadColors.js +121 -121
  76. package/src/unfriend.js +43 -43
  77. package/src/unsendMessage.js +34 -38
  78. package/src/uploadAttachment.js +79 -81
  79. package/LICENSE +0 -21
  80. package/src/httpPostFormData.js +0 -63
package/index.js CHANGED
@@ -3,9 +3,6 @@
3
3
  var utils = require("./utils");
4
4
  var cheerio = require("cheerio");
5
5
  var log = require("npmlog");
6
- /*var { getThemeColors } = require("../../func/utils/log.js");
7
- var logger = require("../../func/utils/log.js");
8
- var { cra, cv, cb, co } = getThemeColors();*/
9
6
  log.maxRecordSize = 100;
10
7
  var checkVerified = null;
11
8
  const Boolean_Option = ['online', 'selfListen', 'listenEvents', 'updatePresence', 'forceLogin', 'autoMarkDelivery', 'autoMarkRead', 'listenTyping', 'autoReconnect', 'emitReady'];
@@ -114,10 +111,10 @@ function buildAPI(globalOptions, html, jar) {
114
111
  }
115
112
  } catch { }
116
113
  if (fb_dtsg) {
117
- console.log("Found fb_dtsg!");
114
+ log.info("Login", "Found fb_dtsg token");
118
115
  }
119
116
  } catch (e) {
120
- console.log("Error finding fb_dtsg:", e);
117
+ log.error("Login", "Error finding fb_dtsg token");
121
118
  }
122
119
  }
123
120
  extractFromHTML();
@@ -126,33 +123,33 @@ function buildAPI(globalOptions, html, jar) {
126
123
  var userCookie = cookies.find(cookie => cookie.cookieString().startsWith("c_user="));
127
124
  var tiktikCookie = cookies.find(cookie => cookie.cookieString().startsWith("i_user="));
128
125
  if (!userCookie && !tiktikCookie) {
129
- return log.error("Error! Your cookiestate is not valid!");
126
+ return log.error("Login", "Invalid cookie state");
130
127
  }
131
128
  if (html.includes("/checkpoint/block/?next")) {
132
- return log.error('error', "Appstate is dead rechange it!", 'error');
129
+ return log.error('Login', "Appstate is blocked - please renew it");
133
130
  }
134
131
  userID = (tiktikCookie || userCookie).cookieString().split("=")[1];
135
- //logger.log(`${cra(`[ CONNECT ]`)} Logged in as ${userID}`, "DATABASE");
132
+ log.info("Login", `User ID: ${api.getCurrentUserID()}`);
136
133
  try { clearInterval(checkVerified); } catch (_) { }
137
134
  const clientID = (Math.random() * 2147483648 | 0).toString(16);
138
- let mqttEndpoint = `wss://edge-chat.facebook.com/chat?region=prn&sid=${userID}`;
139
- let region = "PRN";
135
+ let mqttEndpoint = `wss://edge-chat.facebook.com/chat?region=pnb&sid=${userID}`;
136
+ let region = "PNB";
140
137
 
141
138
  try {
142
139
  const endpointMatch = html.match(/"endpoint":"([^"]+)"/);
143
140
  if (endpointMatch.input.includes("601051028565049")) {
144
- console.log(`login error.`);
145
- ditconmemay = true;
141
+ log.error("Login", "Login error detected");
142
+ ditconmemay = true;
146
143
  }
147
144
  if (endpointMatch) {
148
145
  mqttEndpoint = endpointMatch[1].replace(/\\\//g, '/');
149
146
  const url = new URL(mqttEndpoint);
150
- region = url.searchParams.get('region')?.toUpperCase() || "PRN";
147
+ region = url.searchParams.get('region')?.toUpperCase() || "PNB";
151
148
  }
152
149
  } catch (e) {
153
- console.log('Using default MQTT endpoint');
150
+ log.warn("Login", "Using default MQTT endpoint");
154
151
  }
155
- log.info('Logging in...');
152
+ log.info("Login", `Connecting to region: ${region}`);
156
153
  var ctx = {
157
154
  userID: userID,
158
155
  jar: jar,
@@ -214,11 +211,10 @@ function buildAPI(globalOptions, html, jar) {
214
211
 
215
212
  return newDtsg;
216
213
  } catch (e) {
217
- console.log("Error getting fresh dtsg:", e);
214
+ log.error("Login", "Error getting fresh dtsg token");
218
215
  return null;
219
216
  }
220
217
  };
221
- //if (noMqttData) api.htmlData = noMqttData;
222
218
  require('fs').readdirSync(__dirname + '/src/').filter(v => v.endsWith('.js')).forEach(v => { api[v.replace('.js', '')] = require(`./src/${v}`)(utils.makeDefaults(html, userID, ctx), api, ctx); });
223
219
  api.listen = api.listenMqtt;
224
220
  return {
@@ -251,7 +247,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
251
247
  const cookieData = JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]");
252
248
  jar.setCookie(utils.formatCookie(cookieData, "facebook"), "https://www.facebook.com");
253
249
  });
254
- log.info("Logging in...");
250
+ log.info("Login", "Attempting login...");
255
251
  const loginRes = await utils.post(
256
252
  "https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110",
257
253
  jar,
@@ -262,7 +258,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
262
258
  const headers = loginRes.headers;
263
259
  if (!headers.location) throw new Error("Wrong username/password.");
264
260
  if (headers.location.includes('https://www.facebook.com/checkpoint/')) {
265
- log.info("login", "You have login approvals turned on.");
261
+ log.info("Login", "Login approvals enabled");
266
262
  const checkpointRes = await utils.get(headers.location, jar, null, loginOptions);
267
263
  await utils.saveCookies(jar)(checkpointRes);
268
264
  const checkpointHtml = checkpointRes.body;
@@ -322,7 +318,6 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
322
318
  };
323
319
  }
324
320
 
325
-
326
321
  function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
327
322
  let mainPromise = null;
328
323
  const jar = utils.getJar();
@@ -397,7 +392,7 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
397
392
 
398
393
  mainPromise
399
394
  .then(async () => {
400
- log.info('Login successful');
395
+ log.info("Login", `Successfully logged in as ${ctx.userID} in region ${ctx.region}`);
401
396
  callback(null, api);
402
397
  })
403
398
  .catch(e => {
@@ -405,7 +400,6 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
405
400
  });
406
401
  }
407
402
 
408
-
409
403
  function login(loginData, options, callback) {
410
404
  if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
411
405
  callback = options;
@@ -456,5 +450,4 @@ function login(loginData, options, callback) {
456
450
  return returnPromise;
457
451
  }
458
452
 
459
-
460
453
  module.exports = login;
package/package.json CHANGED
@@ -1,18 +1,7 @@
1
1
  {
2
2
  "name": "rapido-fca",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "A Facebook chat api for messenger bots.",
5
- "main": "index.js",
6
- "scripts": {
7
- "start": "node index.js"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": ""
12
- },
13
- "author": "rapidodev",
14
- "license": "MIT",
15
- "homepage": "",
16
5
  "keywords": [
17
6
  "facebook",
18
7
  "chat",
@@ -21,6 +10,21 @@
21
10
  "messenger",
22
11
  "chatbot"
23
12
  ],
13
+ "homepage": "",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": ""
17
+ },
18
+ "license": "MIT",
19
+ "author": "rapidodev",
20
+ "type": "commonjs",
21
+ "main": "index.js",
22
+ "directories": {
23
+ "test": "test"
24
+ },
25
+ "scripts": {
26
+ "start": "node index.js"
27
+ },
24
28
  "dependencies": {
25
29
  "axios": "^1.6.5",
26
30
  "bluebird": "^3.7.2",
@@ -39,8 +43,5 @@
39
43
  },
40
44
  "engines": {
41
45
  "node": ">=10.x"
42
- },
43
- "directories": {
44
- "test": "test"
45
46
  }
46
47
  }
@@ -1,29 +1,25 @@
1
1
  "use strict";
2
2
 
3
3
  const utils = require("../utils");
4
- const log = require("npmlog");
5
4
 
6
5
  module.exports = function (defaultFuncs, api, ctx) {
7
- return function addExternalModule(moduleObj) {
8
- if (utils.getType(moduleObj) == "Object") {
9
- for (const apiName in moduleObj) {
10
- if (utils.getType(moduleObj[apiName]) == "Function") {
11
- api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx, utils, log);
12
- } else {
13
- throw new Error(`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(moduleObj[apiName])}!`);
14
- }
15
- }
16
- } else {
17
- throw new Error(`moduleObj must be an object, not ${utils.getType(moduleObj)}!`);
18
- }
19
- };
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
+ };
20
25
  };
21
-
22
- // example usage:
23
- // api.addExternalModule({
24
- // getCtx: (defaultFuncs, api, ctx, utils, log) => {
25
- // return function getCtx() {
26
- // return ctx;
27
- // };
28
- // }
29
- // });
@@ -1,113 +1,115 @@
1
1
  "use strict";
2
2
 
3
3
  const utils = require("../utils");
4
- const log = require("npmlog");
4
+ // @NethWs3Dev
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
- return function addUserToGroup(userID, threadID, callback) {
8
- let resolveFunc = function () { };
9
- let rejectFunc = function () { };
10
- const returnPromise = new Promise(function (resolve, reject) {
11
- resolveFunc = resolve;
12
- rejectFunc = reject;
13
- });
7
+ return function addUserToGroup(userID, threadID, callback) {
8
+ let resolveFunc = function () {};
9
+ let rejectFunc = function () {};
10
+ const returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
14
 
15
- if (
16
- !callback &&
17
- (utils.getType(threadID) === "Function" ||
18
- utils.getType(threadID) === "AsyncFunction")
19
- ) {
20
- throw new utils.CustomError({ error: "please pass a threadID as a second argument." });
21
- }
15
+ if (
16
+ !callback &&
17
+ (utils.getType(threadID) === "Function" ||
18
+ utils.getType(threadID) === "AsyncFunction")
19
+ ) {
20
+ throw new utils.CustomError({
21
+ error: "please pass a threadID as a second argument.",
22
+ });
23
+ }
22
24
 
23
- if (!callback) {
24
- callback = function (err) {
25
- if (err) {
26
- return rejectFunc(err);
27
- }
28
- resolveFunc();
29
- };
30
- }
25
+ if (!callback) {
26
+ callback = function (err) {
27
+ if (err) {
28
+ return rejectFunc(err);
29
+ }
30
+ resolveFunc();
31
+ };
32
+ }
31
33
 
32
- if (
33
- utils.getType(threadID) !== "Number" &&
34
- utils.getType(threadID) !== "String"
35
- ) {
36
- throw new utils.CustomError({
37
- error:
38
- "ThreadID should be of type Number or String and not " +
39
- utils.getType(threadID) +
40
- "."
41
- });
42
- }
34
+ if (
35
+ utils.getType(threadID) !== "Number" &&
36
+ utils.getType(threadID) !== "String"
37
+ ) {
38
+ throw new utils.CustomError({
39
+ error:
40
+ "ThreadID should be of type Number or String and not " +
41
+ utils.getType(threadID) +
42
+ ".",
43
+ });
44
+ }
43
45
 
44
- if (utils.getType(userID) !== "Array") {
45
- userID = [userID];
46
- }
46
+ if (utils.getType(userID) !== "Array") {
47
+ userID = [userID];
48
+ }
47
49
 
48
- const messageAndOTID = utils.generateOfflineThreadingID();
49
- const form = {
50
- client: "mercury",
51
- action_type: "ma-type:log-message",
52
- author: "fbid:" + (ctx.i_userID || ctx.userID),
53
- thread_id: "",
54
- timestamp: Date.now(),
55
- timestamp_absolute: "Today",
56
- timestamp_relative: utils.generateTimestampRelative(),
57
- timestamp_time_passed: "0",
58
- is_unread: false,
59
- is_cleared: false,
60
- is_forward: false,
61
- is_filtered_content: false,
62
- is_filtered_content_bh: false,
63
- is_filtered_content_account: false,
64
- is_spoof_warning: false,
65
- source: "source:chat:web",
66
- "source_tags[0]": "source:chat",
67
- log_message_type: "log:subscribe",
68
- status: "0",
69
- offline_threading_id: messageAndOTID,
70
- message_id: messageAndOTID,
71
- threading_id: utils.generateThreadingID(ctx.clientID),
72
- manual_retry_cnt: "0",
73
- thread_fbid: threadID
74
- };
50
+ const messageAndOTID = utils.generateOfflineThreadingID();
51
+ const form = {
52
+ client: "mercury",
53
+ action_type: "ma-type:log-message",
54
+ author: "fbid:" + (ctx.userID),
55
+ thread_id: "",
56
+ timestamp: Date.now(),
57
+ timestamp_absolute: "Today",
58
+ timestamp_relative: utils.generateTimestampRelative(),
59
+ timestamp_time_passed: "0",
60
+ is_unread: false,
61
+ is_cleared: false,
62
+ is_forward: false,
63
+ is_filtered_content: false,
64
+ is_filtered_content_bh: false,
65
+ is_filtered_content_account: false,
66
+ is_spoof_warning: false,
67
+ source: "source:chat:web",
68
+ "source_tags[0]": "source:chat",
69
+ log_message_type: "log:subscribe",
70
+ status: "0",
71
+ offline_threading_id: messageAndOTID,
72
+ message_id: messageAndOTID,
73
+ threading_id: utils.generateThreadingID(ctx.clientID),
74
+ manual_retry_cnt: "0",
75
+ thread_fbid: threadID,
76
+ };
75
77
 
76
- for (let i = 0; i < userID.length; i++) {
77
- if (
78
- utils.getType(userID[i]) !== "Number" &&
79
- utils.getType(userID[i]) !== "String"
80
- ) {
81
- throw new utils.CustomError({
82
- error:
83
- "Elements of userID should be of type Number or String and not " +
84
- utils.getType(userID[i]) +
85
- "."
86
- });
87
- }
78
+ for (let i = 0; i < userID.length; i++) {
79
+ if (
80
+ utils.getType(userID[i]) !== "Number" &&
81
+ utils.getType(userID[i]) !== "String"
82
+ ) {
83
+ throw new utils.CustomError({
84
+ error:
85
+ "Elements of userID should be of type Number or String and not " +
86
+ utils.getType(userID[i]) +
87
+ ".",
88
+ });
89
+ }
88
90
 
89
- form["log_message_data[added_participants][" + i + "]"] =
90
- "fbid:" + userID[i];
91
- }
91
+ form["log_message_data[added_participants][" + i + "]"] =
92
+ "fbid:" + userID[i];
93
+ }
92
94
 
93
- defaultFuncs
94
- .post("https://www.facebook.com/messaging/send/", ctx.jar, form)
95
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
96
- .then(function (resData) {
97
- if (!resData) {
98
- throw new utils.CustomError({ error: "Add to group failed." });
99
- }
100
- if (resData.error) {
101
- throw new utils.CustomError(resData);
102
- }
95
+ defaultFuncs
96
+ .post("https://www.facebook.com/messaging/send/", ctx.jar, form)
97
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
98
+ .then(function (resData) {
99
+ if (!resData) {
100
+ throw new utils.CustomError({ error: "Add to group failed." });
101
+ }
102
+ if (resData.error) {
103
+ throw new utils.CustomError(resData);
104
+ }
103
105
 
104
- return callback();
105
- })
106
- .catch(function (err) {
107
- log.error("addUserToGroup", err);
108
- return callback(err);
109
- });
106
+ return callback();
107
+ })
108
+ .catch(function (err) {
109
+ console.error("addUserToGroup", err);
110
+ return callback(err);
111
+ });
110
112
 
111
- return returnPromise;
112
- };
113
+ return returnPromise;
114
+ };
113
115
  };
@@ -1,79 +1,103 @@
1
1
  "use strict";
2
2
 
3
3
  const utils = require("../utils");
4
- const log = require("npmlog");
4
+ // @NethWs3Dev
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
- return function changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
8
- if (utils.getType(threadID) !== "String") {
9
- throw new utils.CustomError({ error: "changeAdminStatus: threadID must be a string" });
10
- }
7
+ return function changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
8
+ if (utils.getType(threadID) !== "String") {
9
+ throw new utils.CustomError({
10
+ error: "changeAdminStatus: threadID must be a string",
11
+ });
12
+ }
11
13
 
12
- if (utils.getType(adminIDs) === "String") {
13
- adminIDs = [adminIDs];
14
- }
14
+ if (utils.getType(adminIDs) === "String") {
15
+ adminIDs = [adminIDs];
16
+ }
15
17
 
16
- if (utils.getType(adminIDs) !== "Array") {
17
- throw new utils.CustomError({ error: "changeAdminStatus: adminIDs must be an array or string" });
18
- }
18
+ if (utils.getType(adminIDs) !== "Array") {
19
+ throw new utils.CustomError({
20
+ error: "changeAdminStatus: adminIDs must be an array or string",
21
+ });
22
+ }
19
23
 
20
- if (utils.getType(adminStatus) !== "Boolean") {
21
- throw new utils.CustomError({ error: "changeAdminStatus: adminStatus must be a string" });
22
- }
24
+ if (utils.getType(adminStatus) !== "Boolean") {
25
+ throw new utils.CustomError({
26
+ error: "changeAdminStatus: adminStatus must be a string",
27
+ });
28
+ }
23
29
 
24
- let resolveFunc = function () { };
25
- let rejectFunc = function () { };
26
- const returnPromise = new Promise(function (resolve, reject) {
27
- resolveFunc = resolve;
28
- rejectFunc = reject;
29
- });
30
+ let resolveFunc = function () {};
31
+ let rejectFunc = function () {};
32
+ const returnPromise = new Promise(function (resolve, reject) {
33
+ resolveFunc = resolve;
34
+ rejectFunc = reject;
35
+ });
30
36
 
31
- if (!callback) {
32
- callback = function (err) {
33
- if (err) {
34
- return rejectFunc(err);
35
- }
36
- resolveFunc();
37
- };
38
- }
37
+ if (!callback) {
38
+ callback = function (err) {
39
+ if (err) {
40
+ return rejectFunc(err);
41
+ }
42
+ resolveFunc();
43
+ };
44
+ }
39
45
 
40
- if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
41
- throw new utils.CustomError({ error: "changeAdminStatus: callback is not a function" });
42
- }
46
+ if (
47
+ utils.getType(callback) !== "Function" &&
48
+ utils.getType(callback) !== "AsyncFunction"
49
+ ) {
50
+ throw new utils.CustomError({
51
+ error: "changeAdminStatus: callback is not a function",
52
+ });
53
+ }
43
54
 
44
- const form = {
45
- "thread_fbid": threadID
46
- };
55
+ const form = {
56
+ thread_fbid: threadID,
57
+ };
47
58
 
48
- let i = 0;
49
- for (const u of adminIDs) {
50
- form[`admin_ids[${i++}]`] = u;
51
- }
52
- form["add"] = adminStatus;
59
+ let i = 0;
60
+ for (const u of adminIDs) {
61
+ form[`admin_ids[${i++}]`] = u;
62
+ }
63
+ form["add"] = adminStatus;
53
64
 
54
- defaultFuncs
55
- .post("https://www.facebook.com/messaging/save_admins/?dpr=1", ctx.jar, form)
56
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
- .then(function (resData) {
58
- if (resData.error) {
59
- switch (resData.error) {
60
- case 1976004:
61
- throw new utils.CustomError({ error: "Cannot alter admin status: you are not an admin.", rawResponse: resData });
62
- case 1357031:
63
- throw new utils.CustomError({ error: "Cannot alter admin status: this thread is not a group chat.", rawResponse: resData });
64
- default:
65
- throw new utils.CustomError({ error: "Cannot alter admin status: unknown error.", rawResponse: resData });
66
- }
67
- }
65
+ defaultFuncs
66
+ .post(
67
+ "https://www.facebook.com/messaging/save_admins/?dpr=1",
68
+ ctx.jar,
69
+ form,
70
+ )
71
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
72
+ .then(function (resData) {
73
+ if (resData.error) {
74
+ switch (resData.error) {
75
+ case 1976004:
76
+ throw new utils.CustomError({
77
+ error: "Cannot alter admin status: you are not an admin.",
78
+ rawResponse: resData,
79
+ });
80
+ case 1357031:
81
+ throw new utils.CustomError({
82
+ error:
83
+ "Cannot alter admin status: this thread is not a group chat.",
84
+ rawResponse: resData,
85
+ });
86
+ default:
87
+ throw new utils.CustomError({
88
+ error: "Cannot alter admin status: unknown error.",
89
+ rawResponse: resData,
90
+ });
91
+ }
92
+ }
68
93
 
69
- callback();
70
- })
71
- .catch(function (err) {
72
- log.error("changeAdminStatus", err);
73
- return callback(err);
74
- });
94
+ callback();
95
+ })
96
+ .catch(function (err) {
97
+ console.error("changeAdminStatus", err);
98
+ return callback(err);
99
+ });
75
100
 
76
- return returnPromise;
77
- };
101
+ return returnPromise;
102
+ };
78
103
  };
79
-