alicezetion 1.0.0 → 1.0.1
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/alice/addExternalModule.js +19 -0
- package/alice/{add.js → addUserToGroup.js} +16 -2
- package/alice/{admin.js → changeAdminStatus.js} +17 -3
- package/alice/{archive.js → changeArchivedStatus.js} +16 -2
- package/alice/changeBio.js +77 -0
- package/alice/changeBlockedStatus.js +47 -0
- package/alice/{gcimage.js → changeGroupImage.js} +16 -2
- package/alice/{nickname.js → changeNickname.js} +17 -2
- package/alice/changeThreadColor.js +71 -0
- package/alice/{emoji.js → changeThreadEmoji.js} +16 -2
- package/alice/createNewGroup.js +86 -0
- package/alice/{poll.js → createPoll.js} +18 -2
- package/alice/{deletemsg.js → deleteMessage.js} +15 -2
- package/alice/{deletegc.js → deleteThread.js} +15 -2
- package/alice/{forward.js → forwardAttachment.js} +16 -3
- package/alice/{id.js → getCurrentUserID.js} +1 -1
- package/alice/{friend.js → getFriendsList.js} +17 -3
- package/alice/{history.js → getThreadHistory.js} +19 -6
- package/alice/{gchistorydeprecated.js → getThreadHistoryDeprecated.js} +18 -1
- package/alice/{gcinfo.js → getThreadInfo.js} +49 -13
- package/alice/{gcinfodeprecated.js → getThreadInfoDeprecated.js} +17 -2
- package/alice/{gclist.js → getThreadList.js} +27 -9
- package/alice/{gclistdeprecated.js → getThreadListDeprecated.js} +1 -1
- package/alice/{gcimg.js → getThreadPictures.js} +15 -2
- package/alice/{userid.js → getUserID.js} +16 -2
- package/alice/{userinfo.js → getUserInfo.js} +17 -2
- package/alice/handleFriendRequest.js +61 -0
- package/alice/{msgrequest.js → handleMessageRequest.js} +16 -2
- package/alice/httpGet.js +52 -0
- package/alice/httpPost.js +52 -0
- package/alice/listenMqtt.js +363 -134
- package/alice/logout.js +18 -2
- package/alice/{delivered.js → markAsDelivered.js} +19 -2
- package/alice/markAsRead.js +80 -0
- package/alice/{seen.js → markAsReadAll.js} +16 -2
- package/alice/markAsSeen.js +59 -0
- package/alice/{mute.js → muteThread.js} +16 -2
- package/alice/{kick.js → removeUserFromGroup.js} +16 -2
- package/alice/{resolveimgurl.js → resolvePhotoUrl.js} +16 -2
- package/alice/{gcsearch.js → searchForThread.js} +16 -2
- package/alice/{chat.js → sendMessage.js} +78 -34
- package/alice/sendTypingIndicator.js +103 -0
- package/alice/{react.js → setMessageReaction.js} +39 -4
- package/alice/setPostReaction.js +76 -0
- package/alice/{title.js → setTitle.js} +16 -3
- package/alice/threadColors.js +57 -0
- package/alice/unfriend.js +52 -0
- package/alice/{unsend.js → unsendMessage.js} +16 -2
- package/index.js +324 -143
- package/package.json +19 -10
- package/utils.js +137 -61
- package/README.md +0 -40
- package/alice/block.js +0 -72
- package/alice/color.js +0 -53
- package/alice/gcolor.js +0 -22
- package/alice/listen.js +0 -553
- package/alice/read.js +0 -52
- package/alice/typeindicator.js +0 -77
- /package/alice/{emojiurl.js → getEmojiUrl.js} +0 -0
@@ -1 +1 @@
|
|
1
|
-
{"nonce":
|
1
|
+
{"nonce":4923440853840356939,"last_updated":{"seconds":1678368400,"nanos":589579000}}
|
@@ -0,0 +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
|
+
};
|
@@ -3,8 +3,15 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
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
|
+
|
8
15
|
if (
|
9
16
|
!callback &&
|
10
17
|
(utils.getType(threadID) === "Function" ||
|
@@ -14,7 +21,12 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
14
21
|
}
|
15
22
|
|
16
23
|
if (!callback) {
|
17
|
-
callback = function() {
|
24
|
+
callback = function(err) {
|
25
|
+
if (err) {
|
26
|
+
return rejectFunc(err);
|
27
|
+
}
|
28
|
+
resolveFunc();
|
29
|
+
};
|
18
30
|
}
|
19
31
|
|
20
32
|
if (
|
@@ -95,5 +107,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
95
107
|
log.error("addUserToGroup", err);
|
96
108
|
return callback(err);
|
97
109
|
});
|
110
|
+
|
111
|
+
return returnPromise;
|
98
112
|
};
|
99
113
|
};
|
@@ -3,7 +3,7 @@
|
|
3
3
|
const utils = require("../utils");
|
4
4
|
const log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
|
8
8
|
if (utils.getType(threadID) !== "String") {
|
9
9
|
throw {error: "changeAdminStatus: threadID must be a string"};
|
@@ -21,8 +21,20 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
21
21
|
throw {error: "changeAdminStatus: adminStatus must be a string"};
|
22
22
|
}
|
23
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
|
+
|
24
31
|
if (!callback) {
|
25
|
-
callback = ()
|
32
|
+
callback = function (err) {
|
33
|
+
if (err) {
|
34
|
+
return rejectFunc(err);
|
35
|
+
}
|
36
|
+
resolveFunc();
|
37
|
+
};
|
26
38
|
}
|
27
39
|
|
28
40
|
if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
|
@@ -35,7 +47,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
35
47
|
|
36
48
|
let i = 0;
|
37
49
|
for (let u of adminIDs) {
|
38
|
-
form[`admin_ids[${i++}]`] = u
|
50
|
+
form[`admin_ids[${i++}]`] = u;
|
39
51
|
}
|
40
52
|
form["add"] = adminStatus;
|
41
53
|
|
@@ -60,6 +72,8 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
60
72
|
log.error("changeAdminStatus", err);
|
61
73
|
return callback(err);
|
62
74
|
});
|
75
|
+
|
76
|
+
return returnPromise;
|
63
77
|
};
|
64
78
|
};
|
65
79
|
|
@@ -3,10 +3,22 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
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
|
+
|
8
15
|
if (!callback) {
|
9
|
-
callback = function() {
|
16
|
+
callback = function(err) {
|
17
|
+
if (err) {
|
18
|
+
return rejectFunc(err);
|
19
|
+
}
|
20
|
+
resolveFunc();
|
21
|
+
};
|
10
22
|
}
|
11
23
|
|
12
24
|
var form = {};
|
@@ -37,5 +49,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
37
49
|
log.error("changeArchivedStatus", err);
|
38
50
|
return callback(err);
|
39
51
|
});
|
52
|
+
|
53
|
+
return returnPromise;
|
40
54
|
};
|
41
55
|
};
|
@@ -0,0 +1,77 @@
|
|
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 changeBio(bio, publish, 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
|
+
if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") {
|
17
|
+
callback = publish;
|
18
|
+
} else {
|
19
|
+
callback = function (err) {
|
20
|
+
if (err) {
|
21
|
+
return rejectFunc(err);
|
22
|
+
}
|
23
|
+
resolveFunc();
|
24
|
+
};
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
if (utils.getType(publish) != "Boolean") {
|
29
|
+
publish = false;
|
30
|
+
}
|
31
|
+
|
32
|
+
if (utils.getType(bio) != "String") {
|
33
|
+
bio = "";
|
34
|
+
publish = false;
|
35
|
+
}
|
36
|
+
|
37
|
+
var form = {
|
38
|
+
fb_api_caller_class: "RelayModern",
|
39
|
+
fb_api_req_friendly_name: "ProfileCometSetBioMutation",
|
40
|
+
// This doc_is is valid as of May 23, 2020
|
41
|
+
doc_id: "2725043627607610",
|
42
|
+
variables: JSON.stringify({
|
43
|
+
input: {
|
44
|
+
bio: bio,
|
45
|
+
publish_bio_feed_story: publish,
|
46
|
+
actor_id: ctx.userID,
|
47
|
+
client_mutation_id: Math.round(Math.random() * 1024).toString()
|
48
|
+
},
|
49
|
+
hasProfileTileViewID: false,
|
50
|
+
profileTileViewID: null,
|
51
|
+
scale: 1
|
52
|
+
}),
|
53
|
+
av: ctx.userID
|
54
|
+
};
|
55
|
+
|
56
|
+
defaultFuncs
|
57
|
+
.post(
|
58
|
+
"https://www.facebook.com/api/graphql/",
|
59
|
+
ctx.jar,
|
60
|
+
form
|
61
|
+
)
|
62
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
63
|
+
.then(function (resData) {
|
64
|
+
if (resData.errors) {
|
65
|
+
throw resData;
|
66
|
+
}
|
67
|
+
|
68
|
+
return callback();
|
69
|
+
})
|
70
|
+
.catch(function (err) {
|
71
|
+
log.error("changeBio", err);
|
72
|
+
return callback(err);
|
73
|
+
});
|
74
|
+
|
75
|
+
return returnPromise;
|
76
|
+
};
|
77
|
+
};
|
@@ -0,0 +1,47 @@
|
|
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 changeBlockedStatus(userID, block, 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
|
+
defaultFuncs
|
25
|
+
.post(
|
26
|
+
`https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`,
|
27
|
+
ctx.jar,
|
28
|
+
{
|
29
|
+
fbid: userID
|
30
|
+
}
|
31
|
+
)
|
32
|
+
.then(utils.saveCookies(ctx.jar))
|
33
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
34
|
+
.then(function (resData) {
|
35
|
+
if (resData.error) {
|
36
|
+
throw resData;
|
37
|
+
}
|
38
|
+
|
39
|
+
return callback();
|
40
|
+
})
|
41
|
+
.catch(function (err) {
|
42
|
+
log.error("changeBlockedStatus", err);
|
43
|
+
return callback(err);
|
44
|
+
});
|
45
|
+
return returnPromise;
|
46
|
+
};
|
47
|
+
};
|
@@ -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,
|
7
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
8
8
|
function handleUpload(image, callback) {
|
9
9
|
var uploads = [];
|
10
10
|
|
@@ -52,8 +52,20 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
52
52
|
throw { error: "please pass a threadID as a second argument." };
|
53
53
|
}
|
54
54
|
|
55
|
+
var resolveFunc = function(){};
|
56
|
+
var rejectFunc = function(){};
|
57
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
58
|
+
resolveFunc = resolve;
|
59
|
+
rejectFunc = reject;
|
60
|
+
});
|
61
|
+
|
55
62
|
if (!callback) {
|
56
|
-
callback = function() {
|
63
|
+
callback = function(err) {
|
64
|
+
if (err) {
|
65
|
+
return rejectFunc(err);
|
66
|
+
}
|
67
|
+
resolveFunc();
|
68
|
+
};
|
57
69
|
}
|
58
70
|
|
59
71
|
var messageAndOTID = utils.generateOfflineThreadingID();
|
@@ -111,5 +123,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
111
123
|
return callback(err);
|
112
124
|
});
|
113
125
|
});
|
126
|
+
|
127
|
+
return returnPromise;
|
114
128
|
};
|
115
129
|
};
|
@@ -3,9 +3,22 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function changeNickname(nickname, threadID, participantID, callback) {
|
8
|
-
|
8
|
+
var resolveFunc = function(){};
|
9
|
+
var rejectFunc = function(){};
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
|
+
resolveFunc = resolve;
|
12
|
+
rejectFunc = reject;
|
13
|
+
});
|
14
|
+
if (!callback) {
|
15
|
+
callback = function (err) {
|
16
|
+
if (err) {
|
17
|
+
return rejectFunc(err);
|
18
|
+
}
|
19
|
+
resolveFunc();
|
20
|
+
};
|
21
|
+
}
|
9
22
|
|
10
23
|
var form = {
|
11
24
|
nickname: nickname,
|
@@ -40,5 +53,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
40
53
|
log.error("changeNickname", err);
|
41
54
|
return callback(err);
|
42
55
|
});
|
56
|
+
|
57
|
+
return returnPromise;
|
43
58
|
};
|
44
59
|
};
|
@@ -0,0 +1,71 @@
|
|
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 changeThreadColor(color, 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 (!callback) {
|
16
|
+
callback = function(err) {
|
17
|
+
if (err) {
|
18
|
+
return rejectFunc(err);
|
19
|
+
}
|
20
|
+
resolveFunc(err);
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
var validatedColor = color !== null ? color.toLowerCase() : color; // API only accepts lowercase letters in hex string
|
25
|
+
var colorList = Object.keys(api.threadColors).map(function(name) {
|
26
|
+
return api.threadColors[name];
|
27
|
+
});
|
28
|
+
if (!colorList.includes(validatedColor)) {
|
29
|
+
throw {
|
30
|
+
error:
|
31
|
+
"The color you are trying to use is not a valid thread color. Use api.threadColors to find acceptable values."
|
32
|
+
};
|
33
|
+
}
|
34
|
+
|
35
|
+
var form = {
|
36
|
+
dpr: 1,
|
37
|
+
queries: JSON.stringify({
|
38
|
+
o0: {
|
39
|
+
//This doc_id is valid as of January 31, 2020
|
40
|
+
doc_id: "1727493033983591",
|
41
|
+
query_params: {
|
42
|
+
data: {
|
43
|
+
actor_id: ctx.userID,
|
44
|
+
client_mutation_id: "0",
|
45
|
+
source: "SETTINGS",
|
46
|
+
theme_id: validatedColor,
|
47
|
+
thread_id: threadID
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
})
|
52
|
+
};
|
53
|
+
|
54
|
+
defaultFuncs
|
55
|
+
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
56
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
57
|
+
.then(function(resData) {
|
58
|
+
if (resData[resData.length - 1].error_results > 0) {
|
59
|
+
throw resData[0].o0.errors;
|
60
|
+
}
|
61
|
+
|
62
|
+
return callback();
|
63
|
+
})
|
64
|
+
.catch(function(err) {
|
65
|
+
log.error("changeThreadColor", err);
|
66
|
+
return callback(err);
|
67
|
+
});
|
68
|
+
|
69
|
+
return returnPromise;
|
70
|
+
};
|
71
|
+
};
|
@@ -3,10 +3,22 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function changeThreadEmoji(emoji, 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
|
+
|
8
15
|
if (!callback) {
|
9
|
-
callback = function() {
|
16
|
+
callback = function(err) {
|
17
|
+
if (err) {
|
18
|
+
return rejectFunc(err);
|
19
|
+
}
|
20
|
+
resolveFunc();
|
21
|
+
};
|
10
22
|
}
|
11
23
|
var form = {
|
12
24
|
emoji_choice: emoji,
|
@@ -37,5 +49,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
37
49
|
log.error("changeThreadEmoji", err);
|
38
50
|
return callback(err);
|
39
51
|
});
|
52
|
+
|
53
|
+
return returnPromise;
|
40
54
|
};
|
41
55
|
};
|
@@ -0,0 +1,86 @@
|
|
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 createNewGroup(participantIDs, groupTitle, callback) {
|
8
|
+
if (utils.getType(groupTitle) == "Function") {
|
9
|
+
callback = groupTitle;
|
10
|
+
groupTitle = null;
|
11
|
+
}
|
12
|
+
|
13
|
+
if (utils.getType(participantIDs) !== "Array") {
|
14
|
+
throw { error: "createNewGroup: participantIDs should be an array." };
|
15
|
+
}
|
16
|
+
|
17
|
+
if (participantIDs.length < 2) {
|
18
|
+
throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
|
19
|
+
}
|
20
|
+
|
21
|
+
var resolveFunc = function(){};
|
22
|
+
var rejectFunc = function(){};
|
23
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
24
|
+
resolveFunc = resolve;
|
25
|
+
rejectFunc = reject;
|
26
|
+
});
|
27
|
+
|
28
|
+
if (!callback) {
|
29
|
+
callback = function (err, threadID) {
|
30
|
+
if (err) {
|
31
|
+
return rejectFunc(err);
|
32
|
+
}
|
33
|
+
resolveFunc(threadID);
|
34
|
+
};
|
35
|
+
}
|
36
|
+
|
37
|
+
var pids = [];
|
38
|
+
for (var n in participantIDs) {
|
39
|
+
pids.push({
|
40
|
+
fbid: participantIDs[n]
|
41
|
+
});
|
42
|
+
}
|
43
|
+
pids.push({fbid: ctx.userID});
|
44
|
+
|
45
|
+
var form = {
|
46
|
+
fb_api_caller_class: "RelayModern",
|
47
|
+
fb_api_req_friendly_name: "MessengerGroupCreateMutation",
|
48
|
+
av: ctx.userID,
|
49
|
+
//This doc_id is valid as of January 11th, 2020
|
50
|
+
doc_id: "577041672419534",
|
51
|
+
variables: JSON.stringify({
|
52
|
+
input: {
|
53
|
+
entry_point: "jewel_new_group",
|
54
|
+
actor_id: ctx.userID,
|
55
|
+
participants: pids,
|
56
|
+
client_mutation_id: Math.round(Math.random() * 1024).toString(),
|
57
|
+
thread_settings: {
|
58
|
+
name: groupTitle,
|
59
|
+
joinable_mode: "PRIVATE",
|
60
|
+
thread_image_fbid: null
|
61
|
+
}
|
62
|
+
}
|
63
|
+
})
|
64
|
+
};
|
65
|
+
|
66
|
+
defaultFuncs
|
67
|
+
.post(
|
68
|
+
"https://www.facebook.com/api/graphql/",
|
69
|
+
ctx.jar,
|
70
|
+
form
|
71
|
+
)
|
72
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
73
|
+
.then(function(resData) {
|
74
|
+
if (resData.errors) {
|
75
|
+
throw resData;
|
76
|
+
}
|
77
|
+
return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
|
78
|
+
})
|
79
|
+
.catch(function(err) {
|
80
|
+
log.error("createNewGroup", err);
|
81
|
+
return callback(err);
|
82
|
+
});
|
83
|
+
|
84
|
+
return returnPromise;
|
85
|
+
};
|
86
|
+
};
|
@@ -3,13 +3,26 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function createPoll(title, threadID, options, 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
|
+
|
8
15
|
if (!callback) {
|
9
16
|
if (utils.getType(options) == "Function") {
|
10
17
|
callback = options;
|
18
|
+
options = null;
|
11
19
|
} else {
|
12
|
-
callback = function() {
|
20
|
+
callback = function(err) {
|
21
|
+
if (err) {
|
22
|
+
return rejectFunc(err);
|
23
|
+
}
|
24
|
+
resolveFunc();
|
25
|
+
};
|
13
26
|
}
|
14
27
|
}
|
15
28
|
if (!options) {
|
@@ -24,6 +37,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
24
37
|
// Set fields for options (and whether they are selected initially by the posting user)
|
25
38
|
var ind = 0;
|
26
39
|
for (var opt in options) {
|
40
|
+
// eslint-disable-next-line no-prototype-builtins
|
27
41
|
if (options.hasOwnProperty(opt)) {
|
28
42
|
form["option_text_array[" + ind + "]"] = opt;
|
29
43
|
form["option_is_selected_array[" + ind + "]"] = options[opt]
|
@@ -51,5 +65,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
51
65
|
log.error("createPoll", err);
|
52
66
|
return callback(err);
|
53
67
|
});
|
68
|
+
|
69
|
+
return returnPromise;
|
54
70
|
};
|
55
71
|
};
|
@@ -3,10 +3,21 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function deleteMessage(messageOrMessages, callback) {
|
8
|
+
var resolveFunc = function(){};
|
9
|
+
var rejectFunc = function(){};
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
|
+
resolveFunc = resolve;
|
12
|
+
rejectFunc = reject;
|
13
|
+
});
|
8
14
|
if (!callback) {
|
9
|
-
callback = function() {
|
15
|
+
callback = function(err) {
|
16
|
+
if (err) {
|
17
|
+
return rejectFunc(err);
|
18
|
+
}
|
19
|
+
resolveFunc();
|
20
|
+
};
|
10
21
|
}
|
11
22
|
|
12
23
|
var form = {
|
@@ -39,5 +50,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
39
50
|
log.error("deleteMessage", err);
|
40
51
|
return callback(err);
|
41
52
|
});
|
53
|
+
|
54
|
+
return returnPromise;
|
42
55
|
};
|
43
56
|
};
|
@@ -3,10 +3,21 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function deleteThread(threadOrThreads, callback) {
|
8
|
+
var resolveFunc = function(){};
|
9
|
+
var rejectFunc = function(){};
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
|
+
resolveFunc = resolve;
|
12
|
+
rejectFunc = reject;
|
13
|
+
});
|
8
14
|
if (!callback) {
|
9
|
-
callback = function() {
|
15
|
+
callback = function(err) {
|
16
|
+
if (err) {
|
17
|
+
return rejectFunc(err);
|
18
|
+
}
|
19
|
+
resolveFunc();
|
20
|
+
};
|
10
21
|
}
|
11
22
|
|
12
23
|
var form = {
|
@@ -39,5 +50,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
39
50
|
log.error("deleteThread", err);
|
40
51
|
return callback(err);
|
41
52
|
});
|
53
|
+
|
54
|
+
return returnPromise;
|
42
55
|
};
|
43
56
|
};
|
@@ -3,10 +3,21 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function forwardAttachment(attachmentID, userOrUsers, callback) {
|
8
|
+
var resolveFunc = function(){};
|
9
|
+
var rejectFunc = function(){};
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
|
+
resolveFunc = resolve;
|
12
|
+
rejectFunc = reject;
|
13
|
+
});
|
8
14
|
if (!callback) {
|
9
|
-
callback = function() {
|
15
|
+
callback = function(err) {
|
16
|
+
if (err) {
|
17
|
+
return rejectFunc(err);
|
18
|
+
}
|
19
|
+
resolveFunc();
|
20
|
+
};
|
10
21
|
}
|
11
22
|
|
12
23
|
var form = {
|
@@ -37,11 +48,13 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
37
48
|
throw resData;
|
38
49
|
}
|
39
50
|
|
40
|
-
return callback(
|
51
|
+
return callback();
|
41
52
|
})
|
42
53
|
.catch(function(err) {
|
43
54
|
log.error("forwardAttachment", err);
|
44
55
|
return callback(err);
|
45
56
|
});
|
57
|
+
|
58
|
+
return returnPromise;
|
46
59
|
};
|
47
60
|
};
|