alicezetion 1.0.1 → 1.0.3
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/alice/addExternalModule.js +19 -19
- package/alice/addUserToGroup.js +113 -113
- package/alice/changeAdminStatus.js +79 -79
- package/alice/changeArchivedStatus.js +55 -55
- package/alice/changeBio.js +77 -77
- package/alice/changeBlockedStatus.js +47 -47
- package/alice/changeGroupImage.js +129 -129
- package/alice/changeNickname.js +59 -59
- package/alice/changeThreadColor.js +71 -71
- package/alice/changeThreadEmoji.js +55 -55
- package/alice/{sendMessage.js → chat.js} +459 -459
- package/alice/createNewGroup.js +86 -86
- package/alice/createPoll.js +71 -71
- package/alice/deleteMessage.js +56 -56
- package/alice/deleteThread.js +56 -56
- package/alice/forwardAttachment.js +60 -60
- package/alice/getCurrentUserID.js +7 -7
- package/alice/getEmojiUrl.js +29 -29
- package/alice/getFriendsList.js +84 -84
- package/alice/getThreadHistory.js +645 -645
- package/alice/getThreadHistoryDeprecated.js +93 -93
- package/alice/getThreadInfo.js +206 -206
- package/alice/getThreadInfoDeprecated.js +80 -80
- package/alice/getThreadList.js +238 -238
- package/alice/getThreadListDeprecated.js +75 -75
- package/alice/getThreadPictures.js +79 -79
- package/alice/getUserID.js +66 -66
- package/alice/getUserInfo.js +72 -72
- package/alice/handleFriendRequest.js +61 -61
- package/alice/handleMessageRequest.js +65 -65
- package/alice/httpGet.js +52 -52
- package/alice/httpPost.js +52 -52
- package/alice/listenMqtt.js +789 -789
- package/alice/logout.js +75 -75
- package/alice/markAsDelivered.js +58 -58
- package/alice/markAsRead.js +80 -80
- package/alice/markAsSeen.js +59 -59
- package/alice/muteThread.js +52 -52
- package/alice/{setMessageReaction.js → react.js} +117 -117
- package/alice/removeUserFromGroup.js +79 -79
- package/alice/resolvePhotoUrl.js +45 -45
- package/alice/searchForThread.js +53 -53
- package/alice/{markAsReadAll.js → seen.js} +49 -49
- package/alice/sendTypingIndicator.js +103 -103
- package/alice/setPostReaction.js +76 -76
- package/alice/setTitle.js +86 -86
- package/alice/threadColors.js +57 -57
- package/alice/unfriend.js +52 -52
- package/alice/unsendMessage.js +49 -49
- package/index.js +604 -604
- package/package.json +74 -77
- package/test/data/shareAttach.js +146 -0
- package/test/data/something.mov +0 -0
- package/test/data/test.png +0 -0
- package/test/data/test.txt +7 -0
- package/test/example-config.json +18 -0
- package/test/test-page.js +140 -0
- package/test/test.js +385 -0
- package/utils.js +1357 -1359
- package/.cache/replit/modules.stamp +0 -0
- package/.travis.yml +0 -6
@@ -1 +1 @@
|
|
1
|
-
{"nonce":
|
1
|
+
{"nonce":6403169758816327948,"last_updated":{"seconds":1682857666,"nanos":141360000}}
|
@@ -1 +1 @@
|
|
1
|
-
{"entries":{"replit.nix":{"env":{"AR":"ar","AS":"as","CC":"gcc","CONFIG_SHELL":"/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-04-30T12:27:28.412615926Z"}],"channel":"","channel_nix_path":""}}}
|
@@ -1,19 +1,19 @@
|
|
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 (let apiName in moduleObj) {
|
9
|
-
if (utils.getType(moduleObj[apiName]) == "Function") {
|
10
|
-
api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
|
11
|
-
} else {
|
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)}!`);
|
17
|
-
}
|
18
|
-
};
|
19
|
-
};
|
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 (let apiName in moduleObj) {
|
9
|
+
if (utils.getType(moduleObj[apiName]) == "Function") {
|
10
|
+
api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
|
11
|
+
} else {
|
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)}!`);
|
17
|
+
}
|
18
|
+
};
|
19
|
+
};
|
package/alice/addUserToGroup.js
CHANGED
@@ -1,113 +1,113 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var utils = require("../utils");
|
4
|
-
var log = require("npmlog");
|
5
|
-
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
-
return function addUserToGroup(userID, threadID, callback) {
|
8
|
-
var resolveFunc = function(){};
|
9
|
-
var rejectFunc = function(){};
|
10
|
-
var returnPromise = new Promise(function (resolve, reject) {
|
11
|
-
resolveFunc = resolve;
|
12
|
-
rejectFunc = reject;
|
13
|
-
});
|
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
|
-
}
|
22
|
-
|
23
|
-
if (!callback) {
|
24
|
-
callback = function(err) {
|
25
|
-
if (err) {
|
26
|
-
return rejectFunc(err);
|
27
|
-
}
|
28
|
-
resolveFunc();
|
29
|
-
};
|
30
|
-
}
|
31
|
-
|
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
|
-
}
|
43
|
-
|
44
|
-
if (utils.getType(userID) !== "Array") {
|
45
|
-
userID = [userID];
|
46
|
-
}
|
47
|
-
|
48
|
-
var messageAndOTID = utils.generateOfflineThreadingID();
|
49
|
-
var form = {
|
50
|
-
client: "mercury",
|
51
|
-
action_type: "ma-type:log-message",
|
52
|
-
author: "fbid:" + 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
|
-
};
|
75
|
-
|
76
|
-
for (var i = 0; i < userID.length; i++) {
|
77
|
-
if (
|
78
|
-
utils.getType(userID[i]) !== "Number" &&
|
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];
|
91
|
-
}
|
92
|
-
|
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 { error: "Add to group failed." };
|
99
|
-
}
|
100
|
-
if (resData.error) {
|
101
|
-
throw resData;
|
102
|
-
}
|
103
|
-
|
104
|
-
return callback();
|
105
|
-
})
|
106
|
-
.catch(function(err) {
|
107
|
-
log.error("addUserToGroup", err);
|
108
|
-
return callback(err);
|
109
|
-
});
|
110
|
-
|
111
|
-
return returnPromise;
|
112
|
-
};
|
113
|
-
};
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
+
return function addUserToGroup(userID, threadID, callback) {
|
8
|
+
var resolveFunc = function(){};
|
9
|
+
var rejectFunc = function(){};
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
|
+
resolveFunc = resolve;
|
12
|
+
rejectFunc = reject;
|
13
|
+
});
|
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
|
+
}
|
22
|
+
|
23
|
+
if (!callback) {
|
24
|
+
callback = function(err) {
|
25
|
+
if (err) {
|
26
|
+
return rejectFunc(err);
|
27
|
+
}
|
28
|
+
resolveFunc();
|
29
|
+
};
|
30
|
+
}
|
31
|
+
|
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
|
+
}
|
43
|
+
|
44
|
+
if (utils.getType(userID) !== "Array") {
|
45
|
+
userID = [userID];
|
46
|
+
}
|
47
|
+
|
48
|
+
var messageAndOTID = utils.generateOfflineThreadingID();
|
49
|
+
var form = {
|
50
|
+
client: "mercury",
|
51
|
+
action_type: "ma-type:log-message",
|
52
|
+
author: "fbid:" + 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
|
+
};
|
75
|
+
|
76
|
+
for (var i = 0; i < userID.length; i++) {
|
77
|
+
if (
|
78
|
+
utils.getType(userID[i]) !== "Number" &&
|
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];
|
91
|
+
}
|
92
|
+
|
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 { error: "Add to group failed." };
|
99
|
+
}
|
100
|
+
if (resData.error) {
|
101
|
+
throw resData;
|
102
|
+
}
|
103
|
+
|
104
|
+
return callback();
|
105
|
+
})
|
106
|
+
.catch(function(err) {
|
107
|
+
log.error("addUserToGroup", err);
|
108
|
+
return callback(err);
|
109
|
+
});
|
110
|
+
|
111
|
+
return returnPromise;
|
112
|
+
};
|
113
|
+
};
|
@@ -1,79 +1,79 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
const utils = require("../utils");
|
4
|
-
const log = require("npmlog");
|
5
|
-
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
-
return function changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
|
8
|
-
if (utils.getType(threadID) !== "String") {
|
9
|
-
throw {error: "changeAdminStatus: threadID must be a string"};
|
10
|
-
}
|
11
|
-
|
12
|
-
if (utils.getType(adminIDs) === "String") {
|
13
|
-
adminIDs = [adminIDs];
|
14
|
-
}
|
15
|
-
|
16
|
-
if (utils.getType(adminIDs) !== "Array") {
|
17
|
-
throw {error: "changeAdminStatus: adminIDs must be an array or string"};
|
18
|
-
}
|
19
|
-
|
20
|
-
if (utils.getType(adminStatus) !== "Boolean") {
|
21
|
-
throw {error: "changeAdminStatus: adminStatus must be a string"};
|
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;
|
51
|
-
}
|
52
|
-
form["add"] = adminStatus;
|
53
|
-
|
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 { 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;
|
77
|
-
};
|
78
|
-
};
|
79
|
-
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const utils = require("../utils");
|
4
|
+
const log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
+
return function changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
|
8
|
+
if (utils.getType(threadID) !== "String") {
|
9
|
+
throw {error: "changeAdminStatus: threadID must be a string"};
|
10
|
+
}
|
11
|
+
|
12
|
+
if (utils.getType(adminIDs) === "String") {
|
13
|
+
adminIDs = [adminIDs];
|
14
|
+
}
|
15
|
+
|
16
|
+
if (utils.getType(adminIDs) !== "Array") {
|
17
|
+
throw {error: "changeAdminStatus: adminIDs must be an array or string"};
|
18
|
+
}
|
19
|
+
|
20
|
+
if (utils.getType(adminStatus) !== "Boolean") {
|
21
|
+
throw {error: "changeAdminStatus: adminStatus must be a string"};
|
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;
|
51
|
+
}
|
52
|
+
form["add"] = adminStatus;
|
53
|
+
|
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 { 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;
|
77
|
+
};
|
78
|
+
};
|
79
|
+
|
@@ -1,55 +1,55 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var utils = require("../utils");
|
4
|
-
var log = require("npmlog");
|
5
|
-
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
-
return function changeArchivedStatus(threadOrThreads, archive, callback) {
|
8
|
-
var resolveFunc = function(){};
|
9
|
-
var rejectFunc = function(){};
|
10
|
-
var returnPromise = new Promise(function (resolve, reject) {
|
11
|
-
resolveFunc = resolve;
|
12
|
-
rejectFunc = reject;
|
13
|
-
});
|
14
|
-
|
15
|
-
if (!callback) {
|
16
|
-
callback = function(err) {
|
17
|
-
if (err) {
|
18
|
-
return rejectFunc(err);
|
19
|
-
}
|
20
|
-
resolveFunc();
|
21
|
-
};
|
22
|
-
}
|
23
|
-
|
24
|
-
var form = {};
|
25
|
-
|
26
|
-
if (utils.getType(threadOrThreads) === "Array") {
|
27
|
-
for (var i = 0; i < threadOrThreads.length; i++) {
|
28
|
-
form["ids[" + threadOrThreads[i] + "]"] = archive;
|
29
|
-
}
|
30
|
-
} else {
|
31
|
-
form["ids[" + threadOrThreads + "]"] = archive;
|
32
|
-
}
|
33
|
-
|
34
|
-
defaultFuncs
|
35
|
-
.post(
|
36
|
-
"https://www.facebook.com/ajax/mercury/change_archived_status.php",
|
37
|
-
ctx.jar,
|
38
|
-
form
|
39
|
-
)
|
40
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
41
|
-
.then(function(resData) {
|
42
|
-
if (resData.error) {
|
43
|
-
throw resData;
|
44
|
-
}
|
45
|
-
|
46
|
-
return callback();
|
47
|
-
})
|
48
|
-
.catch(function(err) {
|
49
|
-
log.error("changeArchivedStatus", err);
|
50
|
-
return callback(err);
|
51
|
-
});
|
52
|
-
|
53
|
-
return returnPromise;
|
54
|
-
};
|
55
|
-
};
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
+
return function changeArchivedStatus(threadOrThreads, archive, callback) {
|
8
|
+
var resolveFunc = function(){};
|
9
|
+
var rejectFunc = function(){};
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
|
+
resolveFunc = resolve;
|
12
|
+
rejectFunc = reject;
|
13
|
+
});
|
14
|
+
|
15
|
+
if (!callback) {
|
16
|
+
callback = function(err) {
|
17
|
+
if (err) {
|
18
|
+
return rejectFunc(err);
|
19
|
+
}
|
20
|
+
resolveFunc();
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
var form = {};
|
25
|
+
|
26
|
+
if (utils.getType(threadOrThreads) === "Array") {
|
27
|
+
for (var i = 0; i < threadOrThreads.length; i++) {
|
28
|
+
form["ids[" + threadOrThreads[i] + "]"] = archive;
|
29
|
+
}
|
30
|
+
} else {
|
31
|
+
form["ids[" + threadOrThreads + "]"] = archive;
|
32
|
+
}
|
33
|
+
|
34
|
+
defaultFuncs
|
35
|
+
.post(
|
36
|
+
"https://www.facebook.com/ajax/mercury/change_archived_status.php",
|
37
|
+
ctx.jar,
|
38
|
+
form
|
39
|
+
)
|
40
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
41
|
+
.then(function(resData) {
|
42
|
+
if (resData.error) {
|
43
|
+
throw resData;
|
44
|
+
}
|
45
|
+
|
46
|
+
return callback();
|
47
|
+
})
|
48
|
+
.catch(function(err) {
|
49
|
+
log.error("changeArchivedStatus", err);
|
50
|
+
return callback(err);
|
51
|
+
});
|
52
|
+
|
53
|
+
return returnPromise;
|
54
|
+
};
|
55
|
+
};
|