rapido-fca 0.0.6 → 0.0.10
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/index.js +24 -17
- package/package.json +1 -1
- package/src/addExternalModule.js +23 -19
- package/src/addUserToGroup.js +97 -99
- package/src/changeAdminStatus.js +62 -86
- package/src/changeArchivedStatus.js +49 -49
- package/src/changeAvatar.js +108 -118
- package/src/changeBio.js +64 -63
- package/src/changeBlockedStatus.js +38 -40
- package/src/changeGroupImage.js +126 -129
- package/src/changeNickname.js +49 -49
- package/src/changeThreadColor.js +53 -53
- package/src/changeThreadEmoji.js +45 -45
- package/src/createNewGroup.js +72 -74
- package/src/createPoll.js +59 -59
- package/src/deleteMessage.js +50 -50
- package/src/deleteThread.js +50 -50
- package/src/editMessage.js +49 -51
- package/src/forwardAttachment.js +54 -54
- package/src/getCurrentUserID.js +3 -3
- package/src/getEmojiUrl.js +17 -17
- package/src/getFriendsList.js +67 -67
- package/src/getMessage.js +767 -806
- package/src/getThreadHistory.js +642 -656
- package/src/getThreadInfo.js +1 -1
- package/src/getThreadList.js +227 -199
- package/src/getThreadPictures.js +71 -51
- package/src/getUserID.js +58 -53
- package/src/getUserInfo.js +60 -52
- package/src/handleFriendRequest.js +65 -41
- package/src/handleMessageRequest.js +60 -42
- package/src/httpGet.js +57 -49
- package/src/httpPost.js +57 -48
- package/src/httpPostFormData.js +63 -0
- package/src/listenMqtt.js +827 -827
- package/src/logout.js +61 -61
- package/src/markAsDelivered.js +53 -42
- package/src/markAsRead.js +69 -59
- package/src/markAsReadAll.js +42 -32
- package/src/markAsSeen.js +54 -43
- package/src/muteThread.js +47 -40
- package/src/refreshFb_dtsg.js +69 -77
- package/src/removeUserFromGroup.js +67 -67
- package/src/resolvePhotoUrl.js +34 -34
- package/src/searchForThread.js +43 -43
- package/src/sendMessage.js +228 -80
- package/src/sendTypingIndicator.js +88 -86
- package/src/setEmojiReaction.js +59 -0
- package/src/setPostReaction.js +87 -90
- package/src/setTitle.js +72 -76
- package/src/threadColors.js +121 -121
- package/src/unfriend.js +43 -43
- package/src/unsendMessage.js +38 -34
- package/src/uploadAttachment.js +81 -79
- package/src/videoAttachment.js +76 -0
package/index.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
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();*/
|
|
6
9
|
log.maxRecordSize = 100;
|
|
7
10
|
var checkVerified = null;
|
|
8
11
|
const Boolean_Option = ['online', 'selfListen', 'listenEvents', 'updatePresence', 'forceLogin', 'autoMarkDelivery', 'autoMarkRead', 'listenTyping', 'autoReconnect', 'emitReady'];
|
|
@@ -111,10 +114,10 @@ function buildAPI(globalOptions, html, jar) {
|
|
|
111
114
|
}
|
|
112
115
|
} catch { }
|
|
113
116
|
if (fb_dtsg) {
|
|
114
|
-
log
|
|
117
|
+
console.log("Found fb_dtsg!");
|
|
115
118
|
}
|
|
116
119
|
} catch (e) {
|
|
117
|
-
log
|
|
120
|
+
console.log("Error finding fb_dtsg:", e);
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
extractFromHTML();
|
|
@@ -123,33 +126,33 @@ function buildAPI(globalOptions, html, jar) {
|
|
|
123
126
|
var userCookie = cookies.find(cookie => cookie.cookieString().startsWith("c_user="));
|
|
124
127
|
var tiktikCookie = cookies.find(cookie => cookie.cookieString().startsWith("i_user="));
|
|
125
128
|
if (!userCookie && !tiktikCookie) {
|
|
126
|
-
return log.error("
|
|
129
|
+
return log.error("Error! Your cookiestate is not valid!");
|
|
127
130
|
}
|
|
128
131
|
if (html.includes("/checkpoint/block/?next")) {
|
|
129
|
-
return log.error('
|
|
132
|
+
return log.error('error', "Appstate is dead rechange it!", 'error');
|
|
130
133
|
}
|
|
131
134
|
userID = (tiktikCookie || userCookie).cookieString().split("=")[1];
|
|
132
|
-
|
|
135
|
+
//logger.log(`${cra(`[ CONNECT ]`)} Logged in as ${userID}`, "DATABASE");
|
|
133
136
|
try { clearInterval(checkVerified); } catch (_) { }
|
|
134
137
|
const clientID = (Math.random() * 2147483648 | 0).toString(16);
|
|
135
|
-
let mqttEndpoint = `wss://edge-chat.facebook.com/chat?region=
|
|
136
|
-
let region = "
|
|
138
|
+
let mqttEndpoint = `wss://edge-chat.facebook.com/chat?region=frc&sid=${userID}`;
|
|
139
|
+
let region = "FRC";
|
|
137
140
|
|
|
138
141
|
try {
|
|
139
142
|
const endpointMatch = html.match(/"endpoint":"([^"]+)"/);
|
|
140
143
|
if (endpointMatch.input.includes("601051028565049")) {
|
|
141
|
-
|
|
142
|
-
|
|
144
|
+
console.log(`login error.`);
|
|
145
|
+
ditconmemay = true;
|
|
143
146
|
}
|
|
144
147
|
if (endpointMatch) {
|
|
145
148
|
mqttEndpoint = endpointMatch[1].replace(/\\\//g, '/');
|
|
146
149
|
const url = new URL(mqttEndpoint);
|
|
147
|
-
region = url.searchParams.get('region')?.toUpperCase() || "
|
|
150
|
+
region = url.searchParams.get('region')?.toUpperCase() || "FRC";
|
|
148
151
|
}
|
|
149
152
|
} catch (e) {
|
|
150
|
-
log
|
|
153
|
+
console.log('Using default MQTT endpoint');
|
|
151
154
|
}
|
|
152
|
-
log.info(
|
|
155
|
+
log.info('Logging in...');
|
|
153
156
|
var ctx = {
|
|
154
157
|
userID: userID,
|
|
155
158
|
jar: jar,
|
|
@@ -211,10 +214,11 @@ function buildAPI(globalOptions, html, jar) {
|
|
|
211
214
|
|
|
212
215
|
return newDtsg;
|
|
213
216
|
} catch (e) {
|
|
214
|
-
log
|
|
217
|
+
console.log("Error getting fresh dtsg:", e);
|
|
215
218
|
return null;
|
|
216
219
|
}
|
|
217
220
|
};
|
|
221
|
+
//if (noMqttData) api.htmlData = noMqttData;
|
|
218
222
|
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); });
|
|
219
223
|
api.listen = api.listenMqtt;
|
|
220
224
|
return {
|
|
@@ -247,7 +251,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
|
247
251
|
const cookieData = JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]");
|
|
248
252
|
jar.setCookie(utils.formatCookie(cookieData, "facebook"), "https://www.facebook.com");
|
|
249
253
|
});
|
|
250
|
-
log.info("
|
|
254
|
+
log.info("Logging in...");
|
|
251
255
|
const loginRes = await utils.post(
|
|
252
256
|
"https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110",
|
|
253
257
|
jar,
|
|
@@ -258,7 +262,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
|
258
262
|
const headers = loginRes.headers;
|
|
259
263
|
if (!headers.location) throw new Error("Wrong username/password.");
|
|
260
264
|
if (headers.location.includes('https://www.facebook.com/checkpoint/')) {
|
|
261
|
-
log.info("
|
|
265
|
+
log.info("login", "You have login approvals turned on.");
|
|
262
266
|
const checkpointRes = await utils.get(headers.location, jar, null, loginOptions);
|
|
263
267
|
await utils.saveCookies(jar)(checkpointRes);
|
|
264
268
|
const checkpointHtml = checkpointRes.body;
|
|
@@ -318,6 +322,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
|
318
322
|
};
|
|
319
323
|
}
|
|
320
324
|
|
|
325
|
+
|
|
321
326
|
function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
|
|
322
327
|
let mainPromise = null;
|
|
323
328
|
const jar = utils.getJar();
|
|
@@ -392,7 +397,7 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
|
|
|
392
397
|
|
|
393
398
|
mainPromise
|
|
394
399
|
.then(async () => {
|
|
395
|
-
log.info(
|
|
400
|
+
log.info('Login successful');
|
|
396
401
|
callback(null, api);
|
|
397
402
|
})
|
|
398
403
|
.catch(e => {
|
|
@@ -400,6 +405,7 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
|
|
|
400
405
|
});
|
|
401
406
|
}
|
|
402
407
|
|
|
408
|
+
|
|
403
409
|
function login(loginData, options, callback) {
|
|
404
410
|
if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
|
|
405
411
|
callback = options;
|
|
@@ -450,4 +456,5 @@ function login(loginData, options, callback) {
|
|
|
450
456
|
return returnPromise;
|
|
451
457
|
}
|
|
452
458
|
|
|
453
|
-
|
|
459
|
+
|
|
460
|
+
module.exports = login;
|
package/package.json
CHANGED
package/src/addExternalModule.js
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const utils = require("../utils");
|
|
4
|
+
const log = require("npmlog");
|
|
4
5
|
|
|
5
6
|
module.exports = function (defaultFuncs, api, ctx) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} else {
|
|
20
|
-
throw new Error(
|
|
21
|
-
`moduleObj must be an object, not ${utils.getType(moduleObj)}!`,
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
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
|
+
};
|
|
25
20
|
};
|
|
21
|
+
|
|
22
|
+
// example usage:
|
|
23
|
+
// api.addExternalModule({
|
|
24
|
+
// getCtx: (defaultFuncs, api, ctx, utils, log) => {
|
|
25
|
+
// return function getCtx() {
|
|
26
|
+
// return ctx;
|
|
27
|
+
// };
|
|
28
|
+
// }
|
|
29
|
+
// });
|
package/src/addUserToGroup.js
CHANGED
|
@@ -1,115 +1,113 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const utils = require("../utils");
|
|
4
|
-
|
|
4
|
+
const log = require("npmlog");
|
|
5
5
|
|
|
6
6
|
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
23
|
-
}
|
|
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
|
+
}
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
if (!callback) {
|
|
24
|
+
callback = function (err) {
|
|
25
|
+
if (err) {
|
|
26
|
+
return rejectFunc(err);
|
|
27
|
+
}
|
|
28
|
+
resolveFunc();
|
|
29
|
+
};
|
|
30
|
+
}
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
+
}
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
if (utils.getType(userID) !== "Array") {
|
|
45
|
+
userID = [userID];
|
|
46
|
+
}
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
+
};
|
|
77
75
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
+
}
|
|
90
88
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
form["log_message_data[added_participants][" + i + "]"] =
|
|
90
|
+
"fbid:" + userID[i];
|
|
91
|
+
}
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
+
}
|
|
105
103
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
return callback();
|
|
105
|
+
})
|
|
106
|
+
.catch(function (err) {
|
|
107
|
+
log.error("addUserToGroup", err);
|
|
108
|
+
return callback(err);
|
|
109
|
+
});
|
|
112
110
|
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
return returnPromise;
|
|
112
|
+
};
|
|
115
113
|
};
|
package/src/changeAdminStatus.js
CHANGED
|
@@ -1,103 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const utils = require("../utils");
|
|
4
|
-
|
|
4
|
+
const log = require("npmlog");
|
|
5
5
|
|
|
6
6
|
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
}
|
|
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
|
+
}
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
if (utils.getType(adminIDs) === "String") {
|
|
13
|
+
adminIDs = [adminIDs];
|
|
14
|
+
}
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
}
|
|
16
|
+
if (utils.getType(adminIDs) !== "Array") {
|
|
17
|
+
throw new utils.CustomError({ error: "changeAdminStatus: adminIDs must be an array or string" });
|
|
18
|
+
}
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
}
|
|
20
|
+
if (utils.getType(adminStatus) !== "Boolean") {
|
|
21
|
+
throw new utils.CustomError({ error: "changeAdminStatus: adminStatus must be a string" });
|
|
22
|
+
}
|
|
29
23
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
let resolveFunc = function () { };
|
|
25
|
+
let rejectFunc = function () { };
|
|
26
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
27
|
+
resolveFunc = resolve;
|
|
28
|
+
rejectFunc = reject;
|
|
29
|
+
});
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
if (!callback) {
|
|
32
|
+
callback = function (err) {
|
|
33
|
+
if (err) {
|
|
34
|
+
return rejectFunc(err);
|
|
35
|
+
}
|
|
36
|
+
resolveFunc();
|
|
37
|
+
};
|
|
38
|
+
}
|
|
45
39
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
) {
|
|
50
|
-
throw new utils.CustomError({
|
|
51
|
-
error: "changeAdminStatus: callback is not a function",
|
|
52
|
-
});
|
|
53
|
-
}
|
|
40
|
+
if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
|
|
41
|
+
throw new utils.CustomError({ error: "changeAdminStatus: callback is not a function" });
|
|
42
|
+
}
|
|
54
43
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
const form = {
|
|
45
|
+
"thread_fbid": threadID
|
|
46
|
+
};
|
|
58
47
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
48
|
+
let i = 0;
|
|
49
|
+
for (const u of adminIDs) {
|
|
50
|
+
form[`admin_ids[${i++}]`] = u;
|
|
51
|
+
}
|
|
52
|
+
form["add"] = adminStatus;
|
|
64
53
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
}
|
|
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
|
+
}
|
|
93
68
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
69
|
+
callback();
|
|
70
|
+
})
|
|
71
|
+
.catch(function (err) {
|
|
72
|
+
log.error("changeAdminStatus", err);
|
|
73
|
+
return callback(err);
|
|
74
|
+
});
|
|
100
75
|
|
|
101
|
-
|
|
102
|
-
|
|
76
|
+
return returnPromise;
|
|
77
|
+
};
|
|
103
78
|
};
|
|
79
|
+
|