alicezetion 1.2.4 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- package/.cache/replit/__replit_disk_meta.json +1 -1
- package/.cache/replit/nix/env.json +1 -1
- package/index.js +10 -2
- package/leiamnash/addExternalModule.js +6 -10
- package/leiamnash/addUserToGroup.js +16 -52
- package/leiamnash/changeAdminStatus.js +37 -69
- package/leiamnash/changeArchivedStatus.js +12 -26
- package/leiamnash/changeBio.js +6 -19
- package/leiamnash/changeBlockedStatus.js +3 -14
- package/leiamnash/changeGroupImage.js +16 -40
- package/leiamnash/changeNickname.js +11 -27
- package/leiamnash/changeThreadColor.js +10 -20
- package/leiamnash/changeThreadEmoji.js +10 -24
- package/leiamnash/chat.js +279 -414
- package/leiamnash/createNewGroup.js +12 -28
- package/leiamnash/createPoll.js +13 -25
- package/leiamnash/deleteMessage.js +12 -24
- package/leiamnash/deleteThread.js +11 -25
- package/leiamnash/forwardAttachment.js +13 -26
- package/leiamnash/forwardMessage.js +0 -0
- package/leiamnash/getCurrentUserID.js +1 -1
- package/leiamnash/getEmojiUrl.js +2 -4
- package/leiamnash/getFriendsList.js +10 -21
- package/leiamnash/getThreadHistory.js +58 -166
- package/leiamnash/getThreadHistoryDeprecated.js +20 -42
- package/leiamnash/getThreadInfo.js +25 -60
- package/leiamnash/getThreadInfoDeprecated.js +18 -42
- package/leiamnash/getThreadList.js +41 -66
- package/leiamnash/getThreadListDeprecated.js +14 -43
- package/leiamnash/getThreadPictures.js +17 -37
- package/leiamnash/getUserID.js +9 -14
- package/leiamnash/getUserInfo.js +12 -18
- package/leiamnash/handleFriendRequest.js +37 -52
- package/leiamnash/handleMessageRequest.js +14 -32
- package/leiamnash/httpGet.js +12 -17
- package/leiamnash/httpPost.js +12 -17
- package/leiamnash/listen.js +553 -0
- package/leiamnash/listenMqtt-Test.js +687 -0
- package/leiamnash/listenMqtt.js +1 -2
- package/leiamnash/logout.js +13 -20
- package/leiamnash/markAsDelivered.js +11 -22
- package/leiamnash/markAsRead.js +11 -21
- package/leiamnash/markAsReadAll.js +10 -20
- package/leiamnash/markAsSeen.js +7 -18
- package/leiamnash/muteThread.js +11 -18
- package/leiamnash/removeUserFromGroup.js +14 -48
- package/leiamnash/resolvePhotoUrl.js +8 -17
- package/leiamnash/searchForThread.js +10 -21
- package/leiamnash/sendTypingIndicator.js +14 -47
- package/leiamnash/setMessageReaction.js +12 -26
- package/leiamnash/setPostReaction.js +13 -26
- package/leiamnash/setTitle.js +13 -29
- package/leiamnash/threadColors.js +28 -44
- package/leiamnash/unfriend.js +9 -19
- package/leiamnash/unsendMessage.js +9 -19
- package/package.json +1 -1
- package/replit.nix +1 -3
- package/utils.js +0 -0
@@ -1 +1 @@
|
|
1
|
-
{"nonce":
|
1
|
+
{"nonce":4667484136687373514,"last_updated":{"seconds":1693008336,"nanos":139018000}}
|
@@ -1 +1 @@
|
|
1
|
-
{"entries":{"replit.nix":{"env":{"AR":"ar","AS":"as","CC":"gcc","CONFIG_SHELL":"/nix/store/dpjnjrqbgbm8a5wvi1hya01vd8wyvsq4-bash-4.4-p23/bin/bash","CXX":"g++","HOST_PATH":"/nix/store/bwxril521b35zlf4x2g32hll64rzfhck-nodejs-16.7.0/bin:/nix/store/
|
1
|
+
{"entries":{"replit.nix":{"env":{"AR":"ar","AS":"as","CC":"gcc","CONFIG_SHELL":"/nix/store/dpjnjrqbgbm8a5wvi1hya01vd8wyvsq4-bash-4.4-p23/bin/bash","CXX":"g++","HOST_PATH":"/nix/store/bwxril521b35zlf4x2g32hll64rzfhck-nodejs-16.7.0/bin:/nix/store/1570w56jrkvr90w9x158vyb5vahnk18v-coreutils-8.32/bin:/nix/store/ihxk2vlm0vi7c4j3gpm084kbxvz6v585-findutils-4.8.0/bin:/nix/store/kjx1mv85c5cgsrr4bwar22j7hbwj834m-diffutils-3.7/bin:/nix/store/gm2w08wwsa3vd500d8vq879s2lv65ldh-gnused-4.8/bin:/nix/store/v0slhpb2y3xa7gmv4q6gblkdk7n0f09j-gnugrep-3.6/bin:/nix/store/2wn093wbc6ps4brcsppxjd14vxvaa8a2-gawk-5.1.0/bin:/nix/store/5bxrjkyvqmzn1p897652y3lwa9fxagpw-gnutar-1.34/bin:/nix/store/liva1jnjdskrn57s42kfawr2zz66szzm-gzip-1.10/bin:/nix/store/ih2zkh2mbrx2c766ryk2i9hhlkly7snr-bzip2-1.0.6.0.2-bin/bin:/nix/store/pvkiiw0mp1yx0b21b7k105yywccychgh-gnumake-4.3/bin:/nix/store/dpjnjrqbgbm8a5wvi1hya01vd8wyvsq4-bash-4.4-p23/bin:/nix/store/aicl3kwfnaizk45aygm8bviqv7lk0a16-patch-2.7.6/bin:/nix/store/7jk6k46f56rszzc1bxi8mdrvcw53pym4-xz-5.2.5-bin/bin","LD":"ld","LOCALE_ARCHIVE":"/usr/lib/locale/locale-archive","NIX_BINTOOLS":"/nix/store/29bjq5hw1qglybp1a5f3ij9gxc2fyf94-binutils-wrapper-2.35.1","NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu":"1","NIX_BUILD_CORES":"8","NIX_BUILD_TOP":"/tmp","NIX_CC":"/nix/store/4xs1xyj8728yvh9y5v6ji819kwgfy2fv-gcc-wrapper-10.3.0","NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu":"1","NIX_CFLAGS_COMPILE":" -frandom-seed=wn4q3px71j -isystem /nix/store/bwxril521b35zlf4x2g32hll64rzfhck-nodejs-16.7.0/include -isystem /nix/store/bwxril521b35zlf4x2g32hll64rzfhck-nodejs-16.7.0/include","NIX_ENFORCE_NO_NATIVE":"1","NIX_HARDENING_ENABLE":"fortify stackprotector pic strictoverflow format relro bindnow","NIX_INDENT_MAKE":"1","NIX_LDFLAGS":"-rpath /nix/store/wn4q3px71j98mf9lcy14i6xlgmfhk75m-nix-shell/lib64 -rpath /nix/store/wn4q3px71j98mf9lcy14i6xlgmfhk75m-nix-shell/lib ","NIX_STORE":"/nix/store","NM":"nm","NODE_PATH":"/nix/store/bwxril521b35zlf4x2g32hll64rzfhck-nodejs-16.7.0/lib/node_modules","OBJCOPY":"objcopy","OBJDUMP":"objdump","PATH":"/nix/store/w07a7k61dw5gnsyxj3kgcq3shr76jax8-bash-interactive-4.4-p23/bin:/nix/store/435paza0j48aa9vgvf6r2l12nrg4ld11-patchelf-0.12/bin:/nix/store/4xs1xyj8728yvh9y5v6ji819kwgfy2fv-gcc-wrapper-10.3.0/bin:/nix/store/dlni53myj53kx20pi4yhm7p68lw17b07-gcc-10.3.0/bin:/nix/store/6z35qvn00xrjvaznv9kfy8xddbbdz4gl-glibc-2.33-47-bin/bin:/nix/store/1570w56jrkvr90w9x158vyb5vahnk18v-coreutils-8.32/bin:/nix/store/29bjq5hw1qglybp1a5f3ij9gxc2fyf94-binutils-wrapper-2.35.1/bin:/nix/store/v8imx1nvyz0hgvx9cbcmh6gp4ngw3ffj-binutils-2.35.1/bin:/nix/store/bwxril521b35zlf4x2g32hll64rzfhck-nodejs-16.7.0/bin:/nix/store/1570w56jrkvr90w9x158vyb5vahnk18v-coreutils-8.32/bin:/nix/store/ihxk2vlm0vi7c4j3gpm084kbxvz6v585-findutils-4.8.0/bin:/nix/store/kjx1mv85c5cgsrr4bwar22j7hbwj834m-diffutils-3.7/bin:/nix/store/gm2w08wwsa3vd500d8vq879s2lv65ldh-gnused-4.8/bin:/nix/store/v0slhpb2y3xa7gmv4q6gblkdk7n0f09j-gnugrep-3.6/bin:/nix/store/2wn093wbc6ps4brcsppxjd14vxvaa8a2-gawk-5.1.0/bin:/nix/store/5bxrjkyvqmzn1p897652y3lwa9fxagpw-gnutar-1.34/bin:/nix/store/liva1jnjdskrn57s42kfawr2zz66szzm-gzip-1.10/bin:/nix/store/ih2zkh2mbrx2c766ryk2i9hhlkly7snr-bzip2-1.0.6.0.2-bin/bin:/nix/store/pvkiiw0mp1yx0b21b7k105yywccychgh-gnumake-4.3/bin:/nix/store/dpjnjrqbgbm8a5wvi1hya01vd8wyvsq4-bash-4.4-p23/bin:/nix/store/aicl3kwfnaizk45aygm8bviqv7lk0a16-patch-2.7.6/bin:/nix/store/7jk6k46f56rszzc1bxi8mdrvcw53pym4-xz-5.2.5-bin/bin","RANLIB":"ranlib","READELF":"readelf","SIZE":"size","SOURCE_DATE_EPOCH":"315532800","STRINGS":"strings","STRIP":"strip","XDG_DATA_DIRS":"/nix/store/435paza0j48aa9vgvf6r2l12nrg4ld11-patchelf-0.12/share","_":"/nix/store/1570w56jrkvr90w9x158vyb5vahnk18v-coreutils-8.32/bin/env","__ETC_PROFILE_SOURCED":"1","buildInputs":"/nix/store/bwxril521b35zlf4x2g32hll64rzfhck-nodejs-16.7.0","builder":"/nix/store/dpjnjrqbgbm8a5wvi1hya01vd8wyvsq4-bash-4.4-p23/bin/bash","configureFlags":"","depsBuildBuild":"","depsBuildBuildPropagated":"","depsBuildTarget":"","depsBuildTargetPropagated":"","depsHostHost":"","depsHostHostPropagated":"","depsTargetTarget":"","depsTargetTargetPropagated":"","doCheck":"","doInstallCheck":"","name":"nix-shell","nativeBuildInputs":"","nobuildPhase":"echo\necho \"This derivation is not meant to be built, aborting\";\necho\nexit 1\n","out":"/nix/store/wn4q3px71j98mf9lcy14i6xlgmfhk75m-nix-shell","outputs":"out","patches":"","phases":"nobuildPhase","propagatedBuildInputs":"","propagatedNativeBuildInputs":"","shell":"/nix/store/dpjnjrqbgbm8a5wvi1hya01vd8wyvsq4-bash-4.4-p23/bin/bash","shellHook":"","stdenv":"/nix/store/r4bl79l2bdjawmr2rhhqvci56qh0fkvv-stdenv-linux","strictDeps":"","system":"x86_64-linux"},"dependencies":[{"path":"replit.nix","mod_time":"2023-08-26T00:05:17.951815802Z"}],"channel":"","channel_nix_path":""}}}
|
package/index.js
CHANGED
@@ -94,6 +94,8 @@ function buildAPI(globalOptions, html, jar) {
|
|
94
94
|
if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", "Checkpoint detected. Please log in with a browser to verify.");
|
95
95
|
|
96
96
|
var userID = maybeCookie[0].cookieString().split("=")[1].toString();
|
97
|
+
//log.info("login", `Logged in as ${userID}`);
|
98
|
+
|
97
99
|
try {
|
98
100
|
clearInterval(checkVerified);
|
99
101
|
} catch (_) {}
|
@@ -110,6 +112,7 @@ function buildAPI(globalOptions, html, jar) {
|
|
110
112
|
irisSeqID = oldFBMQTTMatch[1];
|
111
113
|
mqttEndpoint = oldFBMQTTMatch[2];
|
112
114
|
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
115
|
+
//log.info("login", `Got this account's message region: ${region}`);
|
113
116
|
} else {
|
114
117
|
let newFBMQTTMatch = html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/);
|
115
118
|
if (newFBMQTTMatch) {
|
@@ -121,6 +124,7 @@ function buildAPI(globalOptions, html, jar) {
|
|
121
124
|
if (legacyFBMQTTMatch) {
|
122
125
|
mqttEndpoint = legacyFBMQTTMatch[4];
|
123
126
|
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
127
|
+
log.warn("login", `Cannot get sequence ID with new RegExp. Fallback to old RegExp (without seqID)...`);
|
124
128
|
} else {
|
125
129
|
log.warn("login", "» Cannot get MQTT region & sequence ID.");
|
126
130
|
log.error("login", "» Please try closing and reopening your browser window or get new fbstate.");
|
@@ -259,6 +263,8 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
259
263
|
jar.setCookie(utils.formatCookie(cookieData, "facebook"), "https://www.facebook.com");
|
260
264
|
});
|
261
265
|
// ---------- Very Hacky Part Ends -----------------
|
266
|
+
|
267
|
+
log.info("login", "Logging in...");
|
262
268
|
return utils
|
263
269
|
.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
|
264
270
|
.then(utils.saveCookies(jar))
|
@@ -322,9 +328,10 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
322
328
|
}
|
323
329
|
})
|
324
330
|
.then(function() {
|
331
|
+
// Use the same form (safe I hope)
|
325
332
|
delete form.no_fido;
|
326
333
|
delete form.approvals_code;
|
327
|
-
form.name_action_selected = 'dont_save';
|
334
|
+
form.name_action_selected = 'dont_save'; //'save_device';
|
328
335
|
|
329
336
|
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
330
337
|
})
|
@@ -477,6 +484,7 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
|
|
477
484
|
// At the end we call the callback or catch an exception
|
478
485
|
mainPromise
|
479
486
|
.then(function() {
|
487
|
+
//log.info("login", 'Done logging in.');
|
480
488
|
return callback(null, api);
|
481
489
|
})
|
482
490
|
.catch(function(e) {
|
@@ -498,7 +506,7 @@ function login(loginData, options, callback) {
|
|
498
506
|
updatePresence: false,
|
499
507
|
forceLogin: false,
|
500
508
|
autoMarkDelivery: false,
|
501
|
-
autoMarkRead:
|
509
|
+
autoMarkRead: true,
|
502
510
|
autoReconnect: true,
|
503
511
|
logRecordSize: defaultLogRecordSize,
|
504
512
|
online: true,
|
@@ -2,18 +2,14 @@
|
|
2
2
|
|
3
3
|
const utils = require("../utils");
|
4
4
|
|
5
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
5
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
6
6
|
return function addExternalModule(moduleObj) {
|
7
7
|
if (utils.getType(moduleObj) == "Object") {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
throw new Error(`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(moduleObj[apiName])}!`);
|
13
|
-
}
|
14
|
-
}
|
15
|
-
} else {
|
16
|
-
throw new Error(`moduleObj must be an object, not ${utils.getType(moduleObj)}!`);
|
8
|
+
for (let apiName in moduleObj) {
|
9
|
+
if (utils.getType(moduleObj[apiName]) == "Function") api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
|
10
|
+
else throw new Error(`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(moduleObj[apiName])}!`);
|
11
|
+
}
|
17
12
|
}
|
13
|
+
else throw new Error(`moduleObj must be an object, not ${utils.getType(moduleObj)}!`);
|
18
14
|
};
|
19
15
|
};
|
@@ -3,47 +3,27 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function addUserToGroup(userID, threadID, callback) {
|
8
|
-
var resolveFunc = function(){};
|
9
|
-
var rejectFunc = function(){};
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
10
|
var returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
|
15
|
-
if (
|
16
|
-
!callback &&
|
17
|
-
(utils.getType(threadID) === "Function" ||
|
18
|
-
utils.getType(threadID) === "AsyncFunction")
|
19
|
-
) {
|
20
|
-
throw { error: "please pass a threadID as a second argument." };
|
21
|
-
}
|
15
|
+
if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
|
22
16
|
|
23
17
|
if (!callback) {
|
24
|
-
callback = function(err) {
|
25
|
-
if (err)
|
26
|
-
return rejectFunc(err);
|
27
|
-
}
|
18
|
+
callback = function (err) {
|
19
|
+
if (err) return rejectFunc(err);
|
28
20
|
resolveFunc();
|
29
21
|
};
|
30
22
|
}
|
31
23
|
|
32
|
-
if (
|
33
|
-
utils.getType(threadID) !== "Number" &&
|
34
|
-
utils.getType(threadID) !== "String"
|
35
|
-
) {
|
36
|
-
throw {
|
37
|
-
error:
|
38
|
-
"ThreadID should be of type Number or String and not " +
|
39
|
-
utils.getType(threadID) +
|
40
|
-
"."
|
41
|
-
};
|
42
|
-
}
|
24
|
+
if (utils.getType(threadID) !== "Number" && utils.getType(threadID) !== "String") throw { error: "ThreadID should be of type Number or String and not " + utils.getType(threadID) + "." };
|
43
25
|
|
44
|
-
if (utils.getType(userID) !== "Array")
|
45
|
-
userID = [userID];
|
46
|
-
}
|
26
|
+
if (utils.getType(userID) !== "Array") userID = [userID];
|
47
27
|
|
48
28
|
var messageAndOTID = utils.generateOfflineThreadingID();
|
49
29
|
var form = {
|
@@ -74,40 +54,24 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
74
54
|
};
|
75
55
|
|
76
56
|
for (var i = 0; i < userID.length; i++) {
|
77
|
-
if (
|
78
|
-
|
79
|
-
utils.getType(userID[i]) !== "String"
|
80
|
-
) {
|
81
|
-
throw {
|
82
|
-
error:
|
83
|
-
"Elements of userID should be of type Number or String and not " +
|
84
|
-
utils.getType(userID[i]) +
|
85
|
-
"."
|
86
|
-
};
|
87
|
-
}
|
88
|
-
|
89
|
-
form["log_message_data[added_participants][" + i + "]"] =
|
90
|
-
"fbid:" + userID[i];
|
57
|
+
if (utils.getType(userID[i]) !== "Number" && utils.getType(userID[i]) !== "String") throw { error: "Elements of userID should be of type Number or String and not " + utils.getType(userID[i]) + "." };
|
58
|
+
form["log_message_data[added_participants][" + i + "]"] = "fbid:" + userID[i];
|
91
59
|
}
|
92
60
|
|
93
61
|
defaultFuncs
|
94
62
|
.post("https://www.facebook.com/messaging/send/", ctx.jar, form)
|
95
63
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
96
|
-
.then(function(resData) {
|
97
|
-
if (!resData) {
|
98
|
-
|
99
|
-
}
|
100
|
-
if (resData.error) {
|
101
|
-
throw resData;
|
102
|
-
}
|
64
|
+
.then(function (resData) {
|
65
|
+
if (!resData) throw { error: "Add to group failed." };
|
66
|
+
if (resData.error) throw resData;
|
103
67
|
|
104
68
|
return callback();
|
105
69
|
})
|
106
|
-
.catch(function(err) {
|
107
|
-
log.error("addUserToGroup",
|
70
|
+
.catch(function (err) {
|
71
|
+
log.error("addUserToGroup", "» Cannot add user to the voice chat. Please try again after");
|
108
72
|
return callback(err);
|
109
73
|
});
|
110
|
-
|
74
|
+
|
111
75
|
return returnPromise;
|
112
76
|
};
|
113
77
|
};
|
@@ -1,79 +1,47 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
const utils = require("../utils");
|
4
|
-
const log = require("npmlog");
|
5
4
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
-
return function changeAdminStatus(threadID,
|
8
|
-
if (utils.getType(threadID) !== "String") {
|
9
|
-
|
5
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
6
|
+
return function changeAdminStatus(threadID, adminID, adminStatus) {
|
7
|
+
if (utils.getType(threadID) !== "String") throw { error: "changeAdminStatus: threadID must be a string" };
|
8
|
+
if (utils.getType(adminID) !== "String" && utils.getType(adminID) !== "Array") throw { error: "changeAdminStatus: adminID must be a string or an array" };
|
9
|
+
if (utils.getType(adminStatus) !== "Boolean") throw { error: "changeAdminStatus: adminStatus must be true or false" };
|
10
|
+
|
11
|
+
let wsContent = {
|
12
|
+
request_id: 1,
|
13
|
+
type: 3,
|
14
|
+
payload: {
|
15
|
+
version_id: '3816854585040595',
|
16
|
+
tasks: [],
|
17
|
+
epoch_id: 6763184801413415579,
|
18
|
+
data_trace_id: null
|
19
|
+
},
|
20
|
+
app_id: '772021112871879'
|
10
21
|
}
|
11
22
|
|
12
|
-
if (utils.getType(
|
13
|
-
|
23
|
+
if (utils.getType(adminID) === "Array") {
|
24
|
+
for (let i = 0; i < adminID.length; i++) {
|
25
|
+
wsContent.payload.tasks.push({
|
26
|
+
label: '25',
|
27
|
+
payload: JSON.stringify({ thread_key: threadID, contact_id: adminID[i], is_admin: adminStatus }),
|
28
|
+
queue_name: 'admin_status',
|
29
|
+
task_id: i + 1,
|
30
|
+
failure_count: null
|
31
|
+
});
|
32
|
+
}
|
14
33
|
}
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
var resolveFunc = function(){};
|
25
|
-
var rejectFunc = function(){};
|
26
|
-
var returnPromise = new Promise(function (resolve, reject) {
|
27
|
-
resolveFunc = resolve;
|
28
|
-
rejectFunc = reject;
|
29
|
-
});
|
30
|
-
|
31
|
-
if (!callback) {
|
32
|
-
callback = function (err) {
|
33
|
-
if (err) {
|
34
|
-
return rejectFunc(err);
|
35
|
-
}
|
36
|
-
resolveFunc();
|
37
|
-
};
|
38
|
-
}
|
39
|
-
|
40
|
-
if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
|
41
|
-
throw {error: "changeAdminStatus: callback is not a function"};
|
42
|
-
}
|
43
|
-
|
44
|
-
let form = {
|
45
|
-
"thread_fbid": threadID,
|
46
|
-
};
|
47
|
-
|
48
|
-
let i = 0;
|
49
|
-
for (let u of adminIDs) {
|
50
|
-
form[`admin_ids[${i++}]`] = u;
|
34
|
+
else {
|
35
|
+
wsContent.payload.tasks.push({
|
36
|
+
label: '25',
|
37
|
+
payload: JSON.stringify({ thread_key: threadID, contact_id: adminID, is_admin: adminStatus }),
|
38
|
+
queue_name: 'admin_status',
|
39
|
+
task_id: 1,
|
40
|
+
failure_count: null
|
41
|
+
});
|
51
42
|
}
|
52
|
-
form["add"] = adminStatus;
|
53
43
|
|
54
|
-
|
55
|
-
|
56
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
57
|
-
.then(function(resData) {
|
58
|
-
if (resData.error) {
|
59
|
-
switch (resData.error) {
|
60
|
-
case 1976004:
|
61
|
-
throw { error: "Cannot alter admin status: you are not an admin.", rawResponse: resData };
|
62
|
-
case 1357031:
|
63
|
-
throw { error: "Cannot alter admin status: this thread is not a group chat.", rawResponse: resData };
|
64
|
-
default:
|
65
|
-
throw { error: "Cannot alter admin status: unknown error.", rawResponse: resData };
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
callback();
|
70
|
-
})
|
71
|
-
.catch(function(err) {
|
72
|
-
log.error("changeAdminStatus", err);
|
73
|
-
return callback(err);
|
74
|
-
});
|
75
|
-
|
76
|
-
return returnPromise;
|
44
|
+
wsContent.payload = JSON.stringify(wsContent.payload);
|
45
|
+
return new Promise((resolve, reject) => ctx.mqttClient && ctx.mqttClient.publish('/ls_req', JSON.stringify(wsContent), {}, (err, _packet) => err ? reject(err) : resolve()));
|
77
46
|
};
|
78
|
-
};
|
79
|
-
|
47
|
+
};
|
@@ -3,53 +3,39 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function changeArchivedStatus(threadOrThreads, archive, callback) {
|
8
|
-
var resolveFunc = function(){};
|
9
|
-
var rejectFunc = function(){};
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
10
|
var returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
|
15
15
|
if (!callback) {
|
16
|
-
callback = function(err) {
|
17
|
-
if (err)
|
18
|
-
return rejectFunc(err);
|
19
|
-
}
|
16
|
+
callback = function (err) {
|
17
|
+
if (err) return rejectFunc(err);
|
20
18
|
resolveFunc();
|
21
19
|
};
|
22
20
|
}
|
23
21
|
|
24
22
|
var form = {};
|
25
23
|
|
26
|
-
if (utils.getType(threadOrThreads) === "Array")
|
27
|
-
|
28
|
-
form["ids[" + threadOrThreads[i] + "]"] = archive;
|
29
|
-
}
|
30
|
-
} else {
|
31
|
-
form["ids[" + threadOrThreads + "]"] = archive;
|
32
|
-
}
|
24
|
+
if (utils.getType(threadOrThreads) === "Array") for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + threadOrThreads[i] + "]"] = archive;
|
25
|
+
else form["ids[" + threadOrThreads + "]"] = archive;
|
33
26
|
|
34
27
|
defaultFuncs
|
35
|
-
.post(
|
36
|
-
"https://www.facebook.com/ajax/mercury/change_archived_status.php",
|
37
|
-
ctx.jar,
|
38
|
-
form
|
39
|
-
)
|
28
|
+
.post("https://www.facebook.com/ajax/mercury/change_archived_status.php", ctx.jar, form)
|
40
29
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
41
|
-
.then(function(resData) {
|
42
|
-
if (resData.error)
|
43
|
-
throw resData;
|
44
|
-
}
|
45
|
-
|
30
|
+
.then(function (resData) {
|
31
|
+
if (resData.error) throw resData;
|
46
32
|
return callback();
|
47
33
|
})
|
48
|
-
.catch(function(err) {
|
34
|
+
.catch(function (err) {
|
49
35
|
log.error("changeArchivedStatus", err);
|
50
36
|
return callback(err);
|
51
37
|
});
|
52
|
-
|
38
|
+
|
53
39
|
return returnPromise;
|
54
40
|
};
|
55
41
|
};
|
package/leiamnash/changeBio.js
CHANGED
@@ -13,22 +13,16 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
13
13
|
});
|
14
14
|
|
15
15
|
if (!callback) {
|
16
|
-
if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction")
|
17
|
-
|
18
|
-
} else {
|
16
|
+
if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") callback = publish;
|
17
|
+
else {
|
19
18
|
callback = function (err) {
|
20
|
-
if (err)
|
21
|
-
return rejectFunc(err);
|
22
|
-
}
|
19
|
+
if (err) return rejectFunc(err);
|
23
20
|
resolveFunc();
|
24
21
|
};
|
25
22
|
}
|
26
23
|
}
|
27
24
|
|
28
|
-
if (utils.getType(publish) != "Boolean")
|
29
|
-
publish = false;
|
30
|
-
}
|
31
|
-
|
25
|
+
if (utils.getType(publish) != "Boolean") publish = false;
|
32
26
|
if (utils.getType(bio) != "String") {
|
33
27
|
bio = "";
|
34
28
|
publish = false;
|
@@ -54,17 +48,10 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
54
48
|
};
|
55
49
|
|
56
50
|
defaultFuncs
|
57
|
-
.post(
|
58
|
-
"https://www.facebook.com/api/graphql/",
|
59
|
-
ctx.jar,
|
60
|
-
form
|
61
|
-
)
|
51
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
62
52
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
63
53
|
.then(function (resData) {
|
64
|
-
if (resData.errors)
|
65
|
-
throw resData;
|
66
|
-
}
|
67
|
-
|
54
|
+
if (resData.errors) throw resData;
|
68
55
|
return callback();
|
69
56
|
})
|
70
57
|
.catch(function (err) {
|
@@ -14,28 +14,17 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
14
14
|
|
15
15
|
if (!callback) {
|
16
16
|
callback = function (err) {
|
17
|
-
if (err)
|
18
|
-
return rejectFunc(err);
|
19
|
-
}
|
17
|
+
if (err) return rejectFunc(err);
|
20
18
|
resolveFunc();
|
21
19
|
};
|
22
20
|
}
|
23
21
|
|
24
22
|
defaultFuncs
|
25
|
-
.post(
|
26
|
-
`https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`,
|
27
|
-
ctx.jar,
|
28
|
-
{
|
29
|
-
fbid: userID
|
30
|
-
}
|
31
|
-
)
|
23
|
+
.post(`https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`, ctx.jar, { fbid: userID })
|
32
24
|
.then(utils.saveCookies(ctx.jar))
|
33
25
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
34
26
|
.then(function (resData) {
|
35
|
-
if (resData.error)
|
36
|
-
throw resData;
|
37
|
-
}
|
38
|
-
|
27
|
+
if (resData.error) throw resData;
|
39
28
|
return callback();
|
40
29
|
})
|
41
30
|
.catch(function (err) {
|
@@ -4,7 +4,7 @@ var utils = require("../utils");
|
|
4
4
|
var log = require("npmlog");
|
5
5
|
var bluebird = require("bluebird");
|
6
6
|
|
7
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
8
8
|
function handleUpload(image, callback) {
|
9
9
|
var uploads = [];
|
10
10
|
|
@@ -15,18 +15,10 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
15
15
|
|
16
16
|
uploads.push(
|
17
17
|
defaultFuncs
|
18
|
-
.postFormData(
|
19
|
-
"https://upload.facebook.com/ajax/mercury/upload.php",
|
20
|
-
ctx.jar,
|
21
|
-
form,
|
22
|
-
{}
|
23
|
-
)
|
18
|
+
.postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
|
24
19
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
25
|
-
.then(function(resData) {
|
26
|
-
if (resData.error)
|
27
|
-
throw resData;
|
28
|
-
}
|
29
|
-
|
20
|
+
.then(function (resData) {
|
21
|
+
if (resData.error) throw resData;
|
30
22
|
return resData.payload.metadata[0];
|
31
23
|
})
|
32
24
|
);
|
@@ -34,36 +26,26 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
34
26
|
// resolve all promises
|
35
27
|
bluebird
|
36
28
|
.all(uploads)
|
37
|
-
.then(
|
38
|
-
|
39
|
-
})
|
40
|
-
.catch(function(err) {
|
29
|
+
.then(resData => callback(null, resData))
|
30
|
+
.catch(function (err) {
|
41
31
|
log.error("handleUpload", err);
|
42
32
|
return callback(err);
|
43
33
|
});
|
44
34
|
}
|
45
35
|
|
46
36
|
return function changeGroupImage(image, threadID, callback) {
|
47
|
-
if (
|
48
|
-
!callback &&
|
49
|
-
(utils.getType(threadID) === "Function" ||
|
50
|
-
utils.getType(threadID) === "AsyncFunction")
|
51
|
-
) {
|
52
|
-
throw { error: "please pass a threadID as a second argument." };
|
53
|
-
}
|
37
|
+
if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
|
54
38
|
|
55
|
-
var resolveFunc = function(){};
|
56
|
-
var rejectFunc = function(){};
|
39
|
+
var resolveFunc = function () { };
|
40
|
+
var rejectFunc = function () { };
|
57
41
|
var returnPromise = new Promise(function (resolve, reject) {
|
58
42
|
resolveFunc = resolve;
|
59
43
|
rejectFunc = reject;
|
60
44
|
});
|
61
45
|
|
62
46
|
if (!callback) {
|
63
|
-
callback = function(err) {
|
64
|
-
if (err)
|
65
|
-
return rejectFunc(err);
|
66
|
-
}
|
47
|
+
callback = function (err) {
|
48
|
+
if (err) return rejectFunc(err);
|
67
49
|
resolveFunc();
|
68
50
|
};
|
69
51
|
}
|
@@ -98,10 +80,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
98
80
|
timestamp_time_passed: "0"
|
99
81
|
};
|
100
82
|
|
101
|
-
handleUpload(image, function(err, payload) {
|
102
|
-
if (err)
|
103
|
-
return callback(err);
|
104
|
-
}
|
83
|
+
handleUpload(image, function (err, payload) {
|
84
|
+
if (err) return callback(err);
|
105
85
|
|
106
86
|
form["thread_image_id"] = payload[0]["image_id"];
|
107
87
|
form["thread_id"] = threadID;
|
@@ -109,16 +89,12 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
109
89
|
defaultFuncs
|
110
90
|
.post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
|
111
91
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
112
|
-
.then(function(resData) {
|
92
|
+
.then(function (resData) {
|
113
93
|
// check for errors here
|
114
|
-
|
115
|
-
if (resData.error) {
|
116
|
-
throw resData;
|
117
|
-
}
|
118
|
-
|
94
|
+
if (resData.error) throw resData;
|
119
95
|
return callback();
|
120
96
|
})
|
121
|
-
.catch(function(err) {
|
97
|
+
.catch(function (err) {
|
122
98
|
log.error("changeGroupImage", err);
|
123
99
|
return callback(err);
|
124
100
|
});
|
@@ -3,19 +3,17 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function changeNickname(nickname, threadID, participantID, callback) {
|
8
|
-
var resolveFunc = function(){};
|
9
|
-
var rejectFunc = function(){};
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
10
|
var returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
if (!callback) {
|
15
15
|
callback = function (err) {
|
16
|
-
if (err)
|
17
|
-
return rejectFunc(err);
|
18
|
-
}
|
16
|
+
if (err) return rejectFunc(err);
|
19
17
|
resolveFunc();
|
20
18
|
};
|
21
19
|
}
|
@@ -27,30 +25,16 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
27
25
|
};
|
28
26
|
|
29
27
|
defaultFuncs
|
30
|
-
.post(
|
31
|
-
"https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1",
|
32
|
-
ctx.jar,
|
33
|
-
form
|
34
|
-
)
|
28
|
+
.post("https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1", ctx.jar, form)
|
35
29
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
36
|
-
.then(function(resData) {
|
37
|
-
if (resData.error === 1545014) {
|
38
|
-
|
39
|
-
|
40
|
-
if (resData.error === 1357031) {
|
41
|
-
throw {
|
42
|
-
error:
|
43
|
-
"Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname."
|
44
|
-
};
|
45
|
-
}
|
46
|
-
if (resData.error) {
|
47
|
-
throw resData;
|
48
|
-
}
|
49
|
-
|
30
|
+
.then(function (resData) {
|
31
|
+
if (resData.error === 1545014) throw { error: "Trying to change nickname of user isn't in thread" };
|
32
|
+
if (resData.error === 1357031) throw { error: "Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname." };
|
33
|
+
if (resData.error) throw resData;
|
50
34
|
return callback();
|
51
35
|
})
|
52
|
-
.catch(function(err) {
|
53
|
-
log.error("changeNickname",
|
36
|
+
.catch(function (err) {
|
37
|
+
log.error("changeNickname", "Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname.");
|
54
38
|
return callback(err);
|
55
39
|
});
|
56
40
|
|