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
@@ -5,18 +5,17 @@ var log = require("npmlog");
|
|
5
5
|
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function logout(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
|
-
}
|
16
|
+
callback = function(err, friendList) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
|
20
19
|
resolveFunc(friendList);
|
21
20
|
};
|
22
21
|
}
|
@@ -52,9 +51,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
52
51
|
.then(utils.saveCookies(ctx.jar));
|
53
52
|
})
|
54
53
|
.then(function(res) {
|
55
|
-
if (!res.headers)
|
54
|
+
if (!res.headers)
|
56
55
|
throw { error: "An error occurred when logging out." };
|
57
|
-
}
|
58
56
|
|
59
57
|
return defaultFuncs
|
60
58
|
.get(res.headers.location, ctx.jar)
|
@@ -3,27 +3,25 @@
|
|
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 markAsDelivered(threadID, messageID, 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, data) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
|
19
|
+
resolveFunc(data);
|
21
20
|
};
|
22
21
|
}
|
23
22
|
|
24
|
-
if (!threadID || !messageID)
|
23
|
+
if (!threadID || !messageID)
|
25
24
|
return callback("Error: messageID or threadID is not defined");
|
26
|
-
}
|
27
25
|
|
28
26
|
var form = {};
|
29
27
|
|
@@ -38,18 +36,16 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
38
36
|
)
|
39
37
|
.then(utils.saveCookies(ctx.jar))
|
40
38
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
41
|
-
.then(function
|
42
|
-
if (resData.error)
|
43
|
-
throw resData;
|
44
|
-
}
|
39
|
+
.then(function(resData) {
|
40
|
+
if (resData.error) throw resData;
|
45
41
|
|
46
42
|
return callback();
|
47
43
|
})
|
48
|
-
.catch(function
|
44
|
+
.catch(function(err) {
|
49
45
|
log.error("markAsDelivered", err);
|
50
|
-
if (utils.getType(err) == "Object" && err.error === "Not logged in.")
|
46
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in.")
|
51
47
|
ctx.loggedIn = false;
|
52
|
-
|
48
|
+
|
53
49
|
return callback(err);
|
54
50
|
});
|
55
51
|
|
@@ -3,23 +3,22 @@
|
|
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 async function markAsRead(threadID, read, callback) {
|
8
|
-
if (
|
8
|
+
if (
|
9
|
+
utils.getType(read) === "Function" ||
|
10
|
+
utils.getType(read) === "AsyncFunction"
|
11
|
+
) {
|
9
12
|
callback = read;
|
10
13
|
read = true;
|
11
14
|
}
|
12
|
-
if (read == undefined)
|
13
|
-
read = true;
|
14
|
-
}
|
15
|
+
if (read == undefined) read = true;
|
15
16
|
|
16
|
-
if (!callback) {
|
17
|
-
callback = () => { };
|
18
|
-
}
|
17
|
+
if (!callback) callback = () => {};
|
19
18
|
|
20
19
|
var form = {};
|
21
20
|
|
22
|
-
if (typeof ctx.globalOptions.pageID !==
|
21
|
+
if (typeof ctx.globalOptions.pageID !== "undefined") {
|
23
22
|
form["source"] = "PagesManagerMessagesInterface";
|
24
23
|
form["request_user_id"] = ctx.globalOptions.pageID;
|
25
24
|
form["ids[" + threadID + "]"] = read;
|
@@ -30,16 +29,14 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
30
29
|
|
31
30
|
let resData;
|
32
31
|
try {
|
33
|
-
resData = await
|
34
|
-
|
35
|
-
.
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
42
|
-
);
|
32
|
+
resData = await defaultFuncs
|
33
|
+
.post(
|
34
|
+
"https://www.facebook.com/ajax/mercury/change_read_status.php",
|
35
|
+
ctx.jar,
|
36
|
+
form
|
37
|
+
)
|
38
|
+
.then(utils.saveCookies(ctx.jar))
|
39
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs));
|
43
40
|
} catch (e) {
|
44
41
|
callback(e);
|
45
42
|
return e;
|
@@ -48,9 +45,8 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
48
45
|
if (resData.error) {
|
49
46
|
let err = resData.error;
|
50
47
|
log.error("markAsRead", err);
|
51
|
-
if (utils.getType(err) == "Object" && err.error === "Not logged in.")
|
48
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in.")
|
52
49
|
ctx.loggedIn = false;
|
53
|
-
}
|
54
50
|
callback(err);
|
55
51
|
return err;
|
56
52
|
}
|
@@ -60,17 +56,23 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
60
56
|
} else {
|
61
57
|
try {
|
62
58
|
if (ctx.mqttClient) {
|
63
|
-
let err = await new Promise(r =>
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
59
|
+
let err = await new Promise(r =>
|
60
|
+
ctx.mqttClient.publish(
|
61
|
+
"/mark_thread",
|
62
|
+
JSON.stringify({
|
63
|
+
threadID,
|
64
|
+
mark: "read",
|
65
|
+
state: read
|
66
|
+
}),
|
67
|
+
{ qos: 1, retain: false },
|
68
|
+
r
|
69
|
+
)
|
70
|
+
);
|
68
71
|
if (err) throw err;
|
69
|
-
} else
|
72
|
+
} else
|
70
73
|
throw {
|
71
74
|
error: "You can only use this function after you start listening."
|
72
75
|
};
|
73
|
-
}
|
74
76
|
} catch (e) {
|
75
77
|
callback(e);
|
76
78
|
return e;
|
@@ -3,27 +3,28 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function
|
7
|
-
return function
|
8
|
-
if (
|
9
|
-
utils.getType(seen_timestamp) == "
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
+
return function markAsSeen(seen_timestamp, callback) {
|
8
|
+
if (
|
9
|
+
utils.getType(seen_timestamp) == "Function" ||
|
10
|
+
utils.getType(seen_timestamp) == "AsyncFunction"
|
11
|
+
) {
|
10
12
|
callback = seen_timestamp;
|
11
13
|
seen_timestamp = Date.now();
|
12
14
|
}
|
13
15
|
|
14
|
-
var resolveFunc = function
|
15
|
-
var rejectFunc = function
|
16
|
-
var returnPromise = new Promise(function
|
16
|
+
var resolveFunc = function() {};
|
17
|
+
var rejectFunc = function() {};
|
18
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
17
19
|
resolveFunc = resolve;
|
18
20
|
rejectFunc = reject;
|
19
21
|
});
|
20
22
|
|
21
23
|
if (!callback) {
|
22
|
-
callback = function
|
23
|
-
if (err)
|
24
|
-
|
25
|
-
|
26
|
-
resolveFunc(friendList);
|
24
|
+
callback = function(err, data) {
|
25
|
+
if (err) return rejectFunc(err);
|
26
|
+
|
27
|
+
resolveFunc(data);
|
27
28
|
};
|
28
29
|
}
|
29
30
|
|
@@ -39,18 +40,16 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
39
40
|
)
|
40
41
|
.then(utils.saveCookies(ctx.jar))
|
41
42
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
42
|
-
.then(function
|
43
|
-
if (resData.error)
|
44
|
-
throw resData;
|
45
|
-
}
|
43
|
+
.then(function(resData) {
|
44
|
+
if (resData.error) throw resData;
|
46
45
|
|
47
46
|
return callback();
|
48
47
|
})
|
49
|
-
.catch(function
|
48
|
+
.catch(function(err) {
|
50
49
|
log.error("markAsSeen", err);
|
51
|
-
if (utils.getType(err) == "Object" && err.error === "Not logged in.")
|
50
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in.")
|
52
51
|
ctx.loggedIn = false;
|
53
|
-
|
52
|
+
|
54
53
|
return callback(err);
|
55
54
|
});
|
56
55
|
|
@@ -6,19 +6,18 @@ var log = require("npmlog");
|
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
// muteSecond: -1=permanent mute, 0=unmute, 60=one minute, 3600=one hour, etc.
|
8
8
|
return function muteThread(threadID, muteSeconds, callback) {
|
9
|
-
var resolveFunc = function(){};
|
10
|
-
var rejectFunc = function(){};
|
11
|
-
var returnPromise = new Promise(function
|
9
|
+
var resolveFunc = function() {};
|
10
|
+
var rejectFunc = function() {};
|
11
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
12
12
|
resolveFunc = resolve;
|
13
13
|
rejectFunc = reject;
|
14
14
|
});
|
15
15
|
|
16
16
|
if (!callback) {
|
17
|
-
callback = function
|
18
|
-
if (err)
|
19
|
-
|
20
|
-
|
21
|
-
resolveFunc(friendList);
|
17
|
+
callback = function(err, data) {
|
18
|
+
if (err) return rejectFunc(err);
|
19
|
+
|
20
|
+
resolveFunc(data);
|
22
21
|
};
|
23
22
|
}
|
24
23
|
|
@@ -4,20 +4,23 @@ var utils = require("../utils");
|
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
-
return function setMessageReaction(
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
return function setMessageReaction(
|
8
|
+
reaction,
|
9
|
+
messageID,
|
10
|
+
callback,
|
11
|
+
forceCustomReaction
|
12
|
+
) {
|
13
|
+
var resolveFunc = function() {};
|
14
|
+
var rejectFunc = function() {};
|
15
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
11
16
|
resolveFunc = resolve;
|
12
17
|
rejectFunc = reject;
|
13
18
|
});
|
14
19
|
|
15
20
|
if (!callback) {
|
16
|
-
callback = function
|
17
|
-
if (err)
|
18
|
-
|
19
|
-
}
|
20
|
-
resolveFunc(friendList);
|
21
|
+
callback = function(err, data) {
|
22
|
+
if (err) return rejectFunc(err);
|
23
|
+
resolveFunc(data);
|
21
24
|
};
|
22
25
|
}
|
23
26
|
|
@@ -68,9 +71,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
68
71
|
reaction = "\uD83D\uDC97";
|
69
72
|
break;
|
70
73
|
default:
|
71
|
-
if (forceCustomReaction)
|
72
|
-
break;
|
73
|
-
}
|
74
|
+
if (forceCustomReaction) break;
|
74
75
|
return callback({ error: "Reaction is not a valid emoji." });
|
75
76
|
}
|
76
77
|
|
@@ -99,12 +100,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
99
100
|
)
|
100
101
|
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
|
101
102
|
.then(function(resData) {
|
102
|
-
if (!resData) {
|
103
|
-
|
104
|
-
}
|
105
|
-
if (resData.error) {
|
106
|
-
throw resData;
|
107
|
-
}
|
103
|
+
if (!resData) throw { error: "setReaction returned empty object." };
|
104
|
+
if (resData.error) throw resData;
|
108
105
|
callback(null);
|
109
106
|
})
|
110
107
|
.catch(function(err) {
|
@@ -9,45 +9,41 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
9
9
|
!callback &&
|
10
10
|
(utils.getType(threadID) === "Function" ||
|
11
11
|
utils.getType(threadID) === "AsyncFunction")
|
12
|
-
)
|
12
|
+
)
|
13
13
|
throw { error: "please pass a threadID as a second argument." };
|
14
|
-
}
|
15
14
|
if (
|
16
15
|
utils.getType(threadID) !== "Number" &&
|
17
16
|
utils.getType(threadID) !== "String"
|
18
|
-
)
|
17
|
+
)
|
19
18
|
throw {
|
20
19
|
error:
|
21
20
|
"threadID should be of type Number or String and not " +
|
22
21
|
utils.getType(threadID) +
|
23
22
|
"."
|
24
23
|
};
|
25
|
-
}
|
26
24
|
if (
|
27
25
|
utils.getType(userID) !== "Number" &&
|
28
26
|
utils.getType(userID) !== "String"
|
29
|
-
)
|
27
|
+
)
|
30
28
|
throw {
|
31
29
|
error:
|
32
30
|
"userID should be of type Number or String and not " +
|
33
31
|
utils.getType(userID) +
|
34
32
|
"."
|
35
33
|
};
|
36
|
-
}
|
37
34
|
|
38
|
-
var resolveFunc = function(){};
|
39
|
-
var rejectFunc = function(){};
|
40
|
-
var returnPromise = new Promise(function
|
35
|
+
var resolveFunc = function() {};
|
36
|
+
var rejectFunc = function() {};
|
37
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
41
38
|
resolveFunc = resolve;
|
42
39
|
rejectFunc = reject;
|
43
40
|
});
|
44
41
|
|
45
42
|
if (!callback) {
|
46
|
-
callback = function
|
47
|
-
if (err)
|
48
|
-
|
49
|
-
|
50
|
-
resolveFunc(friendList);
|
43
|
+
callback = function(err, data) {
|
44
|
+
if (err) return rejectFunc(err);
|
45
|
+
|
46
|
+
resolveFunc(data);
|
51
47
|
};
|
52
48
|
}
|
53
49
|
|
@@ -60,12 +56,9 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
60
56
|
.post("https://www.facebook.com/chat/remove_participants", ctx.jar, form)
|
61
57
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
62
58
|
.then(function(resData) {
|
63
|
-
if (!resData) {
|
64
|
-
|
65
|
-
|
66
|
-
if (resData.error) {
|
67
|
-
throw resData;
|
68
|
-
}
|
59
|
+
if (!resData) throw { error: "Remove from group failed." };
|
60
|
+
|
61
|
+
if (resData.error) throw resData;
|
69
62
|
|
70
63
|
return callback();
|
71
64
|
})
|
@@ -5,19 +5,17 @@ var log = require("npmlog");
|
|
5
5
|
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function resolvePhotoUrl(photoID, 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, data) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
resolveFunc(data);
|
21
19
|
};
|
22
20
|
}
|
23
21
|
|
@@ -27,12 +25,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
27
25
|
})
|
28
26
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
29
27
|
.then(resData => {
|
30
|
-
if (resData.error)
|
31
|
-
throw resData;
|
32
|
-
}
|
33
|
-
|
28
|
+
if (resData.error) throw resData;
|
34
29
|
var photoUrl = resData.jsmods.require[0][3][0];
|
35
|
-
|
36
30
|
return callback(null, photoUrl);
|
37
31
|
})
|
38
32
|
.catch(err => {
|
@@ -4,19 +4,17 @@ var utils = require("../utils");
|
|
4
4
|
|
5
5
|
module.exports = function(defaultFuncs, api, ctx) {
|
6
6
|
return function searchForThread(name, callback) {
|
7
|
-
var resolveFunc = function(){};
|
8
|
-
var rejectFunc = function(){};
|
9
|
-
var returnPromise = new Promise(function
|
7
|
+
var resolveFunc = function() {};
|
8
|
+
var rejectFunc = function() {};
|
9
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
10
10
|
resolveFunc = resolve;
|
11
11
|
rejectFunc = reject;
|
12
12
|
});
|
13
13
|
|
14
14
|
if (!callback) {
|
15
|
-
callback = function
|
16
|
-
if (err)
|
17
|
-
|
18
|
-
}
|
19
|
-
resolveFunc(friendList);
|
15
|
+
callback = function(err, data) {
|
16
|
+
if (err) return rejectFunc(err);
|
17
|
+
resolveFunc(data);
|
20
18
|
};
|
21
19
|
}
|
22
20
|
|
@@ -36,12 +34,9 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
36
34
|
)
|
37
35
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
38
36
|
.then(function(resData) {
|
39
|
-
if (resData.error)
|
40
|
-
|
41
|
-
}
|
42
|
-
if (!resData.payload.mercury_payload.threads) {
|
37
|
+
if (resData.error) throw resData;
|
38
|
+
if (!resData.payload.mercury_payload.threads)
|
43
39
|
return callback({ error: "Could not find thread `" + name + "`." });
|
44
|
-
}
|
45
40
|
return callback(
|
46
41
|
null,
|
47
42
|
resData.payload.mercury_payload.threads.map(utils.formatThread)
|
@@ -5,24 +5,23 @@ var log = require("npmlog");
|
|
5
5
|
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function markAsReadAll(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, data) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
|
19
|
+
resolveFunc(data);
|
21
20
|
};
|
22
21
|
}
|
23
22
|
|
24
23
|
var form = {
|
25
|
-
folder:
|
24
|
+
folder: "inbox"
|
26
25
|
};
|
27
26
|
|
28
27
|
defaultFuncs
|
@@ -34,9 +33,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
34
33
|
.then(utils.saveCookies(ctx.jar))
|
35
34
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
36
35
|
.then(function(resData) {
|
37
|
-
if (resData.error)
|
38
|
-
throw resData;
|
39
|
-
}
|
36
|
+
if (resData.error) throw resData;
|
40
37
|
|
41
38
|
return callback();
|
42
39
|
})
|
@@ -47,4 +44,4 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
47
44
|
|
48
45
|
return returnPromise;
|
49
46
|
};
|
50
|
-
};
|
47
|
+
};
|
@@ -3,7 +3,7 @@
|
|
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
|
function makeTypingIndicator(typ, threadID, callback, isGroup) {
|
8
8
|
var form = {
|
9
9
|
typ: +typ,
|
@@ -21,14 +21,11 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
21
21
|
defaultFuncs
|
22
22
|
.post("https://www.facebook.com/ajax/messaging/typ.php", ctx.jar, form)
|
23
23
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
24
|
-
.then(function
|
25
|
-
if (resData.error)
|
26
|
-
throw resData;
|
27
|
-
}
|
28
|
-
|
24
|
+
.then(function(resData) {
|
25
|
+
if (resData.error) throw resData;
|
29
26
|
return callback();
|
30
27
|
})
|
31
|
-
.catch(function
|
28
|
+
.catch(function(err) {
|
32
29
|
log.error("sendTypingIndicator", err);
|
33
30
|
if (utils.getType(err) == "Object" && err.error === "Not logged in") {
|
34
31
|
ctx.loggedIn = false;
|
@@ -36,31 +33,28 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
36
33
|
return callback(err);
|
37
34
|
});
|
38
35
|
} else {
|
39
|
-
api.getUserInfo(threadID, function
|
40
|
-
if (err)
|
41
|
-
return callback(err);
|
42
|
-
}
|
43
|
-
|
36
|
+
api.getUserInfo(threadID, function(err, res) {
|
37
|
+
if (err) return callback(err);
|
44
38
|
// If id is single person chat
|
45
|
-
if (Object.keys(res).length > 0)
|
46
|
-
form.to = threadID;
|
47
|
-
}
|
48
|
-
|
39
|
+
if (Object.keys(res).length > 0) form.to = threadID;
|
49
40
|
defaultFuncs
|
50
|
-
.post(
|
41
|
+
.post(
|
42
|
+
"https://www.facebook.com/ajax/messaging/typ.php",
|
43
|
+
ctx.jar,
|
44
|
+
form
|
45
|
+
)
|
51
46
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
52
|
-
.then(function
|
53
|
-
if (resData.error)
|
54
|
-
throw resData;
|
55
|
-
}
|
56
|
-
|
47
|
+
.then(function(resData) {
|
48
|
+
if (resData.error) throw resData;
|
57
49
|
return callback();
|
58
50
|
})
|
59
|
-
.catch(function
|
51
|
+
.catch(function(err) {
|
60
52
|
log.error("sendTypingIndicator", err);
|
61
|
-
if (
|
53
|
+
if (
|
54
|
+
utils.getType(err) == "Object" &&
|
55
|
+
err.error === "Not logged in."
|
56
|
+
)
|
62
57
|
ctx.loggedIn = false;
|
63
|
-
}
|
64
58
|
return callback(err);
|
65
59
|
});
|
66
60
|
});
|
@@ -72,13 +66,12 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
72
66
|
utils.getType(callback) !== "Function" &&
|
73
67
|
utils.getType(callback) !== "AsyncFunction"
|
74
68
|
) {
|
75
|
-
if (callback)
|
69
|
+
if (callback)
|
76
70
|
log.warn(
|
77
71
|
"sendTypingIndicator",
|
78
72
|
"callback is not a function - ignoring."
|
79
73
|
);
|
80
|
-
}
|
81
|
-
callback = () => { };
|
74
|
+
callback = () => {};
|
82
75
|
}
|
83
76
|
|
84
77
|
makeTypingIndicator(true, threadID, callback, isGroup);
|
@@ -88,13 +81,12 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
88
81
|
utils.getType(cb) !== "Function" &&
|
89
82
|
utils.getType(cb) !== "AsyncFunction"
|
90
83
|
) {
|
91
|
-
if (cb)
|
84
|
+
if (cb)
|
92
85
|
log.warn(
|
93
86
|
"sendTypingIndicator",
|
94
87
|
"callback is not a function - ignoring."
|
95
88
|
);
|
96
|
-
}
|
97
|
-
cb = () => { };
|
89
|
+
cb = () => {};
|
98
90
|
}
|
99
91
|
|
100
92
|
makeTypingIndicator(false, threadID, cb, isGroup);
|