alicezetion 1.0.3 → 1.0.5
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/modules.stamp +1 -0
- package/.cache/replit/nix/env.json +1 -1
- package/index.js +536 -604
- package/package.json +78 -75
- package/replit.nix +6 -0
- package/src/addExternalModule.js +15 -0
- package/{alice → src}/addUserToGroup.js +77 -113
- package/src/changeAdminStatus.js +47 -0
- package/src/changeArchivedStatus.js +41 -0
- package/{alice → src}/changeBio.js +64 -77
- package/{alice → src}/changeBlockedStatus.js +36 -47
- package/{alice → src}/changeGroupImage.js +105 -129
- package/src/changeNickname.js +43 -0
- package/{alice → src}/changeThreadColor.js +61 -71
- package/src/changeThreadEmoji.js +41 -0
- package/src/chat.js +315 -0
- package/{alice → src}/createNewGroup.js +70 -86
- package/{alice → src}/createPoll.js +59 -71
- package/src/deleteMessage.js +44 -0
- package/src/deleteThread.js +42 -0
- package/src/forwardAttachment.js +47 -0
- package/src/forwardMessage.js +0 -0
- package/{alice → src}/getCurrentUserID.js +7 -7
- package/{alice → src}/getEmojiUrl.js +27 -29
- package/{alice → src}/getFriendsList.js +73 -84
- package/{alice → src}/getThreadHistory.js +537 -645
- package/src/getThreadHistoryDeprecated.js +71 -0
- package/{alice → src}/getThreadInfo.js +171 -206
- package/src/getThreadInfoDeprecated.js +56 -0
- package/{alice → src}/getThreadList.js +213 -238
- package/src/getThreadListDeprecated.js +46 -0
- package/src/getThreadPictures.js +59 -0
- package/{alice → src}/getUserID.js +61 -66
- package/{alice → src}/getUserInfo.js +66 -72
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +47 -0
- package/{alice → src}/httpGet.js +47 -52
- package/{alice → src}/httpPost.js +47 -52
- package/src/listen.js +553 -0
- package/src/listenMqtt-Test.js +687 -0
- package/src/listenMqtt.js +677 -0
- package/{alice → src}/logout.js +68 -75
- package/{alice → src}/markAsDelivered.js +47 -58
- package/{alice → src}/markAsRead.js +70 -80
- package/{alice/seen.js → src/markAsReadAll.js} +39 -49
- package/{alice → src}/markAsSeen.js +48 -59
- package/{alice → src}/muteThread.js +45 -52
- package/src/removeUserFromGroup.js +45 -0
- package/{alice → src}/resolvePhotoUrl.js +36 -45
- package/src/searchForThread.js +42 -0
- package/{alice → src}/sendTypingIndicator.js +70 -103
- package/{alice/react.js → src/setMessageReaction.js} +103 -117
- package/{alice → src}/setPostReaction.js +63 -76
- package/{alice → src}/setTitle.js +70 -86
- package/src/threadColors.js +41 -0
- package/{alice → src}/unfriend.js +42 -52
- package/{alice → src}/unsendMessage.js +39 -49
- package/utils.js +1193 -1357
- package/alice/addExternalModule.js +0 -19
- package/alice/changeAdminStatus.js +0 -79
- package/alice/changeArchivedStatus.js +0 -55
- package/alice/changeNickname.js +0 -59
- package/alice/changeThreadEmoji.js +0 -55
- package/alice/chat.js +0 -459
- package/alice/deleteMessage.js +0 -56
- package/alice/deleteThread.js +0 -56
- package/alice/forwardAttachment.js +0 -60
- package/alice/getThreadHistoryDeprecated.js +0 -93
- package/alice/getThreadInfoDeprecated.js +0 -80
- package/alice/getThreadListDeprecated.js +0 -75
- package/alice/getThreadPictures.js +0 -79
- package/alice/handleFriendRequest.js +0 -61
- package/alice/handleMessageRequest.js +0 -65
- package/alice/listenMqtt.js +0 -789
- package/alice/removeUserFromGroup.js +0 -79
- package/alice/searchForThread.js +0 -53
- package/alice/threadColors.js +0 -57
- package/test/data/shareAttach.js +0 -146
- package/test/data/something.mov +0 -0
- package/test/data/test.png +0 -0
- package/test/data/test.txt +0 -7
- package/test/example-config.json +0 -18
- package/test/test-page.js +0 -140
- package/test/test.js +0 -385
@@ -1,93 +0,0 @@
|
|
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 getThreadHistory(threadID, amount, timestamp, 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, friendList) {
|
17
|
-
if (err) {
|
18
|
-
return rejectFunc(err);
|
19
|
-
}
|
20
|
-
resolveFunc(friendList);
|
21
|
-
};
|
22
|
-
}
|
23
|
-
|
24
|
-
if (!callback) {
|
25
|
-
throw { error: "getThreadHistory: need callback" };
|
26
|
-
}
|
27
|
-
|
28
|
-
var form = {
|
29
|
-
client: "mercury"
|
30
|
-
};
|
31
|
-
|
32
|
-
api.getUserInfo(threadID, function(err, res) {
|
33
|
-
if (err) {
|
34
|
-
return callback(err);
|
35
|
-
}
|
36
|
-
var key = Object.keys(res).length > 0 ? "user_ids" : "thread_fbids";
|
37
|
-
form["messages[" + key + "][" + threadID + "][offset]"] = 0;
|
38
|
-
form["messages[" + key + "][" + threadID + "][timestamp]"] = timestamp;
|
39
|
-
form["messages[" + key + "][" + threadID + "][limit]"] = amount;
|
40
|
-
|
41
|
-
if (ctx.globalOptions.pageID)
|
42
|
-
form.request_user_id = ctx.globalOptions.pageID;
|
43
|
-
|
44
|
-
defaultFuncs
|
45
|
-
.post(
|
46
|
-
"https://www.facebook.com/ajax/mercury/thread_info.php",
|
47
|
-
ctx.jar,
|
48
|
-
form
|
49
|
-
)
|
50
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
51
|
-
.then(function(resData) {
|
52
|
-
if (resData.error) {
|
53
|
-
throw resData;
|
54
|
-
} else if (!resData.payload) {
|
55
|
-
throw { error: "Could not retrieve thread history." };
|
56
|
-
}
|
57
|
-
|
58
|
-
// Asking for message history from a thread with no message history
|
59
|
-
// will return undefined for actions here
|
60
|
-
if (!resData.payload.actions) {
|
61
|
-
resData.payload.actions = [];
|
62
|
-
}
|
63
|
-
|
64
|
-
var userIDs = {};
|
65
|
-
resData.payload.actions.forEach(function(v) {
|
66
|
-
userIDs[v.author.split(":").pop()] = "";
|
67
|
-
});
|
68
|
-
|
69
|
-
api.getUserInfo(Object.keys(userIDs), function(err, data) {
|
70
|
-
if (err) return callback(err); //callback({error: "Could not retrieve user information in getThreadHistory."});
|
71
|
-
|
72
|
-
resData.payload.actions.forEach(function(v) {
|
73
|
-
var sender = data[v.author.split(":").pop()];
|
74
|
-
if (sender) v.sender_name = sender.name;
|
75
|
-
else v.sender_name = "Facebook User";
|
76
|
-
v.sender_fbid = v.author;
|
77
|
-
delete v.author;
|
78
|
-
});
|
79
|
-
|
80
|
-
callback(
|
81
|
-
null,
|
82
|
-
resData.payload.actions.map(utils.formatHistoryMessage)
|
83
|
-
);
|
84
|
-
});
|
85
|
-
})
|
86
|
-
.catch(function(err) {
|
87
|
-
log.error("getThreadHistory", err);
|
88
|
-
return callback(err);
|
89
|
-
});
|
90
|
-
});
|
91
|
-
return returnPromise;
|
92
|
-
};
|
93
|
-
};
|
@@ -1,80 +0,0 @@
|
|
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 getThreadInfo(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, friendList) {
|
17
|
-
if (err) {
|
18
|
-
return rejectFunc(err);
|
19
|
-
}
|
20
|
-
resolveFunc(friendList);
|
21
|
-
};
|
22
|
-
}
|
23
|
-
|
24
|
-
var form = {
|
25
|
-
client: "mercury"
|
26
|
-
};
|
27
|
-
|
28
|
-
api.getUserInfo(threadID, function(err, userRes) {
|
29
|
-
if (err) {
|
30
|
-
return callback(err);
|
31
|
-
}
|
32
|
-
var key = Object.keys(userRes).length > 0 ? "user_ids" : "thread_fbids";
|
33
|
-
form["threads[" + key + "][0]"] = threadID;
|
34
|
-
|
35
|
-
if (ctx.globalOptions.pageId)
|
36
|
-
form.request_user_id = ctx.globalOptions.pageId;
|
37
|
-
|
38
|
-
defaultFuncs
|
39
|
-
.post(
|
40
|
-
"https://www.facebook.com/ajax/mercury/thread_info.php",
|
41
|
-
ctx.jar,
|
42
|
-
form
|
43
|
-
)
|
44
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
45
|
-
.then(function(resData) {
|
46
|
-
if (resData.error) {
|
47
|
-
throw resData;
|
48
|
-
} else if (!resData.payload) {
|
49
|
-
throw {
|
50
|
-
error: "Could not retrieve thread Info."
|
51
|
-
};
|
52
|
-
}
|
53
|
-
var threadData = resData.payload.threads[0];
|
54
|
-
var userData = userRes[threadID];
|
55
|
-
|
56
|
-
if (threadData == null) {
|
57
|
-
throw {
|
58
|
-
error: "ThreadData is null"
|
59
|
-
};
|
60
|
-
}
|
61
|
-
|
62
|
-
threadData.name =
|
63
|
-
userData != null && userData.name != null
|
64
|
-
? userData.name
|
65
|
-
: threadData.name;
|
66
|
-
threadData.image_src =
|
67
|
-
userData != null && userData.thumbSrc != null
|
68
|
-
? userData.thumbSrc
|
69
|
-
: threadData.image_src;
|
70
|
-
|
71
|
-
callback(null, utils.formatThread(threadData));
|
72
|
-
})
|
73
|
-
.catch(function(err) {
|
74
|
-
log.error("getThreadInfo", err);
|
75
|
-
return callback(err);
|
76
|
-
});
|
77
|
-
});
|
78
|
-
return returnPromise;
|
79
|
-
};
|
80
|
-
};
|
@@ -1,75 +0,0 @@
|
|
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 getThreadList(start, end, type, callback) {
|
8
|
-
if (utils.getType(callback) === "Undefined") {
|
9
|
-
if (utils.getType(end) !== "Number") {
|
10
|
-
throw {
|
11
|
-
error: "Please pass a number as a second argument."
|
12
|
-
};
|
13
|
-
} else if (
|
14
|
-
utils.getType(type) === "Function" ||
|
15
|
-
utils.getType(type) === "AsyncFunction"
|
16
|
-
) {
|
17
|
-
callback = type;
|
18
|
-
type = "inbox"; //default to inbox
|
19
|
-
} else if (utils.getType(type) !== "String") {
|
20
|
-
throw {
|
21
|
-
error:
|
22
|
-
"Please pass a String as a third argument. Your options are: inbox, pending, and archived"
|
23
|
-
};
|
24
|
-
} else {
|
25
|
-
throw {
|
26
|
-
error: "getThreadList: need callback"
|
27
|
-
};
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
if (type === "archived") {
|
32
|
-
type = "action:archived";
|
33
|
-
} else if (type !== "inbox" && type !== "pending" && type !== "other") {
|
34
|
-
throw {
|
35
|
-
error:
|
36
|
-
"type can only be one of the following: inbox, pending, archived, other"
|
37
|
-
};
|
38
|
-
}
|
39
|
-
|
40
|
-
if (end <= start) end = start + 20;
|
41
|
-
|
42
|
-
var form = {
|
43
|
-
client: "mercury"
|
44
|
-
};
|
45
|
-
|
46
|
-
form[type + "[offset]"] = start;
|
47
|
-
form[type + "[limit]"] = end - start;
|
48
|
-
|
49
|
-
if (ctx.globalOptions.pageID) {
|
50
|
-
form.request_user_id = ctx.globalOptions.pageID;
|
51
|
-
}
|
52
|
-
|
53
|
-
defaultFuncs
|
54
|
-
.post(
|
55
|
-
"https://www.facebook.com/ajax/mercury/threadlist_info.php",
|
56
|
-
ctx.jar,
|
57
|
-
form
|
58
|
-
)
|
59
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
60
|
-
.then(function(resData) {
|
61
|
-
if (resData.error) {
|
62
|
-
throw resData;
|
63
|
-
}
|
64
|
-
log.verbose("getThreadList", JSON.stringify(resData.payload.threads));
|
65
|
-
return callback(
|
66
|
-
null,
|
67
|
-
(resData.payload.threads || []).map(utils.formatThread)
|
68
|
-
);
|
69
|
-
})
|
70
|
-
.catch(function(err) {
|
71
|
-
log.error("getThreadList", err);
|
72
|
-
return callback(err);
|
73
|
-
});
|
74
|
-
};
|
75
|
-
};
|
@@ -1,79 +0,0 @@
|
|
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 getThreadPictures(threadID, offset, limit, 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, friendList) {
|
17
|
-
if (err) {
|
18
|
-
return rejectFunc(err);
|
19
|
-
}
|
20
|
-
resolveFunc(friendList);
|
21
|
-
};
|
22
|
-
}
|
23
|
-
|
24
|
-
var form = {
|
25
|
-
thread_id: threadID,
|
26
|
-
offset: offset,
|
27
|
-
limit: limit
|
28
|
-
};
|
29
|
-
|
30
|
-
defaultFuncs
|
31
|
-
.post(
|
32
|
-
"https://www.facebook.com/ajax/messaging/attachments/sharedphotos.php",
|
33
|
-
ctx.jar,
|
34
|
-
form
|
35
|
-
)
|
36
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
37
|
-
.then(function(resData) {
|
38
|
-
if (resData.error) {
|
39
|
-
throw resData;
|
40
|
-
}
|
41
|
-
return Promise.all(
|
42
|
-
resData.payload.imagesData.map(function(image) {
|
43
|
-
form = {
|
44
|
-
thread_id: threadID,
|
45
|
-
image_id: image.fbid
|
46
|
-
};
|
47
|
-
return defaultFuncs
|
48
|
-
.post(
|
49
|
-
"https://www.facebook.com/ajax/messaging/attachments/sharedphotos.php",
|
50
|
-
ctx.jar,
|
51
|
-
form
|
52
|
-
)
|
53
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
54
|
-
.then(function(resData) {
|
55
|
-
if (resData.error) {
|
56
|
-
throw resData;
|
57
|
-
}
|
58
|
-
// the response is pretty messy
|
59
|
-
var queryThreadID =
|
60
|
-
resData.jsmods.require[0][3][1].query_metadata.query_path[0]
|
61
|
-
.message_thread;
|
62
|
-
var imageData =
|
63
|
-
resData.jsmods.require[0][3][1].query_results[queryThreadID]
|
64
|
-
.message_images.edges[0].node.image2;
|
65
|
-
return imageData;
|
66
|
-
});
|
67
|
-
})
|
68
|
-
);
|
69
|
-
})
|
70
|
-
.then(function(resData) {
|
71
|
-
callback(null, resData);
|
72
|
-
})
|
73
|
-
.catch(function(err) {
|
74
|
-
log.error("Error in getThreadPictures", err);
|
75
|
-
callback(err);
|
76
|
-
});
|
77
|
-
return returnPromise;
|
78
|
-
};
|
79
|
-
};
|
@@ -1,61 +0,0 @@
|
|
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 handleFriendRequest(userID, accept, callback) {
|
8
|
-
if (utils.getType(accept) !== "Boolean") {
|
9
|
-
throw {
|
10
|
-
error: "Please pass a boolean as a second argument."
|
11
|
-
};
|
12
|
-
}
|
13
|
-
|
14
|
-
var resolveFunc = function(){};
|
15
|
-
var rejectFunc = function(){};
|
16
|
-
var returnPromise = new Promise(function (resolve, reject) {
|
17
|
-
resolveFunc = resolve;
|
18
|
-
rejectFunc = reject;
|
19
|
-
});
|
20
|
-
|
21
|
-
if (!callback) {
|
22
|
-
callback = function (err, friendList) {
|
23
|
-
if (err) {
|
24
|
-
return rejectFunc(err);
|
25
|
-
}
|
26
|
-
resolveFunc(friendList);
|
27
|
-
};
|
28
|
-
}
|
29
|
-
|
30
|
-
var form = {
|
31
|
-
viewer_id: ctx.userID,
|
32
|
-
"frefs[0]": "jwl",
|
33
|
-
floc: "friend_center_requests",
|
34
|
-
ref: "/reqs.php",
|
35
|
-
action: (accept ? "confirm" : "reject")
|
36
|
-
};
|
37
|
-
|
38
|
-
defaultFuncs
|
39
|
-
.post(
|
40
|
-
"https://www.facebook.com/requests/friends/ajax/",
|
41
|
-
ctx.jar,
|
42
|
-
form
|
43
|
-
)
|
44
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
45
|
-
.then(function(resData) {
|
46
|
-
if (resData.payload.err) {
|
47
|
-
throw {
|
48
|
-
err: resData.payload.err
|
49
|
-
};
|
50
|
-
}
|
51
|
-
|
52
|
-
return callback();
|
53
|
-
})
|
54
|
-
.catch(function(err) {
|
55
|
-
log.error("handleFriendRequest", err);
|
56
|
-
return callback(err);
|
57
|
-
});
|
58
|
-
|
59
|
-
return returnPromise;
|
60
|
-
};
|
61
|
-
};
|
@@ -1,65 +0,0 @@
|
|
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 handleMessageRequest(threadID, accept, callback) {
|
8
|
-
if (utils.getType(accept) !== "Boolean") {
|
9
|
-
throw {
|
10
|
-
error: "Please pass a boolean as a second argument."
|
11
|
-
};
|
12
|
-
}
|
13
|
-
|
14
|
-
var resolveFunc = function(){};
|
15
|
-
var rejectFunc = function(){};
|
16
|
-
var returnPromise = new Promise(function (resolve, reject) {
|
17
|
-
resolveFunc = resolve;
|
18
|
-
rejectFunc = reject;
|
19
|
-
});
|
20
|
-
|
21
|
-
if (!callback) {
|
22
|
-
callback = function (err, friendList) {
|
23
|
-
if (err) {
|
24
|
-
return rejectFunc(err);
|
25
|
-
}
|
26
|
-
resolveFunc(friendList);
|
27
|
-
};
|
28
|
-
}
|
29
|
-
|
30
|
-
var form = {
|
31
|
-
client: "mercury"
|
32
|
-
};
|
33
|
-
|
34
|
-
if (utils.getType(threadID) !== "Array") {
|
35
|
-
threadID = [threadID];
|
36
|
-
}
|
37
|
-
|
38
|
-
var messageBox = accept ? "inbox" : "other";
|
39
|
-
|
40
|
-
for (var i = 0; i < threadID.length; i++) {
|
41
|
-
form[messageBox + "[" + i + "]"] = threadID[i];
|
42
|
-
}
|
43
|
-
|
44
|
-
defaultFuncs
|
45
|
-
.post(
|
46
|
-
"https://www.facebook.com/ajax/mercury/move_thread.php",
|
47
|
-
ctx.jar,
|
48
|
-
form
|
49
|
-
)
|
50
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
51
|
-
.then(function(resData) {
|
52
|
-
if (resData.error) {
|
53
|
-
throw resData;
|
54
|
-
}
|
55
|
-
|
56
|
-
return callback();
|
57
|
-
})
|
58
|
-
.catch(function(err) {
|
59
|
-
log.error("handleMessageRequest", err);
|
60
|
-
return callback(err);
|
61
|
-
});
|
62
|
-
|
63
|
-
return returnPromise;
|
64
|
-
};
|
65
|
-
};
|