alicezetion 1.7.0 → 1.7.2
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/Extra/Database/index.js +399 -0
- package/Extra/Database/methods.js +286 -0
- package/Extra/ExtraAddons.js +213 -0
- package/Extra/ExtraGetThread.js +1 -0
- package/Extra/ExtraUptimeRobot.js +59 -0
- package/Extra/PM2/ecosystem.config.js +23 -0
- package/Extra/Src/Last-Run.js +48 -0
- package/Language/index.json +151 -0
- package/StateCrypt.js +22 -0
- package/broadcast.js +42 -0
- package/index.js +755 -533
- package/logger.js +21 -0
- package/package.json +35 -21
- package/replit.nix +0 -3
- package/src/addExternalModule.js +23 -0
- package/{leiamnash → src}/addUserToGroup.js +11 -23
- package/{leiamnash → src}/changeAdminStatus.js +32 -16
- package/{leiamnash → src}/changeArchivedStatus.js +9 -17
- package/src/changeAvt.js +91 -0
- package/{leiamnash → src}/changeBio.js +16 -24
- package/{leiamnash → src}/changeBlockedStatus.js +13 -18
- package/{leiamnash → src}/changeGroupImage.js +14 -23
- package/{leiamnash → src}/changeNickname.js +9 -14
- package/{leiamnash → src}/changeThreadColor.js +6 -10
- package/{leiamnash → src}/changeThreadEmoji.js +6 -11
- package/{leiamnash → src}/chat.js +116 -127
- package/{leiamnash → src}/createNewGroup.js +19 -27
- package/{leiamnash → src}/createPoll.js +6 -12
- package/{leiamnash → src}/deleteMessage.js +8 -13
- package/{leiamnash → src}/deleteThread.js +7 -14
- package/{leiamnash → src}/forwardAttachment.js +9 -16
- package/src/getAccessToken.js +32 -0
- package/{leiamnash → src}/getCurrentUserID.js +0 -0
- package/{leiamnash → src}/getEmojiUrl.js +1 -2
- package/{leiamnash → src}/getFriendsList.js +11 -14
- package/src/getMessage.js +84 -0
- package/{leiamnash → src}/getThreadHistory.js +27 -38
- package/{leiamnash → src}/getThreadHistoryDeprecated.js +14 -25
- package/src/getThreadInfo.js +197 -0
- package/{leiamnash → src}/getThreadInfoDeprecated.js +12 -24
- package/{leiamnash → src}/getThreadList.js +122 -88
- package/{leiamnash → src}/getThreadListDeprecated.js +9 -20
- package/{leiamnash → src}/getThreadPictures.js +9 -17
- package/{leiamnash → src}/getUserID.js +8 -11
- package/{leiamnash → src}/getUserInfo.js +12 -16
- package/src/getUserInfoV2.js +35 -0
- package/src/handleFriendRequest.js +47 -0
- package/{leiamnash → src}/handleMessageRequest.js +12 -22
- package/{leiamnash → src}/httpGet.js +15 -13
- package/{leiamnash → src}/httpPost.js +14 -13
- package/src/httpPostFormData.js +46 -0
- package/src/listenMqtt.js +1280 -0
- package/{leiamnash → src}/logout.js +7 -9
- package/{leiamnash → src}/markAsDelivered.js +14 -18
- package/{leiamnash → src}/markAsRead.js +30 -28
- package/{leiamnash → src}/markAsSeen.js +18 -19
- package/{leiamnash → src}/muteThread.js +7 -8
- package/{leiamnash/setMessageReaction.js → src/react.js} +15 -18
- package/{leiamnash → src}/removeUserFromGroup.js +13 -20
- package/{leiamnash → src}/resolvePhotoUrl.js +7 -13
- package/{leiamnash → src}/searchForThread.js +8 -13
- package/{leiamnash/markAsReadAll.js → src/seen.js} +10 -13
- package/{leiamnash → src}/sendTypingIndicator.js +23 -31
- package/src/setPostReaction.js +104 -0
- package/{leiamnash → src}/setTitle.js +15 -21
- package/src/threadColors.js +39 -0
- package/{leiamnash → src}/unfriend.js +9 -13
- package/{leiamnash/unsendMessage.js → src/unsend.js} +7 -16
- package/utils.js +1112 -1236
- package/leiamnash/addExternalModule.js +0 -19
- package/leiamnash/changeApprovalMode.js +0 -80
- package/leiamnash/getThreadInfo.js +0 -212
- package/leiamnash/handleFriendRequest.js +0 -61
- package/leiamnash/listenMqtt.js +0 -1129
- package/leiamnash/setPostReaction.js +0 -76
- package/leiamnash/threadColors.js +0 -57
@@ -10,37 +10,31 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
10
10
|
groupTitle = null;
|
11
11
|
}
|
12
12
|
|
13
|
-
if (utils.getType(participantIDs) !== "Array")
|
13
|
+
if (utils.getType(participantIDs) !== "Array")
|
14
14
|
throw { error: "createNewGroup: participantIDs should be an array." };
|
15
|
-
}
|
16
15
|
|
17
|
-
if (participantIDs.length < 2)
|
18
|
-
throw {
|
19
|
-
|
16
|
+
if (participantIDs.length < 2)
|
17
|
+
throw {
|
18
|
+
error: "createNewGroup: participantIDs should have at least 2 IDs."
|
19
|
+
};
|
20
20
|
|
21
|
-
var resolveFunc = function(){};
|
22
|
-
var rejectFunc = function(){};
|
23
|
-
var returnPromise = new Promise(function
|
21
|
+
var resolveFunc = function() {};
|
22
|
+
var rejectFunc = function() {};
|
23
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
24
24
|
resolveFunc = resolve;
|
25
25
|
rejectFunc = reject;
|
26
26
|
});
|
27
27
|
|
28
28
|
if (!callback) {
|
29
|
-
callback = function
|
30
|
-
if (err)
|
31
|
-
return rejectFunc(err);
|
32
|
-
}
|
29
|
+
callback = function(err, threadID) {
|
30
|
+
if (err) return rejectFunc(err);
|
33
31
|
resolveFunc(threadID);
|
34
32
|
};
|
35
33
|
}
|
36
34
|
|
37
35
|
var pids = [];
|
38
|
-
for (var n in participantIDs) {
|
39
|
-
|
40
|
-
fbid: participantIDs[n]
|
41
|
-
});
|
42
|
-
}
|
43
|
-
pids.push({fbid: ctx.userID});
|
36
|
+
for (var n in participantIDs) pids.push({ fbid: participantIDs[n] });
|
37
|
+
pids.push({ fbid: ctx.userID });
|
44
38
|
|
45
39
|
var form = {
|
46
40
|
fb_api_caller_class: "RelayModern",
|
@@ -64,17 +58,15 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
64
58
|
};
|
65
59
|
|
66
60
|
defaultFuncs
|
67
|
-
.post(
|
68
|
-
"https://www.facebook.com/api/graphql/",
|
69
|
-
ctx.jar,
|
70
|
-
form
|
71
|
-
)
|
61
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
72
62
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
73
63
|
.then(function(resData) {
|
74
|
-
if (resData.errors)
|
75
|
-
|
76
|
-
|
77
|
-
|
64
|
+
if (resData.errors) throw resData;
|
65
|
+
return callback(
|
66
|
+
null,
|
67
|
+
resData.data.messenger_group_thread_create.thread.thread_key
|
68
|
+
.thread_fbid
|
69
|
+
);
|
78
70
|
})
|
79
71
|
.catch(function(err) {
|
80
72
|
log.error("createNewGroup", err);
|
@@ -5,9 +5,9 @@ var log = require("npmlog");
|
|
5
5
|
|
6
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
|
8
|
+
var resolveFunc = function() {};
|
9
|
+
var rejectFunc = function() {};
|
10
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
@@ -18,16 +18,12 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
18
18
|
options = null;
|
19
19
|
} else {
|
20
20
|
callback = function(err) {
|
21
|
-
if (err)
|
22
|
-
return rejectFunc(err);
|
23
|
-
}
|
21
|
+
if (err) return rejectFunc(err);
|
24
22
|
resolveFunc();
|
25
23
|
};
|
26
24
|
}
|
27
25
|
}
|
28
|
-
if (!options) {
|
29
|
-
options = {}; // Initial poll options are optional
|
30
|
-
}
|
26
|
+
if (!options) options = {}; // Initial poll options are optional
|
31
27
|
|
32
28
|
var form = {
|
33
29
|
target_id: threadID,
|
@@ -55,9 +51,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
55
51
|
)
|
56
52
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
57
53
|
.then(function(resData) {
|
58
|
-
if (resData.payload.status != "success")
|
59
|
-
throw resData;
|
60
|
-
}
|
54
|
+
if (resData.payload.status != "success") throw resData;
|
61
55
|
|
62
56
|
return callback();
|
63
57
|
})
|
@@ -5,17 +5,16 @@ var log = require("npmlog");
|
|
5
5
|
|
6
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
|
8
|
+
var resolveFunc = function() {};
|
9
|
+
var rejectFunc = function() {};
|
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
|
-
|
18
|
-
}
|
16
|
+
if (err) return rejectFunc(err);
|
17
|
+
|
19
18
|
resolveFunc();
|
20
19
|
};
|
21
20
|
}
|
@@ -24,13 +23,11 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
24
23
|
client: "mercury"
|
25
24
|
};
|
26
25
|
|
27
|
-
if (utils.getType(messageOrMessages) !== "Array")
|
26
|
+
if (utils.getType(messageOrMessages) !== "Array")
|
28
27
|
messageOrMessages = [messageOrMessages];
|
29
|
-
}
|
30
28
|
|
31
|
-
for (var i = 0; i < messageOrMessages.length; i++)
|
29
|
+
for (var i = 0; i < messageOrMessages.length; i++)
|
32
30
|
form["message_ids[" + i + "]"] = messageOrMessages[i];
|
33
|
-
}
|
34
31
|
|
35
32
|
defaultFuncs
|
36
33
|
.post(
|
@@ -40,9 +37,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
40
37
|
)
|
41
38
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
42
39
|
.then(function(resData) {
|
43
|
-
if (resData.error)
|
44
|
-
throw resData;
|
45
|
-
}
|
40
|
+
if (resData.error) throw resData;
|
46
41
|
|
47
42
|
return callback();
|
48
43
|
})
|
@@ -5,17 +5,15 @@ var log = require("npmlog");
|
|
5
5
|
|
6
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
|
8
|
+
var resolveFunc = function() {};
|
9
|
+
var rejectFunc = function() {};
|
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
|
}
|
@@ -24,13 +22,10 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
24
22
|
client: "mercury"
|
25
23
|
};
|
26
24
|
|
27
|
-
if (utils.getType(threadOrThreads) !== "Array")
|
25
|
+
if (utils.getType(threadOrThreads) !== "Array")
|
28
26
|
threadOrThreads = [threadOrThreads];
|
29
|
-
|
30
|
-
|
31
|
-
for (var i = 0; i < threadOrThreads.length; i++) {
|
27
|
+
for (var i = 0; i < threadOrThreads.length; i++)
|
32
28
|
form["ids[" + i + "]"] = threadOrThreads[i];
|
33
|
-
}
|
34
29
|
|
35
30
|
defaultFuncs
|
36
31
|
.post(
|
@@ -40,9 +35,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
40
35
|
)
|
41
36
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
42
37
|
.then(function(resData) {
|
43
|
-
if (resData.error)
|
44
|
-
throw resData;
|
45
|
-
}
|
38
|
+
if (resData.error) throw resData;
|
46
39
|
|
47
40
|
return callback();
|
48
41
|
})
|
@@ -5,17 +5,15 @@ var log = require("npmlog");
|
|
5
5
|
|
6
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
|
8
|
+
var resolveFunc = function() {};
|
9
|
+
var rejectFunc = function() {};
|
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
|
}
|
@@ -24,17 +22,14 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
24
22
|
attachment_id: attachmentID
|
25
23
|
};
|
26
24
|
|
27
|
-
if (utils.getType(userOrUsers) !== "Array")
|
28
|
-
userOrUsers = [userOrUsers];
|
29
|
-
}
|
25
|
+
if (utils.getType(userOrUsers) !== "Array") userOrUsers = [userOrUsers];
|
30
26
|
|
31
27
|
var timestamp = Math.floor(Date.now() / 1000);
|
32
28
|
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
//That's good, the key of the array is really timestmap in seconds + index
|
30
|
+
//Probably time when the attachment will be sent?
|
31
|
+
for (var i = 0; i < userOrUsers.length; i++)
|
36
32
|
form["recipient_map[" + (timestamp + i) + "]"] = userOrUsers[i];
|
37
|
-
}
|
38
33
|
|
39
34
|
defaultFuncs
|
40
35
|
.post(
|
@@ -44,9 +39,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
44
39
|
)
|
45
40
|
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
|
46
41
|
.then(function(resData) {
|
47
|
-
if (resData.error)
|
48
|
-
throw resData;
|
49
|
-
}
|
42
|
+
if (resData.error) throw resData;
|
50
43
|
|
51
44
|
return callback();
|
52
45
|
})
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/* eslint-disable linebreak-style */
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var utils = require("../utils");
|
5
|
+
var log = require("npmlog");
|
6
|
+
|
7
|
+
|
8
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
9
|
+
return function getAccessToken(callback) {
|
10
|
+
var resolveFunc = function () { };
|
11
|
+
var rejectFunc = function () { };
|
12
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
13
|
+
resolveFunc = resolve;
|
14
|
+
rejectFunc = reject;
|
15
|
+
});
|
16
|
+
|
17
|
+
if (!callback) {
|
18
|
+
callback = function (err, userInfo) {
|
19
|
+
if (err) return rejectFunc(err);
|
20
|
+
resolveFunc(userInfo);
|
21
|
+
};
|
22
|
+
}
|
23
|
+
try {
|
24
|
+
var { getAccessToken } = require('../Extra/ExtraAddons');
|
25
|
+
getAccessToken(ctx.jar,ctx,defaultFuncs).then(data => callback(null,data));
|
26
|
+
}
|
27
|
+
catch (e) {
|
28
|
+
callback(null, e);
|
29
|
+
}
|
30
|
+
return returnPromise;
|
31
|
+
};
|
32
|
+
};
|
File without changes
|
@@ -19,9 +19,8 @@ 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
23
|
base = (base << 5) - base + ending.charCodeAt(i);
|
24
|
-
}
|
25
24
|
|
26
25
|
let hashed = (base & 255).toString(16);
|
27
26
|
return util.format(baseUrl, hashed, ending);
|
@@ -41,18 +41,16 @@ function formatData(obj) {
|
|
41
41
|
|
42
42
|
module.exports = function(defaultFuncs, api, ctx) {
|
43
43
|
return function getFriendsList(callback) {
|
44
|
-
var resolveFunc = function(){};
|
45
|
-
var rejectFunc = function(){};
|
46
|
-
var returnPromise = new Promise(function
|
44
|
+
var resolveFunc = function() {};
|
45
|
+
var rejectFunc = function() {};
|
46
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
47
47
|
resolveFunc = resolve;
|
48
48
|
rejectFunc = reject;
|
49
49
|
});
|
50
50
|
|
51
51
|
if (!callback) {
|
52
|
-
callback = function
|
53
|
-
if (err)
|
54
|
-
return rejectFunc(err);
|
55
|
-
}
|
52
|
+
callback = function(err, friendList) {
|
53
|
+
if (err) return rejectFunc(err);
|
56
54
|
resolveFunc(friendList);
|
57
55
|
};
|
58
56
|
}
|
@@ -66,16 +64,15 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
66
64
|
)
|
67
65
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
68
66
|
.then(function(resData) {
|
69
|
-
if (!resData) {
|
70
|
-
|
71
|
-
}
|
72
|
-
if (resData.error) {
|
73
|
-
throw resData;
|
74
|
-
}
|
67
|
+
if (!resData) throw { error: "getFriendsList returned empty object." };
|
68
|
+
if (resData.error) throw resData;
|
75
69
|
callback(null, formatData(resData.payload));
|
76
70
|
})
|
77
71
|
.catch(function(err) {
|
78
|
-
log.error(
|
72
|
+
log.error(
|
73
|
+
"getFriendsList",
|
74
|
+
"Lỗi getFriendsList Có Thể Do Bạn Spam Quá Nhiều ! Hãy Hạn Chế !"
|
75
|
+
);
|
79
76
|
return callback(err);
|
80
77
|
});
|
81
78
|
|
@@ -0,0 +1,84 @@
|
|
1
|
+
/* eslint-disable linebreak-style */
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var utils = require("../utils");
|
5
|
+
var log = require("npmlog");
|
6
|
+
|
7
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
8
|
+
return function getMessage(threadID, messageID, callback) {
|
9
|
+
if (!callback) {
|
10
|
+
return callback({ error: "getMessage: need callback" });
|
11
|
+
}
|
12
|
+
|
13
|
+
if (!threadID || !messageID) {
|
14
|
+
return callback({ error: "getMessage: need threadID and messageID" });
|
15
|
+
}
|
16
|
+
|
17
|
+
const form = {
|
18
|
+
av: ctx.globalOptions.pageID,
|
19
|
+
queries: JSON.stringify({
|
20
|
+
o0: {
|
21
|
+
//This doc_id is valid as of ? (prob January 18, 2020)
|
22
|
+
doc_id: "1768656253222505",
|
23
|
+
query_params: {
|
24
|
+
thread_and_message_id: {
|
25
|
+
thread_id: threadID,
|
26
|
+
message_id: messageID
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
})
|
31
|
+
};
|
32
|
+
|
33
|
+
defaultFuncs
|
34
|
+
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
35
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
36
|
+
.then(resData => {
|
37
|
+
if (resData[resData.length - 1].error_results > 0) {
|
38
|
+
throw resData[0].o0.errors;
|
39
|
+
}
|
40
|
+
|
41
|
+
if (resData[resData.length - 1].successful_results === 0) {
|
42
|
+
throw {
|
43
|
+
error: "getMessage: there was no successful_results",
|
44
|
+
res: resData
|
45
|
+
};
|
46
|
+
}
|
47
|
+
|
48
|
+
var fetchData = resData[0].o0.data.message;
|
49
|
+
if (fetchData) {
|
50
|
+
(!ctx.globalOptions.selfListen &&
|
51
|
+
fetchData.message_sender.id.toString() === ctx.userID) ||
|
52
|
+
!ctx.loggedIn
|
53
|
+
? undefined
|
54
|
+
: (function() {
|
55
|
+
callback(null, {
|
56
|
+
threadID: threadID,
|
57
|
+
messageID: fetchData.message_id,
|
58
|
+
senderID: fetchData.message_sender.id,
|
59
|
+
attachments: fetchData.blob_attachments.map(att => {
|
60
|
+
var x;
|
61
|
+
try {
|
62
|
+
x = utils._formatAttachment(att);
|
63
|
+
} catch (ex) {
|
64
|
+
x = att;
|
65
|
+
x.error = ex;
|
66
|
+
x.type = "unknown";
|
67
|
+
}
|
68
|
+
return x;
|
69
|
+
}),
|
70
|
+
body: fetchData.message.text,
|
71
|
+
mentions: fetchData.message.ranges,
|
72
|
+
timestamp: fetchData.timestamp_precise,
|
73
|
+
messageReply: fetchData.replied_to_message,
|
74
|
+
raw: fetchData
|
75
|
+
});
|
76
|
+
})();
|
77
|
+
}
|
78
|
+
})
|
79
|
+
.catch(err => {
|
80
|
+
log.error("getMessage", err);
|
81
|
+
callback(err);
|
82
|
+
});
|
83
|
+
};
|
84
|
+
};
|
@@ -255,9 +255,7 @@ function formatExtensibleAttachment(attachment) {
|
|
255
255
|
attachment.story_attachment.media.image
|
256
256
|
).height // @Legacy
|
257
257
|
};
|
258
|
-
} else {
|
259
|
-
return { error: "Don't know what to do with extensible_attachment." };
|
260
|
-
}
|
258
|
+
} else return { error: "Don't know what to do with extensible_attachment." };
|
261
259
|
}
|
262
260
|
|
263
261
|
function formatReactionsGraphQL(reaction) {
|
@@ -268,36 +266,28 @@ function formatReactionsGraphQL(reaction) {
|
|
268
266
|
}
|
269
267
|
|
270
268
|
function formatEventData(event) {
|
271
|
-
if (event == null) {
|
272
|
-
return {};
|
273
|
-
}
|
269
|
+
if (event == null) return {};
|
274
270
|
|
275
271
|
switch (event.__typename) {
|
276
272
|
case "ThemeColorExtensibleMessageAdminText":
|
277
|
-
return {
|
278
|
-
color: event.theme_color
|
279
|
-
};
|
273
|
+
return { color: event.theme_color };
|
280
274
|
case "ThreadNicknameExtensibleMessageAdminText":
|
281
275
|
return {
|
282
276
|
nickname: event.nickname,
|
283
277
|
participantID: event.participant_id
|
284
278
|
};
|
285
279
|
case "ThreadIconExtensibleMessageAdminText":
|
286
|
-
return {
|
287
|
-
threadIcon: event.thread_icon
|
288
|
-
};
|
280
|
+
return { threadIcon: event.thread_icon };
|
289
281
|
case "InstantGameUpdateExtensibleMessageAdminText":
|
290
282
|
return {
|
291
|
-
gameID:
|
283
|
+
gameID: event.game == null ? null : event.game.id,
|
292
284
|
update_type: event.update_type,
|
293
285
|
collapsed_text: event.collapsed_text,
|
294
286
|
expanded_text: event.expanded_text,
|
295
287
|
instant_game_update_data: event.instant_game_update_data
|
296
288
|
};
|
297
289
|
case "GameScoreExtensibleMessageAdminText":
|
298
|
-
return {
|
299
|
-
game_type: event.game_type
|
300
|
-
};
|
290
|
+
return { game_type: event.game_type };
|
301
291
|
case "RtcCallLogExtensibleMessageAdminText":
|
302
292
|
return {
|
303
293
|
event: event.event,
|
@@ -393,9 +383,13 @@ function formatMessagesGraphQLResponse(data) {
|
|
393
383
|
|
394
384
|
var mentionsObj = {};
|
395
385
|
if (d.message !== null) {
|
396
|
-
d.message.ranges.forEach(
|
397
|
-
|
398
|
-
|
386
|
+
d.message.ranges.forEach(
|
387
|
+
e =>
|
388
|
+
(mentionsObj[e.entity.id] = d.message.text.substr(
|
389
|
+
e.offset,
|
390
|
+
e.length
|
391
|
+
))
|
392
|
+
);
|
399
393
|
}
|
400
394
|
|
401
395
|
return {
|
@@ -407,7 +401,7 @@ function formatMessagesGraphQLResponse(data) {
|
|
407
401
|
: d.extensible_attachment
|
408
402
|
? [formatExtensibleAttachment(d.extensible_attachment)]
|
409
403
|
: [],
|
410
|
-
body: d.message !== null ? d.message.text :
|
404
|
+
body: d.message !== null ? d.message.text : "",
|
411
405
|
isGroup: messageThread.thread_type === "GROUP",
|
412
406
|
messageID: d.message_id,
|
413
407
|
senderID: d.message_sender.id,
|
@@ -434,9 +428,7 @@ function formatMessagesGraphQLResponse(data) {
|
|
434
428
|
timestamp: d.timestamp_precise,
|
435
429
|
eventType: "change_thread_name",
|
436
430
|
snippet: d.snippet,
|
437
|
-
eventData: {
|
438
|
-
threadName: d.thread_name
|
439
|
-
},
|
431
|
+
eventData: { threadName: d.thread_name },
|
440
432
|
|
441
433
|
// @Legacy
|
442
434
|
author: d.message_sender.id,
|
@@ -584,18 +576,16 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
584
576
|
timestamp,
|
585
577
|
callback
|
586
578
|
) {
|
587
|
-
var resolveFunc = function(){};
|
588
|
-
var rejectFunc = function(){};
|
589
|
-
var returnPromise = new Promise(function
|
579
|
+
var resolveFunc = function() {};
|
580
|
+
var rejectFunc = function() {};
|
581
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
590
582
|
resolveFunc = resolve;
|
591
583
|
rejectFunc = reject;
|
592
584
|
});
|
593
585
|
|
594
586
|
if (!callback) {
|
595
|
-
callback = function
|
596
|
-
if (err)
|
597
|
-
return rejectFunc(err);
|
598
|
-
}
|
587
|
+
callback = function(err, data) {
|
588
|
+
if (err) return rejectFunc(err);
|
599
589
|
resolveFunc(data);
|
600
590
|
};
|
601
591
|
}
|
@@ -603,7 +593,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
603
593
|
// `queries` has to be a string. I couldn't tell from the dev console. This
|
604
594
|
// took me a really long time to figure out. I deserve a cookie for this.
|
605
595
|
var form = {
|
606
|
-
|
596
|
+
av: ctx.globalOptions.pageID,
|
607
597
|
queries: JSON.stringify({
|
608
598
|
o0: {
|
609
599
|
// This doc_id was valid on February 2nd 2017.
|
@@ -623,20 +613,19 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
623
613
|
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
624
614
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
625
615
|
.then(function(resData) {
|
626
|
-
if (resData.error)
|
627
|
-
throw resData;
|
628
|
-
}
|
616
|
+
if (resData.error) throw resData;
|
629
617
|
// This returns us an array of things. The last one is the success /
|
630
618
|
// failure one.
|
631
619
|
// @TODO What do we do in this case?
|
632
|
-
if (resData[resData.length - 1].error_results !== 0)
|
620
|
+
if (resData[resData.length - 1].error_results !== 0)
|
633
621
|
throw new Error("There was an error_result.");
|
634
|
-
}
|
635
|
-
|
636
622
|
callback(null, formatMessagesGraphQLResponse(resData[0]));
|
637
623
|
})
|
638
624
|
.catch(function(err) {
|
639
|
-
log.error(
|
625
|
+
log.error(
|
626
|
+
"getThreadHistoryGraphQL",
|
627
|
+
"Lỗi getThreadHistoryGraphQL Có Thể Do Bạn Spam Quá Nhiều, Hãy Thử Lại !"
|
628
|
+
);
|
640
629
|
return callback(err);
|
641
630
|
});
|
642
631
|
|
@@ -5,34 +5,27 @@ var log = require("npmlog");
|
|
5
5
|
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function getThreadHistory(threadID, amount, timestamp, callback) {
|
8
|
-
var resolveFunc = function(){};
|
9
|
-
var rejectFunc = function(){};
|
10
|
-
var returnPromise = new Promise(function
|
8
|
+
var resolveFunc = function() {};
|
9
|
+
var rejectFunc = function() {};
|
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
|
17
|
-
if (err)
|
18
|
-
|
19
|
-
}
|
20
|
-
resolveFunc(friendList);
|
16
|
+
callback = function(err, threadInfo) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
resolveFunc(threadInfo);
|
21
19
|
};
|
22
20
|
}
|
23
21
|
|
24
|
-
if (!callback) {
|
25
|
-
throw { error: "getThreadHistory: need callback" };
|
26
|
-
}
|
27
|
-
|
22
|
+
if (!callback) throw { error: "getThreadHistory: need callback" };
|
28
23
|
var form = {
|
29
24
|
client: "mercury"
|
30
25
|
};
|
31
26
|
|
32
27
|
api.getUserInfo(threadID, function(err, res) {
|
33
|
-
if (err)
|
34
|
-
return callback(err);
|
35
|
-
}
|
28
|
+
if (err) return callback(err);
|
36
29
|
var key = Object.keys(res).length > 0 ? "user_ids" : "thread_fbids";
|
37
30
|
form["messages[" + key + "][" + threadID + "][offset]"] = 0;
|
38
31
|
form["messages[" + key + "][" + threadID + "][timestamp]"] = timestamp;
|
@@ -49,22 +42,18 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
49
42
|
)
|
50
43
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
51
44
|
.then(function(resData) {
|
52
|
-
if (resData.error)
|
53
|
-
|
54
|
-
} else if (!resData.payload) {
|
45
|
+
if (resData.error) throw resData;
|
46
|
+
else if (!resData.payload)
|
55
47
|
throw { error: "Could not retrieve thread history." };
|
56
|
-
}
|
57
48
|
|
58
49
|
// Asking for message history from a thread with no message history
|
59
50
|
// will return undefined for actions here
|
60
|
-
if (!resData.payload.actions)
|
61
|
-
resData.payload.actions = [];
|
62
|
-
}
|
51
|
+
if (!resData.payload.actions) resData.payload.actions = [];
|
63
52
|
|
64
53
|
var userIDs = {};
|
65
|
-
resData.payload.actions.forEach(
|
66
|
-
userIDs[v.author.split(":").pop()] = ""
|
67
|
-
|
54
|
+
resData.payload.actions.forEach(
|
55
|
+
v => (userIDs[v.author.split(":").pop()] = "")
|
56
|
+
);
|
68
57
|
|
69
58
|
api.getUserInfo(Object.keys(userIDs), function(err, data) {
|
70
59
|
if (err) return callback(err); //callback({error: "Could not retrieve user information in getThreadHistory."});
|