alicezetion 1.3.0 → 1.3.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/.cache/replit/nix/env.json +1 -1
- package/index.js +1 -8
- package/leiamnash/addExternalModule.js +10 -6
- package/leiamnash/addUserToGroup.js +52 -16
- package/leiamnash/changeAdminStatus.js +69 -37
- package/leiamnash/changeArchivedStatus.js +26 -12
- package/leiamnash/changeBio.js +19 -6
- package/leiamnash/changeBlockedStatus.js +14 -3
- package/leiamnash/changeGroupImage.js +40 -16
- package/leiamnash/changeNickname.js +27 -11
- package/leiamnash/changeThreadColor.js +20 -10
- package/leiamnash/changeThreadEmoji.js +24 -10
- package/leiamnash/chat.js +414 -279
- package/leiamnash/createNewGroup.js +28 -12
- package/leiamnash/createPoll.js +25 -13
- package/leiamnash/deleteMessage.js +24 -12
- package/leiamnash/deleteThread.js +25 -11
- package/leiamnash/forwardAttachment.js +26 -13
- package/leiamnash/getCurrentUserID.js +1 -1
- package/leiamnash/getEmojiUrl.js +4 -2
- package/leiamnash/getFriendsList.js +21 -10
- package/leiamnash/getThreadHistory.js +166 -58
- package/leiamnash/getThreadHistoryDeprecated.js +42 -20
- package/leiamnash/getThreadInfo.js +60 -25
- package/leiamnash/getThreadInfoDeprecated.js +42 -18
- package/leiamnash/getThreadList.js +66 -41
- package/leiamnash/getThreadListDeprecated.js +43 -14
- package/leiamnash/getThreadPictures.js +37 -17
- package/leiamnash/getUserID.js +14 -9
- package/leiamnash/getUserInfo.js +18 -12
- package/leiamnash/handleFriendRequest.js +52 -37
- package/leiamnash/handleMessageRequest.js +32 -14
- package/leiamnash/httpGet.js +17 -12
- package/leiamnash/httpPost.js +17 -12
- package/leiamnash/listenMqtt.js +2 -1
- package/leiamnash/logout.js +20 -13
- package/leiamnash/markAsDelivered.js +22 -11
- package/leiamnash/markAsRead.js +21 -11
- package/leiamnash/markAsReadAll.js +20 -10
- package/leiamnash/markAsSeen.js +18 -7
- package/leiamnash/muteThread.js +18 -11
- package/leiamnash/removeUserFromGroup.js +48 -14
- package/leiamnash/resolvePhotoUrl.js +17 -8
- package/leiamnash/searchForThread.js +21 -10
- package/leiamnash/sendTypingIndicator.js +47 -14
- package/leiamnash/setMessageReaction.js +26 -12
- package/leiamnash/setPostReaction.js +26 -13
- package/leiamnash/setTitle.js +29 -13
- package/leiamnash/threadColors.js +44 -28
- package/leiamnash/unfriend.js +19 -9
- package/leiamnash/unsendMessage.js +19 -9
- package/package.json +1 -1
- package/replit.nix +3 -1
- package/utils.js +0 -0
- package/leiamnash/forwardMessage.js +0 -0
- package/leiamnash/listen.js +0 -553
- package/leiamnash/listenMqtt-Test.js +0 -687
@@ -3,19 +3,23 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function createNewGroup(participantIDs, groupTitle, callback) {
|
8
8
|
if (utils.getType(groupTitle) == "Function") {
|
9
9
|
callback = groupTitle;
|
10
10
|
groupTitle = null;
|
11
11
|
}
|
12
12
|
|
13
|
-
if (utils.getType(participantIDs) !== "Array")
|
13
|
+
if (utils.getType(participantIDs) !== "Array") {
|
14
|
+
throw { error: "createNewGroup: participantIDs should be an array." };
|
15
|
+
}
|
14
16
|
|
15
|
-
if (participantIDs.length < 2)
|
17
|
+
if (participantIDs.length < 2) {
|
18
|
+
throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
|
19
|
+
}
|
16
20
|
|
17
|
-
var resolveFunc = function
|
18
|
-
var rejectFunc = function
|
21
|
+
var resolveFunc = function(){};
|
22
|
+
var rejectFunc = function(){};
|
19
23
|
var returnPromise = new Promise(function (resolve, reject) {
|
20
24
|
resolveFunc = resolve;
|
21
25
|
rejectFunc = reject;
|
@@ -23,14 +27,20 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
23
27
|
|
24
28
|
if (!callback) {
|
25
29
|
callback = function (err, threadID) {
|
26
|
-
if (err)
|
30
|
+
if (err) {
|
31
|
+
return rejectFunc(err);
|
32
|
+
}
|
27
33
|
resolveFunc(threadID);
|
28
34
|
};
|
29
35
|
}
|
30
36
|
|
31
37
|
var pids = [];
|
32
|
-
for (var n in participantIDs)
|
33
|
-
|
38
|
+
for (var n in participantIDs) {
|
39
|
+
pids.push({
|
40
|
+
fbid: participantIDs[n]
|
41
|
+
});
|
42
|
+
}
|
43
|
+
pids.push({fbid: ctx.userID});
|
34
44
|
|
35
45
|
var form = {
|
36
46
|
fb_api_caller_class: "RelayModern",
|
@@ -54,13 +64,19 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
54
64
|
};
|
55
65
|
|
56
66
|
defaultFuncs
|
57
|
-
.post(
|
67
|
+
.post(
|
68
|
+
"https://www.facebook.com/api/graphql/",
|
69
|
+
ctx.jar,
|
70
|
+
form
|
71
|
+
)
|
58
72
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
59
|
-
.then(function
|
60
|
-
if (resData.errors)
|
73
|
+
.then(function(resData) {
|
74
|
+
if (resData.errors) {
|
75
|
+
throw resData;
|
76
|
+
}
|
61
77
|
return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
|
62
78
|
})
|
63
|
-
.catch(function
|
79
|
+
.catch(function(err) {
|
64
80
|
log.error("createNewGroup", err);
|
65
81
|
return callback(err);
|
66
82
|
});
|
package/leiamnash/createPoll.js
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function createPoll(title, threadID, options, 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;
|
@@ -16,15 +16,18 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
16
16
|
if (utils.getType(options) == "Function") {
|
17
17
|
callback = options;
|
18
18
|
options = null;
|
19
|
-
}
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
} else {
|
20
|
+
callback = function(err) {
|
21
|
+
if (err) {
|
22
|
+
return rejectFunc(err);
|
23
|
+
}
|
23
24
|
resolveFunc();
|
24
25
|
};
|
25
26
|
}
|
26
27
|
}
|
27
|
-
if (!options)
|
28
|
+
if (!options) {
|
29
|
+
options = {}; // Initial poll options are optional
|
30
|
+
}
|
28
31
|
|
29
32
|
var form = {
|
30
33
|
target_id: threadID,
|
@@ -37,19 +40,28 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
37
40
|
// eslint-disable-next-line no-prototype-builtins
|
38
41
|
if (options.hasOwnProperty(opt)) {
|
39
42
|
form["option_text_array[" + ind + "]"] = opt;
|
40
|
-
form["option_is_selected_array[" + ind + "]"] = options[opt]
|
43
|
+
form["option_is_selected_array[" + ind + "]"] = options[opt]
|
44
|
+
? "1"
|
45
|
+
: "0";
|
41
46
|
ind++;
|
42
47
|
}
|
43
48
|
}
|
44
49
|
|
45
50
|
defaultFuncs
|
46
|
-
.post(
|
51
|
+
.post(
|
52
|
+
"https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1",
|
53
|
+
ctx.jar,
|
54
|
+
form
|
55
|
+
)
|
47
56
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
48
|
-
.then(function
|
49
|
-
if (resData.payload.status != "success")
|
57
|
+
.then(function(resData) {
|
58
|
+
if (resData.payload.status != "success") {
|
59
|
+
throw resData;
|
60
|
+
}
|
61
|
+
|
50
62
|
return callback();
|
51
63
|
})
|
52
|
-
.catch(function
|
64
|
+
.catch(function(err) {
|
53
65
|
log.error("createPoll", err);
|
54
66
|
return callback(err);
|
55
67
|
});
|
@@ -3,18 +3,19 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function deleteMessage(messageOrMessages, 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
|
-
callback = function
|
16
|
-
if (err)
|
17
|
-
|
15
|
+
callback = function(err) {
|
16
|
+
if (err) {
|
17
|
+
return rejectFunc(err);
|
18
|
+
}
|
18
19
|
resolveFunc();
|
19
20
|
};
|
20
21
|
}
|
@@ -23,18 +24,29 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
23
24
|
client: "mercury"
|
24
25
|
};
|
25
26
|
|
26
|
-
if (utils.getType(messageOrMessages) !== "Array")
|
27
|
+
if (utils.getType(messageOrMessages) !== "Array") {
|
28
|
+
messageOrMessages = [messageOrMessages];
|
29
|
+
}
|
27
30
|
|
28
|
-
for (var i = 0; i < messageOrMessages.length; i++)
|
31
|
+
for (var i = 0; i < messageOrMessages.length; i++) {
|
32
|
+
form["message_ids[" + i + "]"] = messageOrMessages[i];
|
33
|
+
}
|
29
34
|
|
30
35
|
defaultFuncs
|
31
|
-
.post(
|
36
|
+
.post(
|
37
|
+
"https://www.facebook.com/ajax/mercury/delete_messages.php",
|
38
|
+
ctx.jar,
|
39
|
+
form
|
40
|
+
)
|
32
41
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
33
|
-
.then(function
|
34
|
-
if (resData.error)
|
42
|
+
.then(function(resData) {
|
43
|
+
if (resData.error) {
|
44
|
+
throw resData;
|
45
|
+
}
|
46
|
+
|
35
47
|
return callback();
|
36
48
|
})
|
37
|
-
.catch(function
|
49
|
+
.catch(function(err) {
|
38
50
|
log.error("deleteMessage", err);
|
39
51
|
return callback(err);
|
40
52
|
});
|
@@ -3,17 +3,19 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function deleteThread(threadOrThreads, 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
|
-
callback = function
|
16
|
-
if (err)
|
15
|
+
callback = function(err) {
|
16
|
+
if (err) {
|
17
|
+
return rejectFunc(err);
|
18
|
+
}
|
17
19
|
resolveFunc();
|
18
20
|
};
|
19
21
|
}
|
@@ -22,17 +24,29 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
22
24
|
client: "mercury"
|
23
25
|
};
|
24
26
|
|
25
|
-
if (utils.getType(threadOrThreads) !== "Array")
|
26
|
-
|
27
|
+
if (utils.getType(threadOrThreads) !== "Array") {
|
28
|
+
threadOrThreads = [threadOrThreads];
|
29
|
+
}
|
30
|
+
|
31
|
+
for (var i = 0; i < threadOrThreads.length; i++) {
|
32
|
+
form["ids[" + i + "]"] = threadOrThreads[i];
|
33
|
+
}
|
27
34
|
|
28
35
|
defaultFuncs
|
29
|
-
.post(
|
36
|
+
.post(
|
37
|
+
"https://www.facebook.com/ajax/mercury/delete_thread.php",
|
38
|
+
ctx.jar,
|
39
|
+
form
|
40
|
+
)
|
30
41
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
31
|
-
.then(function
|
32
|
-
if (resData.error)
|
42
|
+
.then(function(resData) {
|
43
|
+
if (resData.error) {
|
44
|
+
throw resData;
|
45
|
+
}
|
46
|
+
|
33
47
|
return callback();
|
34
48
|
})
|
35
|
-
.catch(function
|
49
|
+
.catch(function(err) {
|
36
50
|
log.error("deleteThread", err);
|
37
51
|
return callback(err);
|
38
52
|
});
|
@@ -3,17 +3,19 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function forwardAttachment(attachmentID, userOrUsers, 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
|
-
callback = function
|
16
|
-
if (err)
|
15
|
+
callback = function(err) {
|
16
|
+
if (err) {
|
17
|
+
return rejectFunc(err);
|
18
|
+
}
|
17
19
|
resolveFunc();
|
18
20
|
};
|
19
21
|
}
|
@@ -22,22 +24,33 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
22
24
|
attachment_id: attachmentID
|
23
25
|
};
|
24
26
|
|
25
|
-
if (utils.getType(userOrUsers) !== "Array")
|
27
|
+
if (utils.getType(userOrUsers) !== "Array") {
|
28
|
+
userOrUsers = [userOrUsers];
|
29
|
+
}
|
26
30
|
|
27
31
|
var timestamp = Math.floor(Date.now() / 1000);
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
|
33
|
+
for (var i = 0; i < userOrUsers.length; i++) {
|
34
|
+
//That's good, the key of the array is really timestmap in seconds + index
|
35
|
+
//Probably time when the attachment will be sent?
|
36
|
+
form["recipient_map[" + (timestamp + i) + "]"] = userOrUsers[i];
|
37
|
+
}
|
32
38
|
|
33
39
|
defaultFuncs
|
34
|
-
.post(
|
40
|
+
.post(
|
41
|
+
"https://www.facebook.com/mercury/attachments/forward/",
|
42
|
+
ctx.jar,
|
43
|
+
form
|
44
|
+
)
|
35
45
|
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
|
36
|
-
.then(function
|
37
|
-
if (resData.error)
|
46
|
+
.then(function(resData) {
|
47
|
+
if (resData.error) {
|
48
|
+
throw resData;
|
49
|
+
}
|
50
|
+
|
38
51
|
return callback();
|
39
52
|
})
|
40
|
-
.catch(function
|
53
|
+
.catch(function(err) {
|
41
54
|
log.error("forwardAttachment", err);
|
42
55
|
return callback(err);
|
43
56
|
});
|
package/leiamnash/getEmojiUrl.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
const util = require("util");
|
4
4
|
|
5
|
-
module.exports = function
|
5
|
+
module.exports = function() {
|
6
6
|
return function getEmojiUrl(c, size, pixelRatio) {
|
7
7
|
/*
|
8
8
|
Resolves Facebook Messenger emoji image asset URL for an emoji character.
|
@@ -19,7 +19,9 @@ module.exports = function () {
|
|
19
19
|
c.codePointAt(0).toString(16)
|
20
20
|
);
|
21
21
|
let base = 317426846;
|
22
|
-
for (let i = 0; i < ending.length; i++)
|
22
|
+
for (let i = 0; i < ending.length; i++) {
|
23
|
+
base = (base << 5) - base + ending.charCodeAt(i);
|
24
|
+
}
|
23
25
|
|
24
26
|
let hashed = (base & 255).toString(16);
|
25
27
|
return util.format(baseUrl, hashed, ending);
|
@@ -21,7 +21,7 @@ var GENDERS = {
|
|
21
21
|
};
|
22
22
|
|
23
23
|
function formatData(obj) {
|
24
|
-
return Object.keys(obj).map(function
|
24
|
+
return Object.keys(obj).map(function(key) {
|
25
25
|
var user = obj[key];
|
26
26
|
return {
|
27
27
|
alternateName: user.alternateName,
|
@@ -39,10 +39,10 @@ function formatData(obj) {
|
|
39
39
|
});
|
40
40
|
}
|
41
41
|
|
42
|
-
module.exports = function
|
42
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
43
43
|
return function getFriendsList(callback) {
|
44
|
-
var resolveFunc = function
|
45
|
-
var rejectFunc = function
|
44
|
+
var resolveFunc = function(){};
|
45
|
+
var rejectFunc = function(){};
|
46
46
|
var returnPromise = new Promise(function (resolve, reject) {
|
47
47
|
resolveFunc = resolve;
|
48
48
|
rejectFunc = reject;
|
@@ -50,20 +50,31 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
50
50
|
|
51
51
|
if (!callback) {
|
52
52
|
callback = function (err, friendList) {
|
53
|
-
if (err)
|
53
|
+
if (err) {
|
54
|
+
return rejectFunc(err);
|
55
|
+
}
|
54
56
|
resolveFunc(friendList);
|
55
57
|
};
|
56
58
|
}
|
57
59
|
|
58
60
|
defaultFuncs
|
59
|
-
.postFormData(
|
61
|
+
.postFormData(
|
62
|
+
"https://www.facebook.com/chat/user_info_all",
|
63
|
+
ctx.jar,
|
64
|
+
{},
|
65
|
+
{ viewer: ctx.userID }
|
66
|
+
)
|
60
67
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
61
|
-
.then(function
|
62
|
-
if (!resData)
|
63
|
-
|
68
|
+
.then(function(resData) {
|
69
|
+
if (!resData) {
|
70
|
+
throw { error: "getFriendsList returned empty object." };
|
71
|
+
}
|
72
|
+
if (resData.error) {
|
73
|
+
throw resData;
|
74
|
+
}
|
64
75
|
callback(null, formatData(resData.payload));
|
65
76
|
})
|
66
|
-
.catch(function
|
77
|
+
.catch(function(err) {
|
67
78
|
log.error("getFriendsList", err);
|
68
79
|
return callback(err);
|
69
80
|
});
|