fca-sahu 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +552 -0
- package/package.json +61 -0
- package/src/OldMessage.js +357 -0
- package/src/addExternalModule.js +25 -0
- package/src/addUserToGroup.js +115 -0
- package/src/changeAdminStatus.js +103 -0
- package/src/changeArchivedStatus.js +55 -0
- package/src/changeAvatar.js +136 -0
- package/src/changeAvatarV2.js +86 -0
- package/src/changeAvt.js +85 -0
- package/src/changeBio.js +76 -0
- package/src/changeBlockedStatus.js +49 -0
- package/src/changeBlockedStatusMqtt.js +80 -0
- package/src/changeCover.js +72 -0
- package/src/changeGroupImage.js +135 -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/src/changeUsername.js +59 -0
- package/src/createCommentPost.js +230 -0
- package/src/createNewGroup.js +88 -0
- package/src/createPoll.js +71 -0
- package/src/createPost.js +276 -0
- package/src/deleteMessage.js +56 -0
- package/src/deleteThread.js +56 -0
- package/src/editMessage.js +68 -0
- package/src/editMessageOld.js +67 -0
- package/src/follow.js +74 -0
- package/src/forwardAttachment.js +60 -0
- package/src/friendList.js +103 -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/getMessage.js +847 -0
- package/src/getRegion.js +7 -0
- package/src/getThreadHistory.js +680 -0
- package/src/getThreadHistoryDeprecated.js +71 -0
- package/src/getThreadInfo.js +232 -0
- package/src/getThreadInfoDeprecated.js +56 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadListDeprecated.js +46 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getThreadTheme.js +82 -0
- package/src/getUID.js +119 -0
- package/src/getUserID.js +61 -0
- package/src/getUserInfo.js +66 -0
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +47 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/listenMqtt.js +719 -0
- package/src/logout.js +75 -0
- package/src/markAsDelivered.js +47 -0
- package/src/markAsRead.js +70 -0
- package/src/markAsReadAll.js +40 -0
- package/src/markAsSeen.js +48 -0
- package/src/metaTheme.js +190 -0
- package/src/muteThread.js +45 -0
- package/src/note.js +228 -0
- package/src/refreshFb_dtsg.js +89 -0
- package/src/removeSuspiciousAccount.js +79 -0
- package/src/removeUserFromGroup.js +79 -0
- package/src/resolvePhotoUrl.js +45 -0
- package/src/searchForThread.js +53 -0
- package/src/searchFriends.js +139 -0
- package/src/searchStickers.js +53 -0
- package/src/sendFriendRequest.js +113 -0
- package/src/sendMessage.js +258 -0
- package/src/sendMessageMqtt.js +322 -0
- package/src/sendTypingIndicator.js +45 -0
- package/src/setActiveStatus.js +93 -0
- package/src/setMessageReaction.js +122 -0
- package/src/setMessageReactionMqtt.js +62 -0
- package/src/setPostReaction.js +112 -0
- package/src/setProfileLock.js +98 -0
- package/src/setStoryReaction.js +134 -0
- package/src/setStorySeen.js +109 -0
- package/src/setThreadTheme.js +103 -0
- package/src/setTitle.js +90 -0
- package/src/shareContact.js +110 -0
- package/src/shareLink.js +59 -0
- package/src/stopListenMqtt.js +23 -0
- package/src/storyManager.js +358 -0
- package/src/suggestFriend.js +133 -0
- package/src/threadColors.js +131 -0
- package/src/unfriend.js +52 -0
- package/src/unsendMessage.js +45 -0
- package/src/uploadAttachment.js +93 -0
- package/utils.js +2962 -0
package/src/note.js
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const utils = require('../utils');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description Enhanced module for interacting with Facebook Messenger Notes with additional features
|
|
8
|
+
* @param {Object} defaultFuncs The default functions provided by the API wrapper
|
|
9
|
+
* @param {Object} api The full API object
|
|
10
|
+
* @param {Object} ctx The context object containing the user's session state
|
|
11
|
+
* @returns {Object} An object containing enhanced methods for note management
|
|
12
|
+
*/
|
|
13
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @callback notesCallback
|
|
17
|
+
* @param {Error|null} error An error object if the request fails, otherwise null
|
|
18
|
+
* @param {Object} [data] The data returned from the API
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Enhanced check note function with additional user info
|
|
23
|
+
*/
|
|
24
|
+
function checkNoteAdvanced(callback) {
|
|
25
|
+
if (typeof callback !== 'function') {
|
|
26
|
+
callback = () => {};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const form = {
|
|
30
|
+
fb_api_caller_class: "RelayModern",
|
|
31
|
+
fb_api_req_friendly_name: "MWInboxTrayNoteCreationDialogQuery",
|
|
32
|
+
variables: JSON.stringify({ scale: 2 }),
|
|
33
|
+
doc_id: "30899655739648624",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
defaultFuncs
|
|
37
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
38
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
39
|
+
.then(resData => {
|
|
40
|
+
if (resData && resData.errors) throw resData.errors[0];
|
|
41
|
+
const currentNote = resData?.data?.viewer?.actor?.msgr_user_rich_status;
|
|
42
|
+
|
|
43
|
+
// Enhanced response with additional metadata
|
|
44
|
+
const enhancedResponse = {
|
|
45
|
+
note: currentNote,
|
|
46
|
+
hasActiveNote: !!currentNote,
|
|
47
|
+
userId: ctx.userID,
|
|
48
|
+
timestamp: Date.now(),
|
|
49
|
+
expiresAt: currentNote ? (currentNote.created_time * 1000) + (24 * 60 * 60 * 1000) : null
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
callback(null, enhancedResponse);
|
|
53
|
+
})
|
|
54
|
+
.catch(err => {
|
|
55
|
+
utils.error && utils.error("notesv2.checkNoteAdvanced", err);
|
|
56
|
+
callback(err);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Create note with enhanced privacy options and validation
|
|
62
|
+
*/
|
|
63
|
+
function createNoteAdvanced(text, options = {}, callback) {
|
|
64
|
+
if (typeof options === 'function') {
|
|
65
|
+
callback = options;
|
|
66
|
+
options = {};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (typeof callback !== 'function') {
|
|
70
|
+
callback = () => {};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Validate input
|
|
74
|
+
if (!text || text.trim().length === 0) {
|
|
75
|
+
return callback(new Error("Note text cannot be empty"));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (text.length > 280) {
|
|
79
|
+
return callback(new Error("Note text cannot exceed 280 characters"));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const {
|
|
83
|
+
privacy = "FRIENDS",
|
|
84
|
+
duration = 86400,
|
|
85
|
+
noteType = "TEXT_NOTE"
|
|
86
|
+
} = options;
|
|
87
|
+
|
|
88
|
+
const variables = {
|
|
89
|
+
input: {
|
|
90
|
+
client_mutation_id: Math.round(Math.random() * 1000000).toString(),
|
|
91
|
+
actor_id: ctx.userID,
|
|
92
|
+
description: text.trim(),
|
|
93
|
+
duration: duration,
|
|
94
|
+
note_type: noteType,
|
|
95
|
+
privacy: privacy,
|
|
96
|
+
session_id: utils.getGUID(),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const form = {
|
|
101
|
+
fb_api_caller_class: "RelayModern",
|
|
102
|
+
fb_api_req_friendly_name: "MWInboxTrayNoteCreationDialogCreationStepContentMutation",
|
|
103
|
+
variables: JSON.stringify(variables),
|
|
104
|
+
doc_id: "24060573783603122",
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
defaultFuncs
|
|
108
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
109
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
110
|
+
.then(resData => {
|
|
111
|
+
if (resData && resData.errors) throw resData.errors[0];
|
|
112
|
+
const status = resData?.data?.xfb_rich_status_create?.status;
|
|
113
|
+
if (!status) throw new Error("Could not find note status in the server response.");
|
|
114
|
+
|
|
115
|
+
// Enhanced response
|
|
116
|
+
const enhancedResponse = {
|
|
117
|
+
...status,
|
|
118
|
+
createdAt: Date.now(),
|
|
119
|
+
expiresAt: Date.now() + (duration * 1000),
|
|
120
|
+
characterCount: text.trim().length,
|
|
121
|
+
privacy: privacy
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
callback(null, enhancedResponse);
|
|
125
|
+
})
|
|
126
|
+
.catch(err => {
|
|
127
|
+
utils.error && utils.error("notesv2.createNoteAdvanced", err);
|
|
128
|
+
callback(err);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Delete note with confirmation
|
|
134
|
+
*/
|
|
135
|
+
function deleteNoteAdvanced(noteID, callback) {
|
|
136
|
+
if (typeof callback !== 'function') {
|
|
137
|
+
callback = () => {};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (!noteID) {
|
|
141
|
+
return callback(new Error("Note ID is required"));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const variables = {
|
|
145
|
+
input: {
|
|
146
|
+
client_mutation_id: Math.round(Math.random() * 1000000).toString(),
|
|
147
|
+
actor_id: ctx.userID,
|
|
148
|
+
rich_status_id: noteID,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const form = {
|
|
153
|
+
fb_api_caller_class: "RelayModern",
|
|
154
|
+
fb_api_req_friendly_name: "useMWInboxTrayDeleteNoteMutation",
|
|
155
|
+
variables: JSON.stringify(variables),
|
|
156
|
+
doc_id: "9532619970198958",
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
defaultFuncs
|
|
160
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
161
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
162
|
+
.then(resData => {
|
|
163
|
+
if (resData && resData.errors) throw resData.errors[0];
|
|
164
|
+
const deletedStatus = resData?.data?.xfb_rich_status_delete;
|
|
165
|
+
if (!deletedStatus) throw new Error("Could not find deletion status in the server response.");
|
|
166
|
+
|
|
167
|
+
const enhancedResponse = {
|
|
168
|
+
...deletedStatus,
|
|
169
|
+
deletedAt: Date.now(),
|
|
170
|
+
noteId: noteID
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
callback(null, enhancedResponse);
|
|
174
|
+
})
|
|
175
|
+
.catch(err => {
|
|
176
|
+
utils.error && utils.error("notesv2.deleteNoteAdvanced", err);
|
|
177
|
+
callback(err);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Update existing note (delete old and create new)
|
|
183
|
+
*/
|
|
184
|
+
function updateNote(oldNoteID, newText, options = {}, callback) {
|
|
185
|
+
if (typeof options === 'function') {
|
|
186
|
+
callback = options;
|
|
187
|
+
options = {};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (typeof callback !== 'function') {
|
|
191
|
+
callback = () => {};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
deleteNoteAdvanced(oldNoteID, (err, deleted) => {
|
|
195
|
+
if (err) {
|
|
196
|
+
return callback(err);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Wait a bit before creating new note
|
|
200
|
+
setTimeout(() => {
|
|
201
|
+
createNoteAdvanced(newText, options, (err, created) => {
|
|
202
|
+
if (err) {
|
|
203
|
+
return callback(err);
|
|
204
|
+
}
|
|
205
|
+
callback(null, {
|
|
206
|
+
deleted,
|
|
207
|
+
created,
|
|
208
|
+
updatedAt: Date.now()
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
}, 1000);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
// Enhanced functions
|
|
217
|
+
checkAdvanced: checkNoteAdvanced,
|
|
218
|
+
createAdvanced: createNoteAdvanced,
|
|
219
|
+
deleteAdvanced: deleteNoteAdvanced,
|
|
220
|
+
update: updateNote,
|
|
221
|
+
|
|
222
|
+
// Backward compatibility
|
|
223
|
+
check: checkNoteAdvanced,
|
|
224
|
+
create: createNoteAdvanced,
|
|
225
|
+
delete: deleteNoteAdvanced,
|
|
226
|
+
recreate: updateNote
|
|
227
|
+
};
|
|
228
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require("../utils");
|
|
4
|
+
// @NethWs3Dev
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
/**
|
|
8
|
+
* Refreshes the fb_dtsg and jazoest values.
|
|
9
|
+
* @param {Function} callback
|
|
10
|
+
* @returns {Promise}
|
|
11
|
+
* @description if you don't update the value of fb_dtsg and jazoest for a long time an error "Please try closing and re-opening your browser window" will appear
|
|
12
|
+
* @description you should refresh it every 48h or less
|
|
13
|
+
*/
|
|
14
|
+
return function refreshFb_dtsg(obj, callback) {
|
|
15
|
+
let resolveFunc = function () {};
|
|
16
|
+
let rejectFunc = function () {};
|
|
17
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
18
|
+
resolveFunc = resolve;
|
|
19
|
+
rejectFunc = reject;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
if (
|
|
23
|
+
utils.getType(obj) === "Function" ||
|
|
24
|
+
utils.getType(obj) === "AsyncFunction"
|
|
25
|
+
) {
|
|
26
|
+
callback = obj;
|
|
27
|
+
obj = {};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!obj) {
|
|
31
|
+
obj = {};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (utils.getType(obj) !== "Object") {
|
|
35
|
+
throw new utils.CustomError(
|
|
36
|
+
"the first parameter must be an object or a callback function",
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!callback) {
|
|
41
|
+
callback = function (err, friendList) {
|
|
42
|
+
if (err) {
|
|
43
|
+
return rejectFunc(err);
|
|
44
|
+
}
|
|
45
|
+
resolveFunc(friendList);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (Object.keys(obj).length == 0) {
|
|
50
|
+
utils
|
|
51
|
+
.get("https://m.facebook.com/", ctx.jar, null, ctx.globalOptions, {
|
|
52
|
+
noRef: true,
|
|
53
|
+
})
|
|
54
|
+
.then(function (resData) {
|
|
55
|
+
const html = resData.body;
|
|
56
|
+
const fb_dtsg = utils.getFrom(html, 'name="fb_dtsg" value="', '"');
|
|
57
|
+
const jazoest = utils.getFrom(html, 'name="jazoest" value="', '"');
|
|
58
|
+
if (!fb_dtsg) {
|
|
59
|
+
throw new utils.CustomError(
|
|
60
|
+
"Could not find fb_dtsg in HTML after requesting https://www.facebook.com/",
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
ctx.fb_dtsg = fb_dtsg;
|
|
64
|
+
ctx.jazoest = jazoest;
|
|
65
|
+
callback(null, {
|
|
66
|
+
data: {
|
|
67
|
+
fb_dtsg: fb_dtsg,
|
|
68
|
+
jazoest: jazoest,
|
|
69
|
+
},
|
|
70
|
+
message: "refreshed fb_dtsg and jazoest",
|
|
71
|
+
});
|
|
72
|
+
})
|
|
73
|
+
.catch(function (err) {
|
|
74
|
+
console.error("refreshFb_dtsg", err);
|
|
75
|
+
return callback(err);
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
Object.keys(obj).forEach(function (key) {
|
|
79
|
+
ctx[key] = obj[key];
|
|
80
|
+
});
|
|
81
|
+
callback(null, {
|
|
82
|
+
data: obj,
|
|
83
|
+
message: "refreshed " + Object.keys(obj).join(", "),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return returnPromise;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ===========================================================
|
|
3
|
+
* 🧑💻 Author: Sheikh Tamim (ST | Sheikh Tamim)
|
|
4
|
+
* 🔰 Owner & Developer
|
|
5
|
+
* 🌐 GitHub: https://github.com/sheikhtamimlover
|
|
6
|
+
* 📸 Instagram: https://instagram.com/sheikh.tamim_lover
|
|
7
|
+
* -----------------------------------------------------------
|
|
8
|
+
* 🕊️ Respect the creator & give proper credits if reused.
|
|
9
|
+
* ===========================================================
|
|
10
|
+
*/
|
|
11
|
+
"use strict";
|
|
12
|
+
|
|
13
|
+
const utils = require("../utils");
|
|
14
|
+
const log = require("npmlog");
|
|
15
|
+
|
|
16
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
17
|
+
/** Developed by Sheikh Tamim | GitHub: sheikhtamimlover | Instagram: @sheikh.tamim_lover */
|
|
18
|
+
return function removeSuspiciousAccount(callback) {
|
|
19
|
+
let resolveFunc = function () {};
|
|
20
|
+
let rejectFunc = function () {};
|
|
21
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
22
|
+
resolveFunc = resolve;
|
|
23
|
+
rejectFunc = reject;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (!callback) {
|
|
27
|
+
callback = function (err, data) {
|
|
28
|
+
if (err) return rejectFunc(err);
|
|
29
|
+
resolveFunc(data);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const form = {
|
|
34
|
+
av: ctx.userID,
|
|
35
|
+
__user: ctx.userID,
|
|
36
|
+
__a: "1",
|
|
37
|
+
__req: utils.getGUID(),
|
|
38
|
+
__hs: utils.getEventTime(),
|
|
39
|
+
dpr: "1",
|
|
40
|
+
__ccg: "EXCELLENT",
|
|
41
|
+
__rev: "1029700657",
|
|
42
|
+
__s: utils.getSessionID(),
|
|
43
|
+
__hsi: utils.getEventTime(),
|
|
44
|
+
__dyn: ctx.__dyn || "",
|
|
45
|
+
__csr: ctx.__csr || "",
|
|
46
|
+
__comet_req: "15",
|
|
47
|
+
fb_dtsg: ctx.fb_dtsg || "",
|
|
48
|
+
jazoest: utils.getJazoest(ctx.fb_dtsg),
|
|
49
|
+
lsd: utils.getFormData(ctx.jar, "https://www.facebook.com")?.lsd || "J4SCzL5WXd7KIzVF0tdxFm",
|
|
50
|
+
__spin_r: "1029700657",
|
|
51
|
+
__spin_b: "trunk",
|
|
52
|
+
__spin_t: utils.getEventTime(),
|
|
53
|
+
fb_api_caller_class: "RelayModern",
|
|
54
|
+
fb_api_req_friendly_name: "FBScrapingWarningMutation",
|
|
55
|
+
server_timestamps: "true",
|
|
56
|
+
variables: "{}",
|
|
57
|
+
doc_id: "24406519995698862"
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
defaultFuncs
|
|
61
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
62
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
63
|
+
.then(function (resData) {
|
|
64
|
+
if (resData.error) {
|
|
65
|
+
throw resData;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
log.info("removeSuspiciousAccount", "Successfully removed suspicious account warning");
|
|
69
|
+
callback(null, { success: true, message: "Suspicious account warning removed" });
|
|
70
|
+
})
|
|
71
|
+
.catch(function (err) {
|
|
72
|
+
log.error("removeSuspiciousAccount", err);
|
|
73
|
+
return callback(err);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return returnPromise;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/** Developed by Sheikh Tamim | GitHub: sheikhtamimlover | Please give credits if reused. */
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require("../utils");
|
|
4
|
+
// @NethWs3Dev
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return function removeUserFromGroup(userID, threadID, callback) {
|
|
8
|
+
if (
|
|
9
|
+
!callback &&
|
|
10
|
+
(utils.getType(threadID) === "Function" ||
|
|
11
|
+
utils.getType(threadID) === "AsyncFunction")
|
|
12
|
+
) {
|
|
13
|
+
throw { error: "please pass a threadID as a second argument." };
|
|
14
|
+
}
|
|
15
|
+
if (
|
|
16
|
+
utils.getType(threadID) !== "Number" &&
|
|
17
|
+
utils.getType(threadID) !== "String"
|
|
18
|
+
) {
|
|
19
|
+
throw {
|
|
20
|
+
error:
|
|
21
|
+
"threadID should be of type Number or String and not " +
|
|
22
|
+
utils.getType(threadID) +
|
|
23
|
+
".",
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (
|
|
27
|
+
utils.getType(userID) !== "Number" &&
|
|
28
|
+
utils.getType(userID) !== "String"
|
|
29
|
+
) {
|
|
30
|
+
throw {
|
|
31
|
+
error:
|
|
32
|
+
"userID should be of type Number or String and not " +
|
|
33
|
+
utils.getType(userID) +
|
|
34
|
+
".",
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let resolveFunc = function () {};
|
|
39
|
+
let rejectFunc = function () {};
|
|
40
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
41
|
+
resolveFunc = resolve;
|
|
42
|
+
rejectFunc = reject;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if (!callback) {
|
|
46
|
+
callback = function (err, friendList) {
|
|
47
|
+
if (err) {
|
|
48
|
+
return rejectFunc(err);
|
|
49
|
+
}
|
|
50
|
+
resolveFunc(friendList);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const form = {
|
|
55
|
+
uid: userID,
|
|
56
|
+
tid: threadID,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
defaultFuncs
|
|
60
|
+
.post("https://www.facebook.com/chat/remove_participants", ctx.jar, form)
|
|
61
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
62
|
+
.then(function (resData) {
|
|
63
|
+
if (!resData) {
|
|
64
|
+
throw { error: "Remove from group failed." };
|
|
65
|
+
}
|
|
66
|
+
if (resData.error) {
|
|
67
|
+
throw resData;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return callback();
|
|
71
|
+
})
|
|
72
|
+
.catch(function (err) {
|
|
73
|
+
console.error("removeUserFromGroup", err);
|
|
74
|
+
return callback(err);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
return returnPromise;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require("../utils");
|
|
4
|
+
// @NethWs3Dev
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return function resolvePhotoUrl(photoID, callback) {
|
|
8
|
+
let resolveFunc = function () {};
|
|
9
|
+
let rejectFunc = function () {};
|
|
10
|
+
const 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
|
+
defaultFuncs
|
|
25
|
+
.get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, {
|
|
26
|
+
photo_id: photoID,
|
|
27
|
+
})
|
|
28
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
29
|
+
.then((resData) => {
|
|
30
|
+
if (resData.error) {
|
|
31
|
+
throw resData;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const photoUrl = resData.jsmods.require[0][3][0];
|
|
35
|
+
|
|
36
|
+
return callback(null, photoUrl);
|
|
37
|
+
})
|
|
38
|
+
.catch((err) => {
|
|
39
|
+
console.error("resolvePhotoUrl", err);
|
|
40
|
+
return callback(err);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return returnPromise;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require("../utils");
|
|
4
|
+
|
|
5
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
6
|
+
return function searchForThread(name, callback) {
|
|
7
|
+
let resolveFunc = function () {};
|
|
8
|
+
let rejectFunc = function () {};
|
|
9
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
10
|
+
resolveFunc = resolve;
|
|
11
|
+
rejectFunc = reject;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
if (!callback) {
|
|
15
|
+
callback = function (err, friendList) {
|
|
16
|
+
if (err) {
|
|
17
|
+
return rejectFunc(err);
|
|
18
|
+
}
|
|
19
|
+
resolveFunc(friendList);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const tmpForm = {
|
|
24
|
+
client: "web_messenger",
|
|
25
|
+
query: name,
|
|
26
|
+
offset: 0,
|
|
27
|
+
limit: 21,
|
|
28
|
+
index: "fbid",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
defaultFuncs
|
|
32
|
+
.post(
|
|
33
|
+
"https://www.facebook.com/ajax/mercury/search_threads.php",
|
|
34
|
+
ctx.jar,
|
|
35
|
+
tmpForm,
|
|
36
|
+
)
|
|
37
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
38
|
+
.then(function (resData) {
|
|
39
|
+
if (resData.error) {
|
|
40
|
+
throw resData;
|
|
41
|
+
}
|
|
42
|
+
if (!resData.payload.mercury_payload.threads) {
|
|
43
|
+
return callback({ error: "Could not find thread `" + name + "`." });
|
|
44
|
+
}
|
|
45
|
+
return callback(
|
|
46
|
+
null,
|
|
47
|
+
resData.payload.mercury_payload.threads.map(utils.formatThread),
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return returnPromise;
|
|
52
|
+
};
|
|
53
|
+
};
|