alicezetion 1.0.3 → 1.0.4
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/.travis.yml +6 -0
- package/index.js +532 -604
- package/package.json +78 -75
- package/replit.nix +5 -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 +1190 -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
@@ -0,0 +1,42 @@
|
|
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 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
|
+
});
|
14
|
+
if (!callback) {
|
15
|
+
callback = function (err) {
|
16
|
+
if (err) return rejectFunc(err);
|
17
|
+
resolveFunc();
|
18
|
+
};
|
19
|
+
}
|
20
|
+
|
21
|
+
var form = {
|
22
|
+
client: "mercury"
|
23
|
+
};
|
24
|
+
|
25
|
+
if (utils.getType(threadOrThreads) !== "Array") threadOrThreads = [threadOrThreads];
|
26
|
+
for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + i + "]"] = threadOrThreads[i];
|
27
|
+
|
28
|
+
defaultFuncs
|
29
|
+
.post("https://www.facebook.com/ajax/mercury/delete_thread.php", ctx.jar, form)
|
30
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
31
|
+
.then(function (resData) {
|
32
|
+
if (resData.error) throw resData;
|
33
|
+
return callback();
|
34
|
+
})
|
35
|
+
.catch(function (err) {
|
36
|
+
log.error("deleteThread", err);
|
37
|
+
return callback(err);
|
38
|
+
});
|
39
|
+
|
40
|
+
return returnPromise;
|
41
|
+
};
|
42
|
+
};
|
@@ -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 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
|
+
});
|
14
|
+
if (!callback) {
|
15
|
+
callback = function (err) {
|
16
|
+
if (err) return rejectFunc(err);
|
17
|
+
resolveFunc();
|
18
|
+
};
|
19
|
+
}
|
20
|
+
|
21
|
+
var form = {
|
22
|
+
attachment_id: attachmentID
|
23
|
+
};
|
24
|
+
|
25
|
+
if (utils.getType(userOrUsers) !== "Array") userOrUsers = [userOrUsers];
|
26
|
+
|
27
|
+
var timestamp = Math.floor(Date.now() / 1000);
|
28
|
+
|
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++) form["recipient_map[" + (timestamp + i) + "]"] = userOrUsers[i];
|
32
|
+
|
33
|
+
defaultFuncs
|
34
|
+
.post("https://www.facebook.com/mercury/attachments/forward/", ctx.jar, form)
|
35
|
+
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
|
36
|
+
.then(function (resData) {
|
37
|
+
if (resData.error) throw resData;
|
38
|
+
return callback();
|
39
|
+
})
|
40
|
+
.catch(function (err) {
|
41
|
+
log.error("forwardAttachment", err);
|
42
|
+
return callback(err);
|
43
|
+
});
|
44
|
+
|
45
|
+
return returnPromise;
|
46
|
+
};
|
47
|
+
};
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
4
|
-
return function getCurrentUserID() {
|
5
|
-
return ctx.userID;
|
6
|
-
};
|
7
|
-
};
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
4
|
+
return function getCurrentUserID() {
|
5
|
+
return ctx.userID;
|
6
|
+
};
|
7
|
+
};
|
@@ -1,29 +1,27 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
const util = require("util");
|
4
|
-
|
5
|
-
module.exports = function() {
|
6
|
-
return function getEmojiUrl(c, size, pixelRatio) {
|
7
|
-
/*
|
8
|
-
Resolves Facebook Messenger emoji image asset URL for an emoji character.
|
9
|
-
Supported sizes are 32, 64, and 128.
|
10
|
-
Supported pixel ratios are '1.0' and '1.5' (possibly more; haven't tested)
|
11
|
-
*/
|
12
|
-
const baseUrl = "https://static.xx.fbcdn.net/images/emoji.php/v8/z%s/%s";
|
13
|
-
pixelRatio = pixelRatio || "1.0";
|
14
|
-
|
15
|
-
let ending = util.format(
|
16
|
-
"%s/%s/%s.png",
|
17
|
-
pixelRatio,
|
18
|
-
size,
|
19
|
-
c.codePointAt(0).toString(16)
|
20
|
-
);
|
21
|
-
let base = 317426846;
|
22
|
-
for (let i = 0; i < ending.length; i++)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
};
|
29
|
-
};
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const util = require("util");
|
4
|
+
|
5
|
+
module.exports = function () {
|
6
|
+
return function getEmojiUrl(c, size, pixelRatio) {
|
7
|
+
/*
|
8
|
+
Resolves Facebook Messenger emoji image asset URL for an emoji character.
|
9
|
+
Supported sizes are 32, 64, and 128.
|
10
|
+
Supported pixel ratios are '1.0' and '1.5' (possibly more; haven't tested)
|
11
|
+
*/
|
12
|
+
const baseUrl = "https://static.xx.fbcdn.net/images/emoji.php/v8/z%s/%s";
|
13
|
+
pixelRatio = pixelRatio || "1.0";
|
14
|
+
|
15
|
+
let ending = util.format(
|
16
|
+
"%s/%s/%s.png",
|
17
|
+
pixelRatio,
|
18
|
+
size,
|
19
|
+
c.codePointAt(0).toString(16)
|
20
|
+
);
|
21
|
+
let base = 317426846;
|
22
|
+
for (let i = 0; i < ending.length; i++) base = (base << 5) - base + ending.charCodeAt(i);
|
23
|
+
|
24
|
+
let hashed = (base & 255).toString(16);
|
25
|
+
return util.format(baseUrl, hashed, ending);
|
26
|
+
};
|
27
|
+
};
|
@@ -1,84 +1,73 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
//var cheerio = require("cheerio");
|
4
|
-
var utils = require("../utils");
|
5
|
-
var log = require("npmlog");
|
6
|
-
|
7
|
-
// [almost] copy pasted from one of FB's minified file (GenderConst)
|
8
|
-
var GENDERS = {
|
9
|
-
0: "unknown",
|
10
|
-
1: "female_singular",
|
11
|
-
2: "male_singular",
|
12
|
-
3: "female_singular_guess",
|
13
|
-
4: "male_singular_guess",
|
14
|
-
5: "mixed",
|
15
|
-
6: "neuter_singular",
|
16
|
-
7: "unknown_singular",
|
17
|
-
8: "female_plural",
|
18
|
-
9: "male_plural",
|
19
|
-
10: "neuter_plural",
|
20
|
-
11: "unknown_plural"
|
21
|
-
};
|
22
|
-
|
23
|
-
function formatData(obj) {
|
24
|
-
return Object.keys(obj).map(function(key) {
|
25
|
-
var user = obj[key];
|
26
|
-
return {
|
27
|
-
alternateName: user.alternateName,
|
28
|
-
firstName: user.firstName,
|
29
|
-
gender: GENDERS[user.gender],
|
30
|
-
userID: utils.formatID(user.id.toString()),
|
31
|
-
isFriend: user.is_friend != null && user.is_friend ? true : false,
|
32
|
-
fullName: user.name,
|
33
|
-
profilePicture: user.thumbSrc,
|
34
|
-
type: user.type,
|
35
|
-
profileUrl: user.uri,
|
36
|
-
vanity: user.vanity,
|
37
|
-
isBirthday: !!user.is_birthday
|
38
|
-
};
|
39
|
-
});
|
40
|
-
}
|
41
|
-
|
42
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
43
|
-
return function getFriendsList(callback) {
|
44
|
-
var resolveFunc = function(){};
|
45
|
-
var rejectFunc = function(){};
|
46
|
-
var returnPromise = new Promise(function (resolve, reject) {
|
47
|
-
resolveFunc = resolve;
|
48
|
-
rejectFunc = reject;
|
49
|
-
});
|
50
|
-
|
51
|
-
if (!callback) {
|
52
|
-
callback = function (err, friendList) {
|
53
|
-
if (err)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
.
|
62
|
-
"
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
)
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
}
|
75
|
-
callback(null, formatData(resData.payload));
|
76
|
-
})
|
77
|
-
.catch(function(err) {
|
78
|
-
log.error("getFriendsList", err);
|
79
|
-
return callback(err);
|
80
|
-
});
|
81
|
-
|
82
|
-
return returnPromise;
|
83
|
-
};
|
84
|
-
};
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
//var cheerio = require("cheerio");
|
4
|
+
var utils = require("../utils");
|
5
|
+
var log = require("npmlog");
|
6
|
+
|
7
|
+
// [almost] copy pasted from one of FB's minified file (GenderConst)
|
8
|
+
var GENDERS = {
|
9
|
+
0: "unknown",
|
10
|
+
1: "female_singular",
|
11
|
+
2: "male_singular",
|
12
|
+
3: "female_singular_guess",
|
13
|
+
4: "male_singular_guess",
|
14
|
+
5: "mixed",
|
15
|
+
6: "neuter_singular",
|
16
|
+
7: "unknown_singular",
|
17
|
+
8: "female_plural",
|
18
|
+
9: "male_plural",
|
19
|
+
10: "neuter_plural",
|
20
|
+
11: "unknown_plural"
|
21
|
+
};
|
22
|
+
|
23
|
+
function formatData(obj) {
|
24
|
+
return Object.keys(obj).map(function (key) {
|
25
|
+
var user = obj[key];
|
26
|
+
return {
|
27
|
+
alternateName: user.alternateName,
|
28
|
+
firstName: user.firstName,
|
29
|
+
gender: GENDERS[user.gender],
|
30
|
+
userID: utils.formatID(user.id.toString()),
|
31
|
+
isFriend: user.is_friend != null && user.is_friend ? true : false,
|
32
|
+
fullName: user.name,
|
33
|
+
profilePicture: user.thumbSrc,
|
34
|
+
type: user.type,
|
35
|
+
profileUrl: user.uri,
|
36
|
+
vanity: user.vanity,
|
37
|
+
isBirthday: !!user.is_birthday
|
38
|
+
};
|
39
|
+
});
|
40
|
+
}
|
41
|
+
|
42
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
43
|
+
return function getFriendsList(callback) {
|
44
|
+
var resolveFunc = function () { };
|
45
|
+
var rejectFunc = function () { };
|
46
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
47
|
+
resolveFunc = resolve;
|
48
|
+
rejectFunc = reject;
|
49
|
+
});
|
50
|
+
|
51
|
+
if (!callback) {
|
52
|
+
callback = function (err, friendList) {
|
53
|
+
if (err) return rejectFunc(err);
|
54
|
+
resolveFunc(friendList);
|
55
|
+
};
|
56
|
+
}
|
57
|
+
|
58
|
+
defaultFuncs
|
59
|
+
.postFormData("https://www.facebook.com/chat/user_info_all", ctx.jar, {}, { viewer: ctx.userID })
|
60
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
61
|
+
.then(function (resData) {
|
62
|
+
if (!resData) throw { error: "getFriendsList returned empty object." };
|
63
|
+
if (resData.error) throw resData;
|
64
|
+
callback(null, formatData(resData.payload));
|
65
|
+
})
|
66
|
+
.catch(function (err) {
|
67
|
+
log.error("getFriendsList", err);
|
68
|
+
return callback(err);
|
69
|
+
});
|
70
|
+
|
71
|
+
return returnPromise;
|
72
|
+
};
|
73
|
+
};
|