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,11 +5,13 @@ const log = require("npmlog");
|
|
5
5
|
|
6
6
|
function createProfileUrl(url, username, id) {
|
7
7
|
if (url) return url;
|
8
|
-
return
|
8
|
+
return (
|
9
|
+
"https://www.facebook.com/" + (username || utils.formatID(id.toString()))
|
10
|
+
);
|
9
11
|
}
|
10
12
|
|
11
13
|
function formatParticipants(participants) {
|
12
|
-
return participants.edges.map(
|
14
|
+
return participants.edges.map(p => {
|
13
15
|
p = p.node.messaging_actor;
|
14
16
|
switch (p["__typename"]) {
|
15
17
|
case "User":
|
@@ -21,7 +23,7 @@ function formatParticipants(participants) {
|
|
21
23
|
gender: p.gender,
|
22
24
|
url: p.url, // how about making it profileURL
|
23
25
|
profilePicture: p.big_image_src.uri,
|
24
|
-
username:
|
26
|
+
username: p.username || null,
|
25
27
|
// TODO: maybe better names for these?
|
26
28
|
isViewerFriend: p.is_viewer_friend, // true/false
|
27
29
|
isMessengerUser: p.is_messenger_user, // true/false
|
@@ -37,40 +39,35 @@ function formatParticipants(participants) {
|
|
37
39
|
name: p.name,
|
38
40
|
url: p.url,
|
39
41
|
profilePicture: p.big_image_src.uri,
|
40
|
-
username:
|
42
|
+
username: p.username || null,
|
41
43
|
// uhm... better names maybe?
|
42
44
|
acceptsMessengerUserFeedback: p.accepts_messenger_user_feedback, // true/false
|
43
45
|
isMessengerUser: p.is_messenger_user, // true/false
|
44
46
|
isVerified: p.is_verified, // true/false
|
45
47
|
isMessengerPlatformBot: p.is_messenger_platform_bot, // true/false
|
46
|
-
isMessageBlockedByViewer: p.is_message_blocked_by_viewer
|
48
|
+
isMessageBlockedByViewer: p.is_message_blocked_by_viewer // true/false
|
47
49
|
};
|
48
50
|
case "ReducedMessagingActor":
|
51
|
+
case "UnavailableMessagingActor":
|
49
52
|
return {
|
50
53
|
accountType: p["__typename"],
|
51
54
|
userID: utils.formatID(p.id.toString()),
|
52
55
|
name: p.name,
|
53
56
|
url: createProfileUrl(p.url, p.username, p.id), // in this case p.url is null all the time
|
54
57
|
profilePicture: p.big_image_src.uri, // in this case it is default facebook photo, we could determine gender using it
|
55
|
-
username:
|
56
|
-
isMessageBlockedByViewer: p.is_message_blocked_by_viewer
|
57
|
-
};
|
58
|
-
case "UnavailableMessagingActor":
|
59
|
-
return {
|
60
|
-
accountType: p["__typename"],
|
61
|
-
userID: utils.formatID(p.id.toString()),
|
62
|
-
name: p.name, // "Facebook User" in user's language
|
63
|
-
url: createProfileUrl(p.url, p.username, p.id), // in this case p.url is null all the time
|
64
|
-
profilePicture: p.big_image_src.uri, // default male facebook photo
|
65
|
-
username: (p.username||null), // maybe we could use it to generate profile URL?
|
66
|
-
isMessageBlockedByViewer: p.is_message_blocked_by_viewer, // true/false
|
58
|
+
username: p.username || null, // maybe we could use it to generate profile URL?
|
59
|
+
isMessageBlockedByViewer: p.is_message_blocked_by_viewer // true/false
|
67
60
|
};
|
68
61
|
default:
|
69
|
-
log.warn(
|
62
|
+
log.warn(
|
63
|
+
"getThreadList",
|
64
|
+
"Found participant with unsupported typename. Please open an issue at https://github.com/Schmavery/facebook-chat-api/issues\n" +
|
65
|
+
JSON.stringify(p, null, 2)
|
66
|
+
);
|
70
67
|
return {
|
71
68
|
accountType: p["__typename"],
|
72
69
|
userID: utils.formatID(p.id.toString()),
|
73
|
-
name: p.name || `[unknown ${p["__typename"]}]
|
70
|
+
name: p.name || `[unknown ${p["__typename"]}]` // probably it will always be something... but fallback to [unknown], just in case
|
74
71
|
};
|
75
72
|
}
|
76
73
|
});
|
@@ -78,9 +75,7 @@ function formatParticipants(participants) {
|
|
78
75
|
|
79
76
|
// "FF8C0077" -> "8C0077"
|
80
77
|
function formatColor(color) {
|
81
|
-
if (color && color.match(/^(?:[0-9a-fA-F]{8})$/g))
|
82
|
-
return color.slice(2);
|
83
|
-
}
|
78
|
+
if (color && color.match(/^(?:[0-9a-fA-F]{8})$/g)) return color.slice(2);
|
84
79
|
return color;
|
85
80
|
}
|
86
81
|
|
@@ -89,30 +84,40 @@ function getThreadName(t) {
|
|
89
84
|
|
90
85
|
for (let po of t.all_participants.edges) {
|
91
86
|
let p = po.node;
|
92
|
-
if (p.messaging_actor.id === t.thread_key.other_user_id)
|
87
|
+
if (p.messaging_actor.id === t.thread_key.other_user_id)
|
88
|
+
return p.messaging_actor.name;
|
93
89
|
}
|
94
90
|
}
|
95
91
|
|
96
92
|
function mapNicknames(customizationInfo) {
|
97
|
-
return
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
93
|
+
return customizationInfo && customizationInfo.participant_customizations
|
94
|
+
? customizationInfo.participant_customizations.map(u => {
|
95
|
+
return {
|
96
|
+
userID: u.participant_id,
|
97
|
+
nickname: u.nickname
|
98
|
+
};
|
99
|
+
})
|
100
|
+
: [];
|
103
101
|
}
|
104
102
|
|
105
103
|
function formatThreadList(data) {
|
106
104
|
return data.map(t => {
|
107
|
-
let lastMessageNode =
|
105
|
+
let lastMessageNode =
|
106
|
+
t.last_message && t.last_message.nodes && t.last_message.nodes.length > 0
|
107
|
+
? t.last_message.nodes[0]
|
108
|
+
: null;
|
108
109
|
return {
|
109
|
-
threadID: t.thread_key
|
110
|
+
threadID: t.thread_key
|
111
|
+
? utils.formatID(t.thread_key.thread_fbid || t.thread_key.other_user_id)
|
112
|
+
: null, // shall never be null
|
110
113
|
name: getThreadName(t),
|
111
114
|
unreadCount: t.unread_count,
|
112
115
|
messageCount: t.messages_count,
|
113
|
-
imageSrc: t.image?t.image.uri:null,
|
114
|
-
emoji: t.customization_info?t.customization_info.emoji:null,
|
115
|
-
color: formatColor(
|
116
|
+
imageSrc: t.image ? t.image.uri : null,
|
117
|
+
emoji: t.customization_info ? t.customization_info.emoji : null,
|
118
|
+
color: formatColor(
|
119
|
+
t.customization_info ? t.customization_info.outgoing_bubble_color : null
|
120
|
+
),
|
116
121
|
nicknames: mapNicknames(t.customization_info),
|
117
122
|
muteUntil: t.mute_until,
|
118
123
|
participants: formatParticipants(t.all_participants),
|
@@ -123,7 +128,9 @@ function formatThreadList(data) {
|
|
123
128
|
// isPinProtected: t.is_pin_protected, // feature from future? always false (2018-04-04)
|
124
129
|
customizationEnabled: t.customization_enabled, // false for ONE_TO_ONE with Page or ReducedMessagingActor
|
125
130
|
participantAddMode: t.participant_add_mode_as_string, // "ADD" if "GROUP" and null if "ONE_TO_ONE"
|
126
|
-
montageThread: t.montage_thread
|
131
|
+
montageThread: t.montage_thread
|
132
|
+
? Buffer.from(t.montage_thread.id, "base64").toString()
|
133
|
+
: null, // base64 encoded string "message_thread:0000000000000000"
|
127
134
|
// it is not userID nor any other ID known to me...
|
128
135
|
// can somebody inspect it? where is it used?
|
129
136
|
// probably Messenger Day uses it
|
@@ -134,18 +141,31 @@ function formatThreadList(data) {
|
|
134
141
|
timestamp: t.updated_time_precise, // in miliseconds
|
135
142
|
// isCanonicalUser: t.is_canonical_neo_user, // is it always false?
|
136
143
|
// TODO: how about putting snippet in another object? current implementation does not handle every possibile message type etc.
|
137
|
-
snippet: lastMessageNode?lastMessageNode.snippet:null,
|
138
|
-
snippetAttachments: lastMessageNode
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
+
snippet: lastMessageNode ? lastMessageNode.snippet : null,
|
145
|
+
snippetAttachments: lastMessageNode
|
146
|
+
? lastMessageNode.extensible_attachment
|
147
|
+
: null, // TODO: not sure if it works
|
148
|
+
snippetSender: lastMessageNode
|
149
|
+
? utils.formatID(
|
150
|
+
(lastMessageNode.message_sender.messaging_actor.id || "").toString()
|
151
|
+
)
|
152
|
+
: null,
|
153
|
+
lastMessageTimestamp: lastMessageNode
|
154
|
+
? lastMessageNode.timestamp_precise
|
155
|
+
: null, // timestamp in miliseconds
|
156
|
+
lastReadTimestamp:
|
157
|
+
t.last_read_receipt && t.last_read_receipt.nodes.length > 0
|
158
|
+
? t.last_read_receipt.nodes[0]
|
159
|
+
? t.last_read_receipt.nodes[0].timestamp_precise
|
160
|
+
: null
|
161
|
+
: null, // timestamp in miliseconds
|
144
162
|
cannotReplyReason: t.cannot_reply_reason, // TODO: inspect possible values
|
145
163
|
approvalMode: Boolean(t.approval_mode),
|
146
164
|
|
147
165
|
// @Legacy
|
148
|
-
participantIDs: formatParticipants(t.all_participants).map(
|
166
|
+
participantIDs: formatParticipants(t.all_participants).map(
|
167
|
+
participant => participant.userID
|
168
|
+
),
|
149
169
|
threadType: t.thread_type === "GROUP" ? 2 : 1 // "GROUP" or "ONE_TO_ONE"
|
150
170
|
};
|
151
171
|
});
|
@@ -153,69 +173,78 @@ function formatThreadList(data) {
|
|
153
173
|
|
154
174
|
module.exports = function(defaultFuncs, api, ctx) {
|
155
175
|
return function getThreadList(limit, timestamp, tags, callback) {
|
156
|
-
if (
|
176
|
+
if (
|
177
|
+
!callback &&
|
178
|
+
(utils.getType(tags) === "Function" ||
|
179
|
+
utils.getType(tags) === "AsyncFunction")
|
180
|
+
) {
|
157
181
|
callback = tags;
|
158
182
|
tags = [""];
|
159
183
|
}
|
160
|
-
if (
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
throw {error: "getThreadList:
|
166
|
-
|
167
|
-
if (
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
throw {error: "getThreadList:
|
172
|
-
}
|
184
|
+
if (
|
185
|
+
utils.getType(limit) !== "Number" ||
|
186
|
+
!Number.isInteger(limit) ||
|
187
|
+
limit <= 0
|
188
|
+
)
|
189
|
+
throw { error: "getThreadList: limit must be a positive integer" };
|
190
|
+
|
191
|
+
if (
|
192
|
+
utils.getType(timestamp) !== "Null" &&
|
193
|
+
(utils.getType(timestamp) !== "Number" || !Number.isInteger(timestamp))
|
194
|
+
)
|
195
|
+
throw { error: "getThreadList: timestamp must be an integer or null" };
|
173
196
|
|
174
|
-
|
175
|
-
|
176
|
-
|
197
|
+
if (utils.getType(tags) === "String") tags = [tags];
|
198
|
+
if (utils.getType(tags) !== "Array")
|
199
|
+
throw { error: "getThreadList: tags must be an array" };
|
200
|
+
|
201
|
+
var resolveFunc = function() {};
|
202
|
+
var rejectFunc = function() {};
|
203
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
177
204
|
resolveFunc = resolve;
|
178
205
|
rejectFunc = reject;
|
179
206
|
});
|
180
207
|
|
181
|
-
if (
|
182
|
-
callback
|
183
|
-
|
184
|
-
|
185
|
-
|
208
|
+
if (
|
209
|
+
utils.getType(callback) !== "Function" &&
|
210
|
+
utils.getType(callback) !== "AsyncFunction"
|
211
|
+
) {
|
212
|
+
callback = function(err, data) {
|
213
|
+
if (err) return rejectFunc(err);
|
186
214
|
resolveFunc(data);
|
187
215
|
};
|
188
216
|
}
|
189
217
|
|
190
218
|
const form = {
|
191
|
-
|
192
|
-
|
193
|
-
|
219
|
+
av: ctx.globalOptions.pageID,
|
220
|
+
queries: JSON.stringify({
|
221
|
+
o0: {
|
194
222
|
// This doc_id was valid on 2020-07-20
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
223
|
+
doc_id: "3336396659757871",
|
224
|
+
query_params: {
|
225
|
+
limit: limit + (timestamp ? 1 : 0),
|
226
|
+
before: timestamp,
|
227
|
+
tags: tags,
|
228
|
+
includeDeliveryReceipts: true,
|
229
|
+
includeSeqID: false
|
202
230
|
}
|
203
231
|
}
|
204
232
|
}),
|
205
|
-
|
233
|
+
batch_name: "MessengerGraphQLThreadlistFetcher"
|
206
234
|
};
|
207
235
|
|
208
236
|
defaultFuncs
|
209
237
|
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
210
238
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
211
|
-
.then(
|
212
|
-
if (resData[resData.length - 1].error_results > 0)
|
239
|
+
.then(resData => {
|
240
|
+
if (resData[resData.length - 1].error_results > 0)
|
213
241
|
throw resData[0].o0.errors;
|
214
|
-
}
|
215
242
|
|
216
|
-
if (resData[resData.length - 1].successful_results === 0)
|
217
|
-
throw {
|
218
|
-
|
243
|
+
if (resData[resData.length - 1].successful_results === 0)
|
244
|
+
throw {
|
245
|
+
error: "getThreadList: there was no successful_results",
|
246
|
+
res: resData
|
247
|
+
};
|
219
248
|
|
220
249
|
// When we ask for threads using timestamp from the previous request,
|
221
250
|
// we are getting the last thread repeated as the first thread in this response.
|
@@ -223,13 +252,18 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
223
252
|
// It is also the reason for increasing limit by 1 when timestamp is set
|
224
253
|
// this way user asks for 10 threads, we are asking for 11,
|
225
254
|
// but after removing the duplicated one, it is again 10
|
226
|
-
if (timestamp)
|
227
|
-
|
228
|
-
|
229
|
-
|
255
|
+
if (timestamp) resData[0].o0.data.viewer.message_threads.nodes.shift();
|
256
|
+
|
257
|
+
callback(
|
258
|
+
null,
|
259
|
+
formatThreadList(resData[0].o0.data.viewer.message_threads.nodes)
|
260
|
+
);
|
230
261
|
})
|
231
|
-
.catch(
|
232
|
-
log.error(
|
262
|
+
.catch(err => {
|
263
|
+
log.error(
|
264
|
+
"getThreadList",
|
265
|
+
"Lỗi: getThreadList Có Thể Do Bạn Spam Quá Nhiều, Hãy Thử Lại !"
|
266
|
+
);
|
233
267
|
return callback(err);
|
234
268
|
});
|
235
269
|
|
@@ -6,36 +6,28 @@ var log = require("npmlog");
|
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function getThreadList(start, end, type, callback) {
|
8
8
|
if (utils.getType(callback) === "Undefined") {
|
9
|
-
if (utils.getType(end) !== "Number")
|
10
|
-
throw {
|
11
|
-
|
12
|
-
};
|
13
|
-
} else if (
|
9
|
+
if (utils.getType(end) !== "Number")
|
10
|
+
throw { error: "Please pass a number as a second argument." };
|
11
|
+
else if (
|
14
12
|
utils.getType(type) === "Function" ||
|
15
13
|
utils.getType(type) === "AsyncFunction"
|
16
14
|
) {
|
17
15
|
callback = type;
|
18
16
|
type = "inbox"; //default to inbox
|
19
|
-
} else if (utils.getType(type) !== "String")
|
17
|
+
} else if (utils.getType(type) !== "String")
|
20
18
|
throw {
|
21
19
|
error:
|
22
20
|
"Please pass a String as a third argument. Your options are: inbox, pending, and archived"
|
23
21
|
};
|
24
|
-
|
25
|
-
throw {
|
26
|
-
error: "getThreadList: need callback"
|
27
|
-
};
|
28
|
-
}
|
22
|
+
else throw { error: "getThreadList: need callback" };
|
29
23
|
}
|
30
24
|
|
31
|
-
if (type === "archived")
|
32
|
-
|
33
|
-
} else if (type !== "inbox" && type !== "pending" && type !== "other") {
|
25
|
+
if (type === "archived") type = "action:archived";
|
26
|
+
else if (type !== "inbox" && type !== "pending" && type !== "other")
|
34
27
|
throw {
|
35
28
|
error:
|
36
29
|
"type can only be one of the following: inbox, pending, archived, other"
|
37
30
|
};
|
38
|
-
}
|
39
31
|
|
40
32
|
if (end <= start) end = start + 20;
|
41
33
|
|
@@ -46,9 +38,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
46
38
|
form[type + "[offset]"] = start;
|
47
39
|
form[type + "[limit]"] = end - start;
|
48
40
|
|
49
|
-
if (ctx.globalOptions.pageID)
|
41
|
+
if (ctx.globalOptions.pageID)
|
50
42
|
form.request_user_id = ctx.globalOptions.pageID;
|
51
|
-
}
|
52
43
|
|
53
44
|
defaultFuncs
|
54
45
|
.post(
|
@@ -58,9 +49,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
58
49
|
)
|
59
50
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
60
51
|
.then(function(resData) {
|
61
|
-
if (resData.error)
|
62
|
-
throw resData;
|
63
|
-
}
|
52
|
+
if (resData.error) throw resData;
|
64
53
|
log.verbose("getThreadList", JSON.stringify(resData.payload.threads));
|
65
54
|
return callback(
|
66
55
|
null,
|
@@ -5,19 +5,17 @@ var log = require("npmlog");
|
|
5
5
|
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function getThreadPictures(threadID, offset, limit, 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
|
|
@@ -35,9 +33,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
35
33
|
)
|
36
34
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
37
35
|
.then(function(resData) {
|
38
|
-
if (resData.error)
|
39
|
-
throw resData;
|
40
|
-
}
|
36
|
+
if (resData.error) throw resData;
|
41
37
|
return Promise.all(
|
42
38
|
resData.payload.imagesData.map(function(image) {
|
43
39
|
form = {
|
@@ -52,9 +48,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
52
48
|
)
|
53
49
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
54
50
|
.then(function(resData) {
|
55
|
-
if (resData.error)
|
56
|
-
throw resData;
|
57
|
-
}
|
51
|
+
if (resData.error) throw resData;
|
58
52
|
// the response is pretty messy
|
59
53
|
var queryThreadID =
|
60
54
|
resData.jsmods.require[0][3][1].query_metadata.query_path[0]
|
@@ -67,9 +61,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
67
61
|
})
|
68
62
|
);
|
69
63
|
})
|
70
|
-
.then(
|
71
|
-
callback(null, resData);
|
72
|
-
})
|
64
|
+
.then(resData => callback(null, resData))
|
73
65
|
.catch(function(err) {
|
74
66
|
log.error("Error in getThreadPictures", err);
|
75
67
|
callback(err);
|
@@ -19,19 +19,17 @@ function formatData(data) {
|
|
19
19
|
|
20
20
|
module.exports = function(defaultFuncs, api, ctx) {
|
21
21
|
return function getUserID(name, callback) {
|
22
|
-
var resolveFunc = function(){};
|
23
|
-
var rejectFunc = function(){};
|
24
|
-
var returnPromise = new Promise(function
|
22
|
+
var resolveFunc = function() {};
|
23
|
+
var rejectFunc = function() {};
|
24
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
25
25
|
resolveFunc = resolve;
|
26
26
|
rejectFunc = reject;
|
27
27
|
});
|
28
28
|
|
29
29
|
if (!callback) {
|
30
|
-
callback = function
|
31
|
-
if (err)
|
32
|
-
|
33
|
-
}
|
34
|
-
resolveFunc(friendList);
|
30
|
+
callback = function(err, data) {
|
31
|
+
if (err) return rejectFunc(err);
|
32
|
+
resolveFunc(data);
|
35
33
|
};
|
36
34
|
}
|
37
35
|
|
@@ -48,9 +46,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
48
46
|
.get("https://www.facebook.com/ajax/typeahead/search.php", ctx.jar, form)
|
49
47
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
50
48
|
.then(function(resData) {
|
51
|
-
if (resData.error)
|
52
|
-
throw resData;
|
53
|
-
}
|
49
|
+
if (resData.error) throw resData;
|
54
50
|
|
55
51
|
var data = resData.payload.entries;
|
56
52
|
|
@@ -58,6 +54,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
58
54
|
})
|
59
55
|
.catch(function(err) {
|
60
56
|
log.error("getUserID", err);
|
57
|
+
console.log(err);
|
61
58
|
return callback(err);
|
62
59
|
});
|
63
60
|
|
@@ -29,25 +29,21 @@ function formatData(data) {
|
|
29
29
|
|
30
30
|
module.exports = function(defaultFuncs, api, ctx) {
|
31
31
|
return function getUserInfo(id, callback) {
|
32
|
-
var resolveFunc = function(){};
|
33
|
-
var rejectFunc = function(){};
|
34
|
-
var returnPromise = new Promise(function
|
32
|
+
var resolveFunc = function() {};
|
33
|
+
var rejectFunc = function() {};
|
34
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
35
35
|
resolveFunc = resolve;
|
36
36
|
rejectFunc = reject;
|
37
37
|
});
|
38
38
|
|
39
39
|
if (!callback) {
|
40
|
-
callback = function
|
41
|
-
if (err)
|
42
|
-
|
43
|
-
}
|
44
|
-
resolveFunc(friendList);
|
40
|
+
callback = function(err, userInfo) {
|
41
|
+
if (err) return rejectFunc(err);
|
42
|
+
resolveFunc(userInfo);
|
45
43
|
};
|
46
44
|
}
|
47
45
|
|
48
|
-
if (utils.getType(id) !== "Array")
|
49
|
-
id = [id];
|
50
|
-
}
|
46
|
+
if (utils.getType(id) !== "Array") id = [id];
|
51
47
|
|
52
48
|
var form = {};
|
53
49
|
id.map(function(v, i) {
|
@@ -57,16 +53,16 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
57
53
|
.post("https://www.facebook.com/chat/user_info/", ctx.jar, form)
|
58
54
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
59
55
|
.then(function(resData) {
|
60
|
-
if (resData.error)
|
61
|
-
throw resData;
|
62
|
-
}
|
56
|
+
if (resData.error) throw resData;
|
63
57
|
return callback(null, formatData(resData.payload.profiles));
|
64
58
|
})
|
65
59
|
.catch(function(err) {
|
66
|
-
log.error(
|
60
|
+
log.error(
|
61
|
+
"getUserInfo",
|
62
|
+
"Lỗi: getUserInfo Có Thể Do Bạn Spam Quá Nhiều !,Hãy Thử Lại !"
|
63
|
+
);
|
67
64
|
return callback(err);
|
68
65
|
});
|
69
|
-
|
70
66
|
return returnPromise;
|
71
67
|
};
|
72
68
|
};
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/* eslint-disable linebreak-style */
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var utils = require("../utils");
|
5
|
+
var log = require("npmlog");
|
6
|
+
|
7
|
+
|
8
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
9
|
+
return function getUserInfoV2(id, callback) {
|
10
|
+
var resolveFunc = function () { };
|
11
|
+
var rejectFunc = function () { };
|
12
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
13
|
+
resolveFunc = resolve;
|
14
|
+
rejectFunc = reject;
|
15
|
+
});
|
16
|
+
|
17
|
+
if (!callback) {
|
18
|
+
callback = function (err, userInfo) {
|
19
|
+
if (err) return rejectFunc(err);
|
20
|
+
resolveFunc(userInfo);
|
21
|
+
};
|
22
|
+
}
|
23
|
+
try {
|
24
|
+
var { getInfo } = require('../Extra/ExtraAddons');
|
25
|
+
getInfo(id)
|
26
|
+
.then(data => {
|
27
|
+
return callback(null, data);
|
28
|
+
});
|
29
|
+
}
|
30
|
+
catch (e) {
|
31
|
+
return callback(null, e);
|
32
|
+
}
|
33
|
+
return returnPromise;
|
34
|
+
};
|
35
|
+
};
|
@@ -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 handleFriendRequest(userID, accept, callback) {
|
8
|
+
if (utils.getType(accept) !== "Boolean")
|
9
|
+
throw { error: "Please pass a boolean as a second argument." };
|
10
|
+
|
11
|
+
var resolveFunc = function() {};
|
12
|
+
var rejectFunc = function() {};
|
13
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
14
|
+
resolveFunc = resolve;
|
15
|
+
rejectFunc = reject;
|
16
|
+
});
|
17
|
+
|
18
|
+
if (!callback) {
|
19
|
+
callback = function(err, data) {
|
20
|
+
if (err) return rejectFunc(err);
|
21
|
+
resolveFunc(data);
|
22
|
+
};
|
23
|
+
}
|
24
|
+
|
25
|
+
var form = {
|
26
|
+
viewer_id: userID,
|
27
|
+
"frefs[0]": "jwl",
|
28
|
+
floc: "friend_center_requests",
|
29
|
+
ref: "/reqs.php",
|
30
|
+
action: accept ? "confirm" : "reject"
|
31
|
+
};
|
32
|
+
|
33
|
+
defaultFuncs
|
34
|
+
.post("https://www.facebook.com/requests/friends/ajax/", ctx.jar, form)
|
35
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
36
|
+
.then(function(resData) {
|
37
|
+
if (resData.payload.err) throw { err: resData.payload.err };
|
38
|
+
return callback();
|
39
|
+
})
|
40
|
+
.catch(function(err) {
|
41
|
+
log.error("handleFriendRequest", err);
|
42
|
+
return callback(err);
|
43
|
+
});
|
44
|
+
|
45
|
+
return returnPromise;
|
46
|
+
};
|
47
|
+
};
|