alicezetion 1.8.2 → 1.8.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/index.js +210 -375
- package/package.json +6 -3
- package/replit.nix +4 -4
- package/src/addExternalModule.js +17 -0
- package/src/addUserToGroup.js +113 -0
- package/src/changeAdminStatus.js +79 -0
- package/src/changeArchivedStatus.js +55 -0
- package/src/changeAvatar.js +93 -0
- package/src/changeBio.js +77 -0
- package/src/changeBlockedStatus.js +47 -0
- package/src/changeCover.js +73 -0
- package/src/changeGroupImage.js +132 -0
- package/src/changeName.js +79 -0
- package/src/changeNickname.js +59 -0
- package/src/changeThreadColor.js +65 -0
- package/src/changeThreadEmoji.js +55 -0
- package/{leiamnash → src}/chat.js +28 -3
- package/src/createNewGroup.js +86 -0
- package/src/createPoll.js +71 -0
- package/src/data/getThreadInfo.json +1 -0
- package/src/deleteMessage.js +56 -0
- package/src/deleteThread.js +56 -0
- package/src/forwardAttachment.js +60 -0
- package/src/getAccess.js +112 -0
- package/src/getAvatarUser.js +78 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +29 -0
- package/src/getFriendsList.js +83 -0
- package/src/getThreadHistory.js +666 -0
- package/{leiamnash → src}/getThreadInfo.js +70 -54
- package/src/getThreadList.js +237 -0
- package/src/getThreadPictures.js +79 -0
- package/src/getUserID.js +66 -0
- package/src/getUserInfo.js +163 -0
- package/src/handleFriendRequest.js +61 -0
- package/src/handleMessageRequest.js +65 -0
- package/src/httpGet.js +57 -0
- package/src/httpPost.js +57 -0
- package/src/httpPostFormData.js +63 -0
- package/{leiamnash → src}/listenMqtt.js +16 -6
- package/src/listenNotification.js +88 -0
- package/src/logout.js +275 -0
- package/src/markAsDelivered.js +58 -0
- package/src/markAsRead.js +80 -0
- package/src/markAsReadAll.js +50 -0
- package/src/markAsSeen.js +59 -0
- package/src/muteThread.js +52 -0
- package/src/react.js +117 -0
- package/{leiamnash → src}/refreshFb_dtsg.js +1 -1
- package/src/removeUserFromGroup.js +79 -0
- package/src/resolvePhotoUrl.js +45 -0
- package/src/searchForThread.js +53 -0
- package/src/searchStickers.js +52 -0
- package/src/seen.js +50 -0
- package/src/sendMessage.js +477 -0
- package/src/sendMessageMqtt.js +316 -0
- package/src/sendTypingIndicator.js +103 -0
- package/src/setMessageReaction.js +117 -0
- package/src/setPostReaction.js +109 -0
- package/src/setTitle.js +86 -0
- package/src/threadColors.js +131 -0
- package/src/unfriend.js +52 -0
- package/src/unsendMessage.js +49 -0
- package/utils.js +135 -176
- package/.cache/replit/modules.stamp +0 -1
- package/leiamnash/addExternalModule.js +0 -15
- package/leiamnash/addUserToGroup.js +0 -77
- package/leiamnash/changeAdminStatus.js +0 -47
- package/leiamnash/changeArchivedStatus.js +0 -41
- package/leiamnash/changeAvatar.js +0 -127
- package/leiamnash/changeBio.js +0 -64
- package/leiamnash/changeBlockedStatus.js +0 -36
- package/leiamnash/changeGroupImage.js +0 -105
- package/leiamnash/changeNickname.js +0 -43
- package/leiamnash/changeThreadColor.js +0 -61
- package/leiamnash/changeThreadEmoji.js +0 -41
- package/leiamnash/createNewGroup.js +0 -70
- package/leiamnash/createPoll.js +0 -59
- package/leiamnash/deleteMessage.js +0 -44
- package/leiamnash/deleteThread.js +0 -42
- package/leiamnash/forwardAttachment.js +0 -47
- package/leiamnash/forwardMessage.js +0 -0
- package/leiamnash/getCurrentUserID.js +0 -7
- package/leiamnash/getEmojiUrl.js +0 -27
- package/leiamnash/getFriendsList.js +0 -73
- package/leiamnash/getInfoVideo.js +0 -134
- package/leiamnash/getThreadHistory.js +0 -537
- package/leiamnash/getThreadHistoryDeprecated.js +0 -71
- package/leiamnash/getThreadInfoDeprecated.js +0 -56
- package/leiamnash/getThreadList.js +0 -213
- package/leiamnash/getThreadListDeprecated.js +0 -46
- package/leiamnash/getThreadPictures.js +0 -59
- package/leiamnash/getUserID.js +0 -61
- package/leiamnash/getUserInfo.js +0 -66
- package/leiamnash/handleFriendRequest.js +0 -46
- package/leiamnash/handleMessageRequest.js +0 -47
- package/leiamnash/httpGet.js +0 -47
- package/leiamnash/httpPost.js +0 -47
- package/leiamnash/logout.js +0 -68
- package/leiamnash/markAsDelivered.js +0 -47
- package/leiamnash/markAsRead.js +0 -70
- package/leiamnash/markAsReadAll.js +0 -40
- package/leiamnash/markAsSeen.js +0 -48
- package/leiamnash/muteThread.js +0 -45
- package/leiamnash/react.js +0 -109
- package/leiamnash/removeUserFromGroup.js +0 -45
- package/leiamnash/resolvePhotoUrl.js +0 -36
- package/leiamnash/searchForThread.js +0 -42
- package/leiamnash/seen.js +0 -40
- package/leiamnash/sendMessage.js +0 -315
- package/leiamnash/sendTypingIndicator.js +0 -70
- package/leiamnash/setMessageReaction.js +0 -103
- package/leiamnash/setPostReaction.js +0 -63
- package/leiamnash/setTitle.js +0 -70
- package/leiamnash/threadColors.js +0 -41
- package/leiamnash/unfriend.js +0 -42
- package/leiamnash/unsendMessage.js +0 -39
- /package/{leiamnash → src}/getMessage.js +0 -0
@@ -1,127 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
const utils = require("../utils");
|
4
|
-
const log = require("npmlog");
|
5
|
-
const bluebird = require("bluebird");
|
6
|
-
|
7
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
8
|
-
function handleUpload(image, callback) {
|
9
|
-
const uploads = [];
|
10
|
-
|
11
|
-
const form = {
|
12
|
-
profile_id: ctx.i_userID || ctx.userID,
|
13
|
-
photo_source: 57,
|
14
|
-
av: ctx.i_userID || ctx.userID,
|
15
|
-
file: image
|
16
|
-
};
|
17
|
-
|
18
|
-
uploads.push(
|
19
|
-
defaultFuncs
|
20
|
-
.postFormData(
|
21
|
-
"https://www.facebook.com/profile/picture/upload/",
|
22
|
-
ctx.jar,
|
23
|
-
form,
|
24
|
-
{}
|
25
|
-
)
|
26
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
27
|
-
.then(function (resData) {
|
28
|
-
if (resData.error) {
|
29
|
-
throw resData;
|
30
|
-
}
|
31
|
-
return resData;
|
32
|
-
})
|
33
|
-
);
|
34
|
-
|
35
|
-
// resolve all promises
|
36
|
-
bluebird
|
37
|
-
.all(uploads)
|
38
|
-
.then(function (resData) {
|
39
|
-
callback(null, resData);
|
40
|
-
})
|
41
|
-
.catch(function (err) {
|
42
|
-
log.error("handleUpload", err);
|
43
|
-
return callback(err);
|
44
|
-
});
|
45
|
-
}
|
46
|
-
|
47
|
-
return function changeAvatar(image, caption = "", timestamp = null, callback) {
|
48
|
-
let resolveFunc = function () { };
|
49
|
-
let rejectFunc = function () { };
|
50
|
-
const returnPromise = new Promise(function (resolve, reject) {
|
51
|
-
resolveFunc = resolve;
|
52
|
-
rejectFunc = reject;
|
53
|
-
});
|
54
|
-
|
55
|
-
if (!timestamp && utils.getType(caption) === "Number") {
|
56
|
-
timestamp = caption;
|
57
|
-
caption = "";
|
58
|
-
}
|
59
|
-
|
60
|
-
if (!timestamp && !callback && (utils.getType(caption) == "Function" || utils.getType(caption) == "AsyncFunction")) {
|
61
|
-
callback = caption;
|
62
|
-
caption = "";
|
63
|
-
timestamp = null;
|
64
|
-
}
|
65
|
-
|
66
|
-
if (!callback) callback = function (err, data) {
|
67
|
-
if (err) {
|
68
|
-
return rejectFunc(err);
|
69
|
-
}
|
70
|
-
resolveFunc(data);
|
71
|
-
};
|
72
|
-
|
73
|
-
if (!utils.isReadableStream(image))
|
74
|
-
return callback("Image is not a readable stream");
|
75
|
-
|
76
|
-
handleUpload(image, function (err, payload) {
|
77
|
-
if (err) {
|
78
|
-
return callback(err);
|
79
|
-
}
|
80
|
-
|
81
|
-
const form = {
|
82
|
-
av: ctx.i_userID || ctx.userID,
|
83
|
-
fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
|
84
|
-
fb_api_caller_class: "RelayModern",
|
85
|
-
doc_id: "5066134240065849",
|
86
|
-
variables: JSON.stringify({
|
87
|
-
input: {
|
88
|
-
caption,
|
89
|
-
existing_photo_id: payload[0].payload.fbid,
|
90
|
-
expiration_time: timestamp,
|
91
|
-
profile_id: ctx.i_userID || ctx.userID,
|
92
|
-
profile_pic_method: "EXISTING",
|
93
|
-
profile_pic_source: "TIMELINE",
|
94
|
-
scaled_crop_rect: {
|
95
|
-
height: 1,
|
96
|
-
width: 1,
|
97
|
-
x: 0,
|
98
|
-
y: 0
|
99
|
-
},
|
100
|
-
skip_cropping: true,
|
101
|
-
actor_id: ctx.i_userID || ctx.userID,
|
102
|
-
client_mutation_id: Math.round(Math.random() * 19).toString()
|
103
|
-
},
|
104
|
-
isPage: false,
|
105
|
-
isProfile: true,
|
106
|
-
scale: 3
|
107
|
-
})
|
108
|
-
};
|
109
|
-
|
110
|
-
defaultFuncs
|
111
|
-
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
112
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
113
|
-
.then(function (resData) {
|
114
|
-
if (resData.errors) {
|
115
|
-
throw resData;
|
116
|
-
}
|
117
|
-
return callback(null, resData[0].data.profile_picture_set);
|
118
|
-
})
|
119
|
-
.catch(function (err) {
|
120
|
-
log.error("changeAvatar", err);
|
121
|
-
return callback(err);
|
122
|
-
});
|
123
|
-
});
|
124
|
-
|
125
|
-
return returnPromise;
|
126
|
-
};
|
127
|
-
};
|
package/leiamnash/changeBio.js
DELETED
@@ -1,64 +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 changeBio(bio, publish, 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
|
-
if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") callback = publish;
|
17
|
-
else {
|
18
|
-
callback = function (err) {
|
19
|
-
if (err) return rejectFunc(err);
|
20
|
-
resolveFunc();
|
21
|
-
};
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
if (utils.getType(publish) != "Boolean") publish = false;
|
26
|
-
if (utils.getType(bio) != "String") {
|
27
|
-
bio = "";
|
28
|
-
publish = false;
|
29
|
-
}
|
30
|
-
|
31
|
-
var form = {
|
32
|
-
fb_api_caller_class: "RelayModern",
|
33
|
-
fb_api_req_friendly_name: "ProfileCometSetBioMutation",
|
34
|
-
// This doc_is is valid as of May 23, 2020
|
35
|
-
doc_id: "2725043627607610",
|
36
|
-
variables: JSON.stringify({
|
37
|
-
input: {
|
38
|
-
bio: bio,
|
39
|
-
publish_bio_feed_story: publish,
|
40
|
-
actor_id: ctx.userID,
|
41
|
-
client_mutation_id: Math.round(Math.random() * 1024).toString()
|
42
|
-
},
|
43
|
-
hasProfileTileViewID: false,
|
44
|
-
profileTileViewID: null,
|
45
|
-
scale: 1
|
46
|
-
}),
|
47
|
-
av: ctx.userID
|
48
|
-
};
|
49
|
-
|
50
|
-
defaultFuncs
|
51
|
-
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
52
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
53
|
-
.then(function (resData) {
|
54
|
-
if (resData.errors) throw resData;
|
55
|
-
return callback();
|
56
|
-
})
|
57
|
-
.catch(function (err) {
|
58
|
-
log.error("changeBio", err);
|
59
|
-
return callback(err);
|
60
|
-
});
|
61
|
-
|
62
|
-
return returnPromise;
|
63
|
-
};
|
64
|
-
};
|
@@ -1,36 +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 changeBlockedStatus(userID, block, 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) {
|
17
|
-
if (err) return rejectFunc(err);
|
18
|
-
resolveFunc();
|
19
|
-
};
|
20
|
-
}
|
21
|
-
|
22
|
-
defaultFuncs
|
23
|
-
.post(`https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`, ctx.jar, { fbid: userID })
|
24
|
-
.then(utils.saveCookies(ctx.jar))
|
25
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
26
|
-
.then(function (resData) {
|
27
|
-
if (resData.error) throw resData;
|
28
|
-
return callback();
|
29
|
-
})
|
30
|
-
.catch(function (err) {
|
31
|
-
log.error("changeBlockedStatus", err);
|
32
|
-
return callback(err);
|
33
|
-
});
|
34
|
-
return returnPromise;
|
35
|
-
};
|
36
|
-
};
|
@@ -1,105 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var utils = require("../utils");
|
4
|
-
var log = require("npmlog");
|
5
|
-
var bluebird = require("bluebird");
|
6
|
-
|
7
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
8
|
-
function handleUpload(image, callback) {
|
9
|
-
var uploads = [];
|
10
|
-
|
11
|
-
var form = {
|
12
|
-
images_only: "true",
|
13
|
-
"attachment[]": image
|
14
|
-
};
|
15
|
-
|
16
|
-
uploads.push(
|
17
|
-
defaultFuncs
|
18
|
-
.postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
|
19
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
20
|
-
.then(function (resData) {
|
21
|
-
if (resData.error) throw resData;
|
22
|
-
return resData.payload.metadata[0];
|
23
|
-
})
|
24
|
-
);
|
25
|
-
|
26
|
-
// resolve all promises
|
27
|
-
bluebird
|
28
|
-
.all(uploads)
|
29
|
-
.then(resData => callback(null, resData))
|
30
|
-
.catch(function (err) {
|
31
|
-
log.error("handleUpload", err);
|
32
|
-
return callback(err);
|
33
|
-
});
|
34
|
-
}
|
35
|
-
|
36
|
-
return function changeGroupImage(image, threadID, callback) {
|
37
|
-
if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
|
38
|
-
|
39
|
-
var resolveFunc = function () { };
|
40
|
-
var rejectFunc = function () { };
|
41
|
-
var returnPromise = new Promise(function (resolve, reject) {
|
42
|
-
resolveFunc = resolve;
|
43
|
-
rejectFunc = reject;
|
44
|
-
});
|
45
|
-
|
46
|
-
if (!callback) {
|
47
|
-
callback = function (err) {
|
48
|
-
if (err) return rejectFunc(err);
|
49
|
-
resolveFunc();
|
50
|
-
};
|
51
|
-
}
|
52
|
-
|
53
|
-
var messageAndOTID = utils.generateOfflineThreadingID();
|
54
|
-
var form = {
|
55
|
-
client: "mercury",
|
56
|
-
action_type: "ma-type:log-message",
|
57
|
-
author: "fbid:" + ctx.userID,
|
58
|
-
author_email: "",
|
59
|
-
ephemeral_ttl_mode: "0",
|
60
|
-
is_filtered_content: false,
|
61
|
-
is_filtered_content_account: false,
|
62
|
-
is_filtered_content_bh: false,
|
63
|
-
is_filtered_content_invalid_app: false,
|
64
|
-
is_filtered_content_quasar: false,
|
65
|
-
is_forward: false,
|
66
|
-
is_spoof_warning: false,
|
67
|
-
is_unread: false,
|
68
|
-
log_message_type: "log:thread-image",
|
69
|
-
manual_retry_cnt: "0",
|
70
|
-
message_id: messageAndOTID,
|
71
|
-
offline_threading_id: messageAndOTID,
|
72
|
-
source: "source:chat:web",
|
73
|
-
"source_tags[0]": "source:chat",
|
74
|
-
status: "0",
|
75
|
-
thread_fbid: threadID,
|
76
|
-
thread_id: "",
|
77
|
-
timestamp: Date.now(),
|
78
|
-
timestamp_absolute: "Today",
|
79
|
-
timestamp_relative: utils.generateTimestampRelative(),
|
80
|
-
timestamp_time_passed: "0"
|
81
|
-
};
|
82
|
-
|
83
|
-
handleUpload(image, function (err, payload) {
|
84
|
-
if (err) return callback(err);
|
85
|
-
|
86
|
-
form["thread_image_id"] = payload[0]["image_id"];
|
87
|
-
form["thread_id"] = threadID;
|
88
|
-
|
89
|
-
defaultFuncs
|
90
|
-
.post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
|
91
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
92
|
-
.then(function (resData) {
|
93
|
-
// check for errors here
|
94
|
-
if (resData.error) throw resData;
|
95
|
-
return callback();
|
96
|
-
})
|
97
|
-
.catch(function (err) {
|
98
|
-
log.error("changeGroupImage", err);
|
99
|
-
return callback(err);
|
100
|
-
});
|
101
|
-
});
|
102
|
-
|
103
|
-
return returnPromise;
|
104
|
-
};
|
105
|
-
};
|
@@ -1,43 +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 changeNickname(nickname, threadID, participantID, 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
|
-
nickname: nickname,
|
23
|
-
participant_id: participantID,
|
24
|
-
thread_or_other_fbid: threadID
|
25
|
-
};
|
26
|
-
|
27
|
-
defaultFuncs
|
28
|
-
.post("https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1", ctx.jar, form)
|
29
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
30
|
-
.then(function (resData) {
|
31
|
-
if (resData.error === 1545014) throw { error: "Trying to change nickname of user isn't in thread" };
|
32
|
-
if (resData.error === 1357031) throw { error: "Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname." };
|
33
|
-
if (resData.error) throw resData;
|
34
|
-
return callback();
|
35
|
-
})
|
36
|
-
.catch(function (err) {
|
37
|
-
log.error("changeNickname", "Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname.");
|
38
|
-
return callback(err);
|
39
|
-
});
|
40
|
-
|
41
|
-
return returnPromise;
|
42
|
-
};
|
43
|
-
};
|
@@ -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 changeThreadColor(color, 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) {
|
17
|
-
if (err) return rejectFunc(err);
|
18
|
-
resolveFunc(err);
|
19
|
-
};
|
20
|
-
}
|
21
|
-
|
22
|
-
var validatedColor = color !== null ? color.toLowerCase() : color; // API only accepts lowercase letters in hex string
|
23
|
-
var colorList = Object.keys(api.threadColors).map(function (name) {
|
24
|
-
return api.threadColors[name];
|
25
|
-
});
|
26
|
-
if (!colorList.includes(validatedColor)) throw { error: "The color you are trying to use is not a valid thread color. Use api.threadColors to find acceptable values." };
|
27
|
-
|
28
|
-
var form = {
|
29
|
-
dpr: 1,
|
30
|
-
queries: JSON.stringify({
|
31
|
-
o0: {
|
32
|
-
//This doc_id is valid as of January 31, 2020
|
33
|
-
doc_id: "1727493033983591",
|
34
|
-
query_params: {
|
35
|
-
data: {
|
36
|
-
actor_id: ctx.userID,
|
37
|
-
client_mutation_id: "0",
|
38
|
-
source: "SETTINGS",
|
39
|
-
theme_id: validatedColor,
|
40
|
-
thread_id: threadID
|
41
|
-
}
|
42
|
-
}
|
43
|
-
}
|
44
|
-
})
|
45
|
-
};
|
46
|
-
|
47
|
-
defaultFuncs
|
48
|
-
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
49
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
50
|
-
.then(function (resData) {
|
51
|
-
if (resData[resData.length - 1].error_results > 0) throw resData[0].o0.errors;
|
52
|
-
return callback();
|
53
|
-
})
|
54
|
-
.catch(function (err) {
|
55
|
-
log.error("changeThreadColor", err);
|
56
|
-
return callback(err);
|
57
|
-
});
|
58
|
-
|
59
|
-
return returnPromise;
|
60
|
-
};
|
61
|
-
};
|
@@ -1,41 +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 changeThreadEmoji(emoji, 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) {
|
17
|
-
if (err) return rejectFunc(err);
|
18
|
-
resolveFunc();
|
19
|
-
};
|
20
|
-
}
|
21
|
-
var form = {
|
22
|
-
emoji_choice: emoji,
|
23
|
-
thread_or_other_fbid: threadID
|
24
|
-
};
|
25
|
-
|
26
|
-
defaultFuncs
|
27
|
-
.post("https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg", ctx.jar, form)
|
28
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
29
|
-
.then(function (resData) {
|
30
|
-
if (resData.error === 1357031) throw { error: "Trying to change emoji of a chat that doesn't exist. Have at least one message in the thread before trying to change the emoji." };
|
31
|
-
if (resData.error) throw resData;
|
32
|
-
return callback();
|
33
|
-
})
|
34
|
-
.catch(function (err) {
|
35
|
-
log.error("changeThreadEmoji", err);
|
36
|
-
return callback(err);
|
37
|
-
});
|
38
|
-
|
39
|
-
return returnPromise;
|
40
|
-
};
|
41
|
-
};
|
@@ -1,70 +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 createNewGroup(participantIDs, groupTitle, callback) {
|
8
|
-
if (utils.getType(groupTitle) == "Function") {
|
9
|
-
callback = groupTitle;
|
10
|
-
groupTitle = null;
|
11
|
-
}
|
12
|
-
|
13
|
-
if (utils.getType(participantIDs) !== "Array") throw { error: "createNewGroup: participantIDs should be an array." };
|
14
|
-
|
15
|
-
if (participantIDs.length < 2) throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
|
16
|
-
|
17
|
-
var resolveFunc = function () { };
|
18
|
-
var rejectFunc = function () { };
|
19
|
-
var returnPromise = new Promise(function (resolve, reject) {
|
20
|
-
resolveFunc = resolve;
|
21
|
-
rejectFunc = reject;
|
22
|
-
});
|
23
|
-
|
24
|
-
if (!callback) {
|
25
|
-
callback = function (err, threadID) {
|
26
|
-
if (err) return rejectFunc(err);
|
27
|
-
resolveFunc(threadID);
|
28
|
-
};
|
29
|
-
}
|
30
|
-
|
31
|
-
var pids = [];
|
32
|
-
for (var n in participantIDs) pids.push({ fbid: participantIDs[n] });
|
33
|
-
pids.push({ fbid: ctx.userID });
|
34
|
-
|
35
|
-
var form = {
|
36
|
-
fb_api_caller_class: "RelayModern",
|
37
|
-
fb_api_req_friendly_name: "MessengerGroupCreateMutation",
|
38
|
-
av: ctx.userID,
|
39
|
-
//This doc_id is valid as of January 11th, 2020
|
40
|
-
doc_id: "577041672419534",
|
41
|
-
variables: JSON.stringify({
|
42
|
-
input: {
|
43
|
-
entry_point: "jewel_new_group",
|
44
|
-
actor_id: ctx.userID,
|
45
|
-
participants: pids,
|
46
|
-
client_mutation_id: Math.round(Math.random() * 1024).toString(),
|
47
|
-
thread_settings: {
|
48
|
-
name: groupTitle,
|
49
|
-
joinable_mode: "PRIVATE",
|
50
|
-
thread_image_fbid: null
|
51
|
-
}
|
52
|
-
}
|
53
|
-
})
|
54
|
-
};
|
55
|
-
|
56
|
-
defaultFuncs
|
57
|
-
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
58
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
59
|
-
.then(function (resData) {
|
60
|
-
if (resData.errors) throw resData;
|
61
|
-
return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
|
62
|
-
})
|
63
|
-
.catch(function (err) {
|
64
|
-
log.error("createNewGroup", err);
|
65
|
-
return callback(err);
|
66
|
-
});
|
67
|
-
|
68
|
-
return returnPromise;
|
69
|
-
};
|
70
|
-
};
|
package/leiamnash/createPoll.js
DELETED
@@ -1,59 +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 createPoll(title, threadID, options, 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
|
-
if (utils.getType(options) == "Function") {
|
17
|
-
callback = options;
|
18
|
-
options = null;
|
19
|
-
}
|
20
|
-
else {
|
21
|
-
callback = function (err) {
|
22
|
-
if (err) return rejectFunc(err);
|
23
|
-
resolveFunc();
|
24
|
-
};
|
25
|
-
}
|
26
|
-
}
|
27
|
-
if (!options) options = {}; // Initial poll options are optional
|
28
|
-
|
29
|
-
var form = {
|
30
|
-
target_id: threadID,
|
31
|
-
question_text: title
|
32
|
-
};
|
33
|
-
|
34
|
-
// Set fields for options (and whether they are selected initially by the posting user)
|
35
|
-
var ind = 0;
|
36
|
-
for (var opt in options) {
|
37
|
-
// eslint-disable-next-line no-prototype-builtins
|
38
|
-
if (options.hasOwnProperty(opt)) {
|
39
|
-
form["option_text_array[" + ind + "]"] = opt;
|
40
|
-
form["option_is_selected_array[" + ind + "]"] = options[opt] ? "1" : "0";
|
41
|
-
ind++;
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
defaultFuncs
|
46
|
-
.post("https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1", ctx.jar, form)
|
47
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
48
|
-
.then(function (resData) {
|
49
|
-
if (resData.payload.status != "success") throw resData;
|
50
|
-
return callback();
|
51
|
-
})
|
52
|
-
.catch(function (err) {
|
53
|
-
log.error("createPoll", err);
|
54
|
-
return callback(err);
|
55
|
-
});
|
56
|
-
|
57
|
-
return returnPromise;
|
58
|
-
};
|
59
|
-
};
|
@@ -1,44 +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 deleteMessage(messageOrMessages, 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
|
-
|
18
|
-
resolveFunc();
|
19
|
-
};
|
20
|
-
}
|
21
|
-
|
22
|
-
var form = {
|
23
|
-
client: "mercury"
|
24
|
-
};
|
25
|
-
|
26
|
-
if (utils.getType(messageOrMessages) !== "Array") messageOrMessages = [messageOrMessages];
|
27
|
-
|
28
|
-
for (var i = 0; i < messageOrMessages.length; i++) form["message_ids[" + i + "]"] = messageOrMessages[i];
|
29
|
-
|
30
|
-
defaultFuncs
|
31
|
-
.post("https://www.facebook.com/ajax/mercury/delete_messages.php", ctx.jar, form)
|
32
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
33
|
-
.then(function (resData) {
|
34
|
-
if (resData.error) throw resData;
|
35
|
-
return callback();
|
36
|
-
})
|
37
|
-
.catch(function (err) {
|
38
|
-
log.error("deleteMessage", err);
|
39
|
-
return callback(err);
|
40
|
-
});
|
41
|
-
|
42
|
-
return returnPromise;
|
43
|
-
};
|
44
|
-
};
|
@@ -1,42 +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 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
|
-
};
|