@dongdev/fca-unofficial 1.0.14 → 1.0.16
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/CHANGELOG.md +6 -0
- package/index.d.ts +618 -0
- package/index.js +24 -30
- package/package.json +37 -2
- package/src/getUserInfo.js +24 -14
package/CHANGELOG.md
CHANGED
package/index.d.ts
ADDED
@@ -0,0 +1,618 @@
|
|
1
|
+
// Origin: NOCOM-BOT/mod_fbmsg_legacy
|
2
|
+
|
3
|
+
declare module '@dongdev/fca-unofficial' {
|
4
|
+
import type { Readable, Duplex, Transform } from "stream";
|
5
|
+
import type EventEmitter from "events";
|
6
|
+
|
7
|
+
type ReadableStream = Readable | Duplex | Transform;
|
8
|
+
function login(credentials: Partial<{
|
9
|
+
email: string,
|
10
|
+
password: string,
|
11
|
+
appState: AppstateData
|
12
|
+
}>, options: Partial<IFCAU_Options>, callback: (err: Error | null, api: IFCAU_API) => void): void;
|
13
|
+
function login(credentials: Partial<{
|
14
|
+
email: string,
|
15
|
+
password: string,
|
16
|
+
appState: AppstateData
|
17
|
+
}>, options: Partial<IFCAU_Options>): Promise<IFCAU_API>;
|
18
|
+
function login(credentials: Partial<{
|
19
|
+
email: string,
|
20
|
+
password: string,
|
21
|
+
appState: AppstateData
|
22
|
+
}>, callback: (err: Error | null, api: IFCAU_API) => void): void;
|
23
|
+
function login(credentials: Partial<{
|
24
|
+
email: string,
|
25
|
+
password: string,
|
26
|
+
appState: AppstateData
|
27
|
+
}>): Promise<IFCAU_API>;
|
28
|
+
|
29
|
+
export default login;
|
30
|
+
|
31
|
+
export type Cookie = {
|
32
|
+
key: string,
|
33
|
+
value: string,
|
34
|
+
domain: string,
|
35
|
+
path?: string,
|
36
|
+
hostOnly?: boolean,
|
37
|
+
creation?: string,
|
38
|
+
lastAccessed?: string
|
39
|
+
}
|
40
|
+
|
41
|
+
export type AppstateData = {
|
42
|
+
appState: Cookie[]
|
43
|
+
}
|
44
|
+
|
45
|
+
export type MessageObject = {
|
46
|
+
body: string,
|
47
|
+
sticker?: string,
|
48
|
+
attachment?: ReadableStream | ReadableStream[],
|
49
|
+
url?: string,
|
50
|
+
emoji?: string,
|
51
|
+
emojiSize?: string,
|
52
|
+
mentions?: {
|
53
|
+
tag: string,
|
54
|
+
id: string,
|
55
|
+
fromIndex?: number
|
56
|
+
}[],
|
57
|
+
location?: {
|
58
|
+
latitude: number,
|
59
|
+
longitude: number,
|
60
|
+
current?: boolean
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
function sendMessage(
|
65
|
+
message: string | MessageObject,
|
66
|
+
threadID: string | string[],
|
67
|
+
callback?: (err?: Error, data?: { threadID: string, messageID: string, timestamp: number }) => void,
|
68
|
+
replyMessageID?: string,
|
69
|
+
isGroup?: boolean
|
70
|
+
): Promise<{ threadID: string, messageID: string, timestamp: number }>;
|
71
|
+
function sendMessage(
|
72
|
+
message: string | MessageObject,
|
73
|
+
threadID: string | string[],
|
74
|
+
replyMessageID?: string,
|
75
|
+
isGroup?: boolean
|
76
|
+
): Promise<{ threadID: string, messageID: string, timestamp: number }>;
|
77
|
+
|
78
|
+
export type IFCAU_API = {
|
79
|
+
addUserToGroup: (userID: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
80
|
+
changeAdminStatus: (threadID: string, adminIDs: string | string[], adminStatus: boolean, callback?: (err?: Error) => void) => Promise<void>,
|
81
|
+
changeApprovalMode: (approvalMode: 0 | 1, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
82
|
+
changeArchivedStatus: (threadOrThreads: string | string[], archive: boolean, callback?: (err?: Error) => void) => Promise<void>,
|
83
|
+
changeBlockedStatus: (userID: string, blocked: boolean, callback?: (err?: Error) => void) => Promise<void>,
|
84
|
+
changeBlockedStatusMqtt: (userID: string, status: boolean, type: string?, callback?: (err?: Error) => void) => Promise<void>,
|
85
|
+
changeGroupImage: (image: ReadableStream, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
86
|
+
changeNickname: (nickname: string, threadID: string, pariticipantID: string, callback?: (err?: Error) => void) => Promise<void>,
|
87
|
+
changeThreadColor: (color: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
88
|
+
changeThreadEmoji: (emoji: string | null, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
89
|
+
createNewGroup: (participantIDs: string[], groupTitle?: string, callback?: (err: Error, threadID: string) => void) => Promise<string>,
|
90
|
+
createPoll: (title: string, threadID: string, options?: { [item: string]: boolean }, callback?: (err?: Error) => void) => Promise<void>,
|
91
|
+
createPollMqtt: (title: string, options?: { [item: string]: boolean }, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
92
|
+
deleteMessage: (messageOrMessages: string | string[], callback?: (err?: Error) => void) => Promise<void>,
|
93
|
+
deleteThread: (threadOrThreads: string | string[], callback?: (err?: Error) => void) => Promise<void>,
|
94
|
+
editMessage: (text: string, messageID: string, callback?: (err?: Error) => void) => Promise<void>,
|
95
|
+
forwardAttachment: (attachmentID: string, userOrUsers: string | string[], callback?: (err?: Error) => void) => Promise<void>,
|
96
|
+
forwardMessage: (messageID: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
97
|
+
getAppState: () => any,
|
98
|
+
getCurrentUserID: () => string,
|
99
|
+
getEmojiUrl: (c: string, size: number, pixelRatio: number) => string,
|
100
|
+
getFriendsList: (callback?: (err: Error | null, friends: IFCAU_Friend[]) => void) => Promise<IFCAU_Friend[]>,
|
101
|
+
getThreadHistory: (threadID: string, amount: number, time?: number, callback?: (err: Error | null, messages: any[]) => void) => Promise<any[]>,
|
102
|
+
getThreadInfo: (threadID: string, callback?: (err: Error | null, thread: IFCAU_Thread) => void) => Promise<IFCAU_Thread>,
|
103
|
+
getThreadList: (limit: number, timestamp: number | null, tags: string[], callback?: (err: Error | null, threads: IFCAU_ThreadList) => void) => Promise<IFCAU_ThreadList>,
|
104
|
+
getThreadPictures: (threadID: string, offset: number, limit: number, callback?: (err: Error | null, pictures: string[]) => void) => Promise<string[]>,
|
105
|
+
getUserID: (name: string, callback?: (err: Error | null, obj: IFCAU_UserIDResponse) => void) => Promise<IFCAU_UserIDResponse>,
|
106
|
+
getUserInfo: (userOrUsers: string | string[], callback?: (err: Error | null, users: { [id: string]: IFCAU_User }) => void) => Promise<{ [id: string]: IFCAU_User }>,
|
107
|
+
threadColors: {
|
108
|
+
[color: string]: string
|
109
|
+
},
|
110
|
+
handleMessageRequest(threadOrThreads: string | string[], accept: boolean, callback: (err?: Error) => void): Promise<void>;
|
111
|
+
listen(callback?: (err: Error | null, message: IFCAU_ListenMessage) => void): EventEmitter;
|
112
|
+
listenMqtt(callback?: (err: Error | null, message: IFCAU_ListenMessage) => void): EventEmitter & { stopListening: (callback?: () => void) => void };
|
113
|
+
logout: (callback?: (err?: Error) => void) => Promise<void>,
|
114
|
+
markAsDelivered(threadID: string, messageID: string, callback?: (err?: Error) => void): Promise<void>,
|
115
|
+
markAsRead(threadID: string, read?: boolean, callback?: (err?: Error) => void): Promise<void>,
|
116
|
+
markAsReadAll: (callback?: (err?: Error) => void) => Promise<void>,
|
117
|
+
markAsSeen(seenTimestamp?: number, callback?: (err?: Error) => void): Promise<void>,
|
118
|
+
muteThread: (threadID: string, muteSeconds: number, callback?: (err?: Error) => void) => Promise<void>,
|
119
|
+
pinMessage: (pinMode: boolean, messageID: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
120
|
+
removeUserFromGroup: (userID: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
121
|
+
resolvePhotoUrl: (photoID: string, callback?: (err: Error | null, url: string) => void) => Promise<string>,
|
122
|
+
sendMessage: typeof sendMessage,
|
123
|
+
sendTypingIndicator: (threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
124
|
+
sendTypingIndicatorMqtt: (isTyping: boolean, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
125
|
+
setMessageReaction: (reaction: string, messageID: string, callback?: (err?: Error) => void, forceCustomReaction?: boolean) => Promise<void>,
|
126
|
+
setMessageReactionMqtt: (reaction: string, messageID: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
127
|
+
setOptions: (options: Partial<IFCAU_Options>) => void,
|
128
|
+
setTitle: (newTitle: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
129
|
+
setTheme: (themeID?: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
130
|
+
unsendMessage: (messageID: string, callback?: (err?: Error) => void) => Promise<void>,
|
131
|
+
unsendMessageMqtt: (messageID: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
|
132
|
+
}
|
133
|
+
|
134
|
+
export type IFCAU_ListenMessage =
|
135
|
+
{
|
136
|
+
type: "message",
|
137
|
+
attachments: IFCAU_Attachment[],
|
138
|
+
args: string[],
|
139
|
+
body: string,
|
140
|
+
isGroup: boolean,
|
141
|
+
mentions: { [id: string]: string },
|
142
|
+
messageID: string,
|
143
|
+
senderID: string,
|
144
|
+
threadID: string,
|
145
|
+
isUnread: boolean,
|
146
|
+
participantIDs: string[]
|
147
|
+
} |
|
148
|
+
{
|
149
|
+
type: "event",
|
150
|
+
author: string,
|
151
|
+
logMessageBody: string,
|
152
|
+
logMessageData: {
|
153
|
+
image: {
|
154
|
+
attachmentID: string,
|
155
|
+
width: number,
|
156
|
+
height: number,
|
157
|
+
url: string
|
158
|
+
}
|
159
|
+
},
|
160
|
+
logMessageType: "log:thread-image",
|
161
|
+
threadID: string
|
162
|
+
} |
|
163
|
+
{
|
164
|
+
type: "event",
|
165
|
+
author: string,
|
166
|
+
logMessageBody: string,
|
167
|
+
logMessageData: {
|
168
|
+
addedParticipants: {
|
169
|
+
fanoutPolicy: string,
|
170
|
+
firstName: string,
|
171
|
+
fullName: string,
|
172
|
+
groupJoinStatus: string,
|
173
|
+
initialFolder: string,
|
174
|
+
initialFolderId: {
|
175
|
+
systemFolderId: string,
|
176
|
+
},
|
177
|
+
lastUnsubscribeTimestampMs: string,
|
178
|
+
userFbId: string,
|
179
|
+
isMessengerUser: boolean
|
180
|
+
}[],
|
181
|
+
},
|
182
|
+
logMessageType: "log:subscribe",
|
183
|
+
threadID: string,
|
184
|
+
participantIDs: string[]
|
185
|
+
} |
|
186
|
+
{
|
187
|
+
type: "event",
|
188
|
+
author: string,
|
189
|
+
logMessageBody: string,
|
190
|
+
logMessageData: { leftParticipantFbId: string },
|
191
|
+
logMessageType: "log:unsubscribe",
|
192
|
+
threadID: string,
|
193
|
+
participantIDs: string[]
|
194
|
+
} |
|
195
|
+
{
|
196
|
+
type: "event",
|
197
|
+
author: string,
|
198
|
+
logMessageBody: string,
|
199
|
+
logMessageData: { name: string },
|
200
|
+
logMessageType: "log:thread-name",
|
201
|
+
threadID: string,
|
202
|
+
participantIDs: string[]
|
203
|
+
} |
|
204
|
+
{
|
205
|
+
type: "event",
|
206
|
+
author: string,
|
207
|
+
logMessageBody: string,
|
208
|
+
logMessageData: {
|
209
|
+
theme_color: string,
|
210
|
+
gradient?: string,
|
211
|
+
should_show_icon: string,
|
212
|
+
theme_id: string,
|
213
|
+
accessibility_label: string,
|
214
|
+
theme_name_with_subtitle: string,
|
215
|
+
theme_emoji?: string
|
216
|
+
},
|
217
|
+
logMessageType: "log:thread-color",
|
218
|
+
threadID: string,
|
219
|
+
participantIDs: string[]
|
220
|
+
} |
|
221
|
+
{
|
222
|
+
type: "event",
|
223
|
+
author: string,
|
224
|
+
logMessageBody: string,
|
225
|
+
logMessageData: {
|
226
|
+
thread_quick_reaction_instruction_key_id: string,
|
227
|
+
thread_quick_reaction_emoji: string,
|
228
|
+
thread_quick_reaction_emoji_url: string
|
229
|
+
},
|
230
|
+
logMessageType: "log:thread-icon",
|
231
|
+
threadID: string,
|
232
|
+
participantIDs: string[]
|
233
|
+
} |
|
234
|
+
{
|
235
|
+
type: "event",
|
236
|
+
author: string,
|
237
|
+
logMessageBody: string,
|
238
|
+
logMessageData: {
|
239
|
+
nickname: string,
|
240
|
+
participant_id: string
|
241
|
+
},
|
242
|
+
logMessageType: "log:user-nickname",
|
243
|
+
threadID: string,
|
244
|
+
participantIDs: string[]
|
245
|
+
} |
|
246
|
+
{
|
247
|
+
type: "event",
|
248
|
+
author: string,
|
249
|
+
logMessageBody: string,
|
250
|
+
logMessageData: {
|
251
|
+
THREAD_CATEGORY: string,
|
252
|
+
TARGET_ID: string,
|
253
|
+
ADMIN_TYPE: string,
|
254
|
+
ADMIN_EVENT: 'add_admin' | 'remove_admin'
|
255
|
+
},
|
256
|
+
logMessageType: "log:thread-admins",
|
257
|
+
threadID: string,
|
258
|
+
participantIDs: string[]
|
259
|
+
} |
|
260
|
+
{
|
261
|
+
type: "event",
|
262
|
+
author: string,
|
263
|
+
logMessageBody: string,
|
264
|
+
logMessageData: {
|
265
|
+
removed_option_ids: string,
|
266
|
+
question_json: string,
|
267
|
+
event_type: 'question_creation' | 'update_vote' | 'add_unvoted_option' | 'multiple_updates',
|
268
|
+
added_option_ids: string,
|
269
|
+
new_option_texts: string,
|
270
|
+
new_option_ids: string,
|
271
|
+
question_id: string,
|
272
|
+
},
|
273
|
+
logMessageType: "log:thread-poll",
|
274
|
+
threadID: string,
|
275
|
+
participantIDs: string[]
|
276
|
+
} |
|
277
|
+
{
|
278
|
+
type: "event",
|
279
|
+
author: string,
|
280
|
+
logMessageBody: string,
|
281
|
+
logMessageData: { APPROVAL_MODE: '0' | '1', THREAD_CATEGORY: string },
|
282
|
+
logMessageType: "log:thread-approval-mode",
|
283
|
+
threadID: string,
|
284
|
+
participantIDs: string[]
|
285
|
+
} |
|
286
|
+
{
|
287
|
+
type: "event",
|
288
|
+
author: string,
|
289
|
+
logMessageBody: string,
|
290
|
+
logMessageData: any,
|
291
|
+
logMessageType: "log:thread-call",
|
292
|
+
threadID: string,
|
293
|
+
participantIDs: string[]
|
294
|
+
} |
|
295
|
+
{
|
296
|
+
type: "typ",
|
297
|
+
from: string,
|
298
|
+
fromMobile: boolean,
|
299
|
+
isTyping: boolean,
|
300
|
+
threadID: string
|
301
|
+
} |
|
302
|
+
{
|
303
|
+
type: "read",
|
304
|
+
threadID: string,
|
305
|
+
time: number,
|
306
|
+
} |
|
307
|
+
{
|
308
|
+
type: "read_receipt",
|
309
|
+
reader: string,
|
310
|
+
threadID: string,
|
311
|
+
time: number
|
312
|
+
} | {
|
313
|
+
type: "message_reaction",
|
314
|
+
threadID: string,
|
315
|
+
messageID: string,
|
316
|
+
reaction: string,
|
317
|
+
senderID: string,
|
318
|
+
userID: string,
|
319
|
+
reactionTimestamp: number
|
320
|
+
} | {
|
321
|
+
type: "presence",
|
322
|
+
statuses: number,
|
323
|
+
timestamp: number,
|
324
|
+
userID: string
|
325
|
+
} | {
|
326
|
+
type: "message_unsend",
|
327
|
+
threadID: string,
|
328
|
+
senderID: string,
|
329
|
+
messageID: string,
|
330
|
+
deletionnTimestamp: number
|
331
|
+
} | {
|
332
|
+
type: "message_reply"
|
333
|
+
attachments: IFCAU_Attachment[],
|
334
|
+
args: string[],
|
335
|
+
body: string,
|
336
|
+
isGroup: boolean,
|
337
|
+
mentions: { [id: string]: string },
|
338
|
+
messageID: string,
|
339
|
+
senderID: string,
|
340
|
+
threadID: string,
|
341
|
+
isUnread: boolean,
|
342
|
+
participantIDs: string[],
|
343
|
+
messageReply: {
|
344
|
+
attachments: IFCAU_Attachment[],
|
345
|
+
body: string,
|
346
|
+
isGroup: boolean,
|
347
|
+
mentions: { [id: string]: string },
|
348
|
+
messageID: string,
|
349
|
+
senderID: string,
|
350
|
+
threadID: string,
|
351
|
+
isUnread: boolean
|
352
|
+
}
|
353
|
+
};
|
354
|
+
|
355
|
+
export type IFCAU_Attachment =
|
356
|
+
{
|
357
|
+
type: "sticker",
|
358
|
+
ID: string,
|
359
|
+
url: string,
|
360
|
+
packID: string,
|
361
|
+
spriteUrl: string,
|
362
|
+
spriteUrl2x: string,
|
363
|
+
width: number,
|
364
|
+
height: number,
|
365
|
+
caption: string,
|
366
|
+
description: string,
|
367
|
+
frameCount: number,
|
368
|
+
frameRate: number,
|
369
|
+
framesPerRow: number,
|
370
|
+
framesPerCol: number
|
371
|
+
} |
|
372
|
+
{
|
373
|
+
type: "file",
|
374
|
+
ID: string,
|
375
|
+
filename: string,
|
376
|
+
url: string,
|
377
|
+
isMalicious: boolean,
|
378
|
+
contentType: string
|
379
|
+
} |
|
380
|
+
{
|
381
|
+
type: "photo",
|
382
|
+
ID: string,
|
383
|
+
filename: string,
|
384
|
+
thumbnailUrl: string,
|
385
|
+
previewUrl: string,
|
386
|
+
previewWidth: number,
|
387
|
+
previewHeight: number,
|
388
|
+
largePreviewUrl: string,
|
389
|
+
largePreviewWidth: number,
|
390
|
+
largePreviewHeight: number,
|
391
|
+
url: string,
|
392
|
+
width: number,
|
393
|
+
height: number
|
394
|
+
} |
|
395
|
+
{
|
396
|
+
type: "animated_image",
|
397
|
+
ID: string,
|
398
|
+
filename: string,
|
399
|
+
previewUrl: string,
|
400
|
+
previewWidth: number,
|
401
|
+
previewHeight: number,
|
402
|
+
url: string,
|
403
|
+
width: number,
|
404
|
+
height: number
|
405
|
+
} |
|
406
|
+
{
|
407
|
+
type: "video",
|
408
|
+
ID: string,
|
409
|
+
filename: string,
|
410
|
+
previewUrl: string,
|
411
|
+
previewWidth: number,
|
412
|
+
previewHeight: number,
|
413
|
+
url: string,
|
414
|
+
width: number,
|
415
|
+
height: number
|
416
|
+
duration: number,
|
417
|
+
videoType: string
|
418
|
+
} |
|
419
|
+
{
|
420
|
+
type: "audio",
|
421
|
+
ID: string,
|
422
|
+
filename: string,
|
423
|
+
audioType: string,
|
424
|
+
duration: number,
|
425
|
+
url: string,
|
426
|
+
isVoiceMail: boolean
|
427
|
+
} |
|
428
|
+
{
|
429
|
+
type: "location",
|
430
|
+
ID: string,
|
431
|
+
latitude: number,
|
432
|
+
longitude: number,
|
433
|
+
image: string,
|
434
|
+
width: number,
|
435
|
+
height: number,
|
436
|
+
url: string,
|
437
|
+
address: string
|
438
|
+
} |
|
439
|
+
{
|
440
|
+
type: "share",
|
441
|
+
ID: string,
|
442
|
+
url: string,
|
443
|
+
title: string,
|
444
|
+
description: string,
|
445
|
+
source: string,
|
446
|
+
image: string,
|
447
|
+
width: number,
|
448
|
+
height: number,
|
449
|
+
playable: boolean,
|
450
|
+
duration: number,
|
451
|
+
playableUrl: string,
|
452
|
+
subattachments: any,
|
453
|
+
properties: any
|
454
|
+
}
|
455
|
+
|
456
|
+
export type IFCAU_User = {
|
457
|
+
name: string,
|
458
|
+
firstName?: string,
|
459
|
+
vanity?: string,
|
460
|
+
thumbSrc: string,
|
461
|
+
profileUrl: string | null,
|
462
|
+
gender?: number,
|
463
|
+
type: string,
|
464
|
+
isFriend?: boolean,
|
465
|
+
isBirthday: boolean,
|
466
|
+
searchToken: any,
|
467
|
+
alternateName?: string
|
468
|
+
}
|
469
|
+
|
470
|
+
export type IFCAU_UserIDResponse = {
|
471
|
+
userID: string,
|
472
|
+
photoUrl: string,
|
473
|
+
indexRank: number,
|
474
|
+
name: string,
|
475
|
+
isVerified: boolean,
|
476
|
+
profileUrl: string,
|
477
|
+
category: string,
|
478
|
+
score: number,
|
479
|
+
type: string
|
480
|
+
}[];
|
481
|
+
|
482
|
+
export type IFCAU_Options = {
|
483
|
+
pauseLog: boolean,
|
484
|
+
logLevel: "silly" | "verbose" | "info" | "http" | "warn" | "error" | "silent",
|
485
|
+
selfListen: boolean,
|
486
|
+
listenEvents: boolean,
|
487
|
+
pageID: string,
|
488
|
+
updatePresence: boolean,
|
489
|
+
forceLogin: boolean,
|
490
|
+
userAgent: string,
|
491
|
+
autoMarkDelivery: boolean,
|
492
|
+
autoMarkRead: boolean,
|
493
|
+
proxy: string,
|
494
|
+
online: boolean
|
495
|
+
}
|
496
|
+
|
497
|
+
export type IFCAU_Friend = {
|
498
|
+
alternativeName: string,
|
499
|
+
firstName: string,
|
500
|
+
gender: string,
|
501
|
+
userID: string,
|
502
|
+
isFriend: boolean,
|
503
|
+
fullName: string,
|
504
|
+
profilePicture: string,
|
505
|
+
type: string,
|
506
|
+
profileUrl: string,
|
507
|
+
vanity: string,
|
508
|
+
isBirthday: boolean
|
509
|
+
}
|
510
|
+
|
511
|
+
export type IFCAU_Thread = {
|
512
|
+
threadID: string,
|
513
|
+
participantIDs: string[],
|
514
|
+
threadName: string,
|
515
|
+
userInfo: (IFCAU_User & { id: string })[],
|
516
|
+
nicknames: { [id: string]: string } | null,
|
517
|
+
unreadCount: number,
|
518
|
+
messageCount: number,
|
519
|
+
imageSrc: string,
|
520
|
+
timestamp: number,
|
521
|
+
muteUntil: number | null,
|
522
|
+
isGroup: boolean,
|
523
|
+
isSubscribed: boolean,
|
524
|
+
folder: 'INBOX' | 'ARCHIVE' | string,
|
525
|
+
isArchived: boolean,
|
526
|
+
cannotReplyReason: string | null,
|
527
|
+
lastReadTimestamp: number,
|
528
|
+
emoji: string | null,
|
529
|
+
color: string | null,
|
530
|
+
adminIDs: string[],
|
531
|
+
approvalMode: boolean,
|
532
|
+
approvalQueue: { inviterID: string, requesterID: string, timestamp: string }[]
|
533
|
+
}
|
534
|
+
|
535
|
+
export type IFCAU_ThreadList = {
|
536
|
+
threadID: string,
|
537
|
+
name: string,
|
538
|
+
unreadCount: number,
|
539
|
+
messageCount: number,
|
540
|
+
imageSrc: string,
|
541
|
+
emoji: string | null,
|
542
|
+
color: string | null,
|
543
|
+
nicknames: { userid: string, nickname: string }[],
|
544
|
+
muteUntil: number | null,
|
545
|
+
participants: IFCAU_ThreadList_Participants[],
|
546
|
+
adminIDs: string[],
|
547
|
+
folder: "INBOX" | "ARCHIVED" | "PENNDING" | "OTHER" | string,
|
548
|
+
isGroup: boolean,
|
549
|
+
customizationEnabled: boolean,
|
550
|
+
participantAddMode: string,
|
551
|
+
reactionMuteMode: string,
|
552
|
+
isArchived: boolean,
|
553
|
+
isSubscribed: boolean,
|
554
|
+
timestamp: number,
|
555
|
+
snippet: string,
|
556
|
+
snippetAttachments: string
|
557
|
+
snippetSender: string,
|
558
|
+
lastMessageTimestamp: number,
|
559
|
+
listReadTimestamp: number | null,
|
560
|
+
cannotReplyReason: string | null,
|
561
|
+
approvalMode: string
|
562
|
+
}[]
|
563
|
+
|
564
|
+
export type IFCAU_ThreadList_Participants =
|
565
|
+
{
|
566
|
+
accountType: "User",
|
567
|
+
userID: string,
|
568
|
+
name: string,
|
569
|
+
shortName: string,
|
570
|
+
gender: string,
|
571
|
+
url: string,
|
572
|
+
profilePicture: string,
|
573
|
+
username: string | null,
|
574
|
+
isViewerFriend: boolean,
|
575
|
+
isMessengerUser: boolean,
|
576
|
+
isVerified: boolean,
|
577
|
+
isMessageBlockedByViewer: boolean,
|
578
|
+
isViewerCoworker: boolean
|
579
|
+
} |
|
580
|
+
{
|
581
|
+
accountType: "Page",
|
582
|
+
userID: string,
|
583
|
+
name: string,
|
584
|
+
url: string,
|
585
|
+
profilePicture: string,
|
586
|
+
username: string | null,
|
587
|
+
acceptMessengerUserFeedback: boolean,
|
588
|
+
isMessengerUser: boolean,
|
589
|
+
isVerified: boolean,
|
590
|
+
isMessengerPlatformBot: boolean,
|
591
|
+
isMessageBlockedByViewer: boolean,
|
592
|
+
} |
|
593
|
+
{
|
594
|
+
accountType: "ReducedMessagingActor",
|
595
|
+
userID: string,
|
596
|
+
name: string,
|
597
|
+
url: string,
|
598
|
+
profilePicture: string,
|
599
|
+
username: string | null,
|
600
|
+
acceptMessengerUserFeedback: boolean,
|
601
|
+
isMessageBlockedByViewer: boolean
|
602
|
+
} |
|
603
|
+
{
|
604
|
+
accountType: "UnavailableMessagingActor",
|
605
|
+
userID: string,
|
606
|
+
name: string,
|
607
|
+
url: null,
|
608
|
+
profilePicture: string,
|
609
|
+
username: null,
|
610
|
+
acceptMessengerUserFeedback: boolean,
|
611
|
+
isMessageBlockedByViewer: boolean
|
612
|
+
} |
|
613
|
+
{
|
614
|
+
accountType: string,
|
615
|
+
userID: string,
|
616
|
+
name: string
|
617
|
+
};
|
618
|
+
}
|
package/index.js
CHANGED
@@ -36,36 +36,6 @@ if (!fs.existsSync(configPath)) {
|
|
36
36
|
global.fca = {
|
37
37
|
config: config
|
38
38
|
};
|
39
|
-
async function checkForUpdates() {
|
40
|
-
logger('Auto Check Update...', '[ FCA-UNO ] >');
|
41
|
-
try {
|
42
|
-
const packageResponse = await axios.get('https://raw.githubusercontent.com/DongDev-VN/fca-unofficial/main/package.json');
|
43
|
-
const localBrandVersion = JSON.parse(readFileSync(path.join('./node_modules/@dongdev/fca-unofficial/package.json'), 'utf8')).version;
|
44
|
-
if (localBrandVersion !== packageResponse.data.version) {
|
45
|
-
logger(`New Version Published: ${localBrandVersion} => ${packageResponse.data.version}`, '[ FCA-UNO ] >');
|
46
|
-
logger('Performing Automatic Update to the Latest Version!', '[ FCA-UNO ] >');
|
47
|
-
const fcaUnoPath = path.join(process.cwd(), 'node_modules', '@dongdev', 'fca-unofficial');
|
48
|
-
if (fs.existsSync(fcaUnoPath)) {
|
49
|
-
fs.rmSync(fcaUnoPath, { recursive: true, force: true });
|
50
|
-
}
|
51
|
-
execSync('npm install @dongdev/fca-unofficial@latest', { stdio: 'inherit' });
|
52
|
-
logger('Version Upgrade Successful!', '[ FCA-UNO ] >');
|
53
|
-
logger('Restarting...', '[ FCA-UNO ] >');
|
54
|
-
await new Promise(resolve => setTimeout(resolve, 5000));
|
55
|
-
console.clear();
|
56
|
-
process.exit(1);
|
57
|
-
} else {
|
58
|
-
logger(`You Are Currently Using Version: ${localBrandVersion}!`, '[ FCA-UNO ] >');
|
59
|
-
logger('Have a good day!', '[ FCA-UNO ] >');
|
60
|
-
}
|
61
|
-
} catch (err) {
|
62
|
-
logger(`Error checking/updating package: ${err}`, '[ FCA-UNO ] >');
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
if (global.fca.config.autoUpdate) {
|
67
|
-
checkForUpdates();
|
68
|
-
}
|
69
39
|
const Boolean_Option = [
|
70
40
|
"online",
|
71
41
|
"selfListen",
|
@@ -310,6 +280,30 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
|
|
310
280
|
|
311
281
|
mainPromise
|
312
282
|
.then(async () => {
|
283
|
+
if (global.fca.config.autoUpdate) {
|
284
|
+
axios.get('https://raw.githubusercontent.com/DongDev-VN/fca-unofficial/main/package.json').then(async (res) => {
|
285
|
+
const localbrand = JSON.parse(readFileSync('./node_modules/@dongdev/fca-unofficial/package.json')).version;
|
286
|
+
if (localbrand != res.data.version) {
|
287
|
+
logger(`New Version Published: ${JSON.parse(readFileSync('./node_modules/@dongdev/fca-unofficial/package.json')).version} => ${res.data.version}`, 'warn');
|
288
|
+
logger(`Perform Automatic Update to the Latest Version !`, 'warn');
|
289
|
+
try {
|
290
|
+
execSync('npm install @dongdev/fca-unofficial@latest', { stdio: 'inherit' });
|
291
|
+
logger("Upgrade Version Successfully!", "[ FCA-UNO ] >")
|
292
|
+
logger('Restarting...', '[ FCA-UNO ] >');
|
293
|
+
await new Promise(resolve => setTimeout(resolve, 5 * 1000));
|
294
|
+
console.clear();
|
295
|
+
process.exit(1);
|
296
|
+
} catch (err) {
|
297
|
+
logger('Error Auto Update ! ' + err, 'error');
|
298
|
+
}
|
299
|
+
} else {
|
300
|
+
logger(`You Are Currently Using Version: ` + localbrand + ' !', "[ FCA-UNO ] >");
|
301
|
+
logger(`Have a good day !`, "[ FCA-UNO ] >")
|
302
|
+
await new Promise(resolve => setTimeout(resolve, 5 * 1000));
|
303
|
+
callback(null, api);
|
304
|
+
}
|
305
|
+
});
|
306
|
+
}
|
313
307
|
logger('Login successful!', '[ FCA-UNO ] >');
|
314
308
|
callback(null, api);
|
315
309
|
})
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dongdev/fca-unofficial",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.16",
|
4
4
|
"description": "A Facebook chat API without XMPP, will not be deprecated after April 30th, 2015.",
|
5
5
|
"main": "index.js",
|
6
6
|
"repository": {
|
@@ -27,7 +27,7 @@
|
|
27
27
|
},
|
28
28
|
"devDependencies": {
|
29
29
|
"eslint": "^7.5.0",
|
30
|
-
"mocha": "^
|
30
|
+
"mocha": "^10.2.0",
|
31
31
|
"prettier": "^1.11.1"
|
32
32
|
},
|
33
33
|
"scripts": {
|
@@ -45,6 +45,41 @@
|
|
45
45
|
"engines": {
|
46
46
|
"node": ">=10.x"
|
47
47
|
},
|
48
|
+
"eslintConfig": {
|
49
|
+
"env": {
|
50
|
+
"es6": true,
|
51
|
+
"es2017": true,
|
52
|
+
"node": true
|
53
|
+
},
|
54
|
+
"extends": "eslint:recommended",
|
55
|
+
"parserOptions": {
|
56
|
+
"sourceType": "module"
|
57
|
+
},
|
58
|
+
"rules": {
|
59
|
+
"linebreak-style": [
|
60
|
+
"error",
|
61
|
+
"unix"
|
62
|
+
],
|
63
|
+
"semi": [
|
64
|
+
"error",
|
65
|
+
"always"
|
66
|
+
],
|
67
|
+
"no-unused-vars": [
|
68
|
+
1,
|
69
|
+
{
|
70
|
+
"argsIgnorePattern": "^_",
|
71
|
+
"varsIgnorePattern": "^_"
|
72
|
+
}
|
73
|
+
],
|
74
|
+
"no-empty": [
|
75
|
+
"error",
|
76
|
+
{
|
77
|
+
"allowEmptyCatch": true
|
78
|
+
}
|
79
|
+
]
|
80
|
+
}
|
81
|
+
},
|
82
|
+
"types": "index.d.ts",
|
48
83
|
"homepage": "https://github.com/DongDev-VN/fca-unofficial#readme",
|
49
84
|
"bugs": {
|
50
85
|
"url": "https://github.com/DongDev-VN/fca-unofficial/issues"
|
package/src/getUserInfo.js
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
var utils = require("../utils");
|
4
3
|
var log = require("npmlog");
|
5
|
-
|
6
4
|
module.exports = function (defaultFuncs, api, ctx) {
|
7
5
|
function formatData(data) {
|
8
6
|
const retObj = {};
|
@@ -36,12 +34,13 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
36
34
|
resolveFunc(data);
|
37
35
|
};
|
38
36
|
}
|
39
|
-
const
|
37
|
+
const ids = Array.isArray(id) ? id : [id];
|
38
|
+
var form = {
|
40
39
|
queries: JSON.stringify({
|
41
40
|
o0: {
|
42
41
|
doc_id: "5009315269112105",
|
43
42
|
query_params: {
|
44
|
-
ids:
|
43
|
+
ids: ids
|
45
44
|
}
|
46
45
|
}
|
47
46
|
}),
|
@@ -50,21 +49,32 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
50
49
|
defaultFuncs
|
51
50
|
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
52
51
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
53
|
-
.then(resData
|
54
|
-
if (!resData || resData.
|
55
|
-
throw
|
52
|
+
.then(function(resData) {
|
53
|
+
if (!resData || resData.length === 0) {
|
54
|
+
throw new Error("Empty response from server");
|
56
55
|
}
|
57
|
-
|
58
|
-
|
59
|
-
console.error("getUserInfo", "Không nhận được dữ liệu hợp lệ!");
|
60
|
-
return callback(new Error("Invalid data received"));
|
56
|
+
if (resData.error) {
|
57
|
+
throw resData.error;
|
61
58
|
}
|
62
|
-
|
59
|
+
const response = resData[0];
|
60
|
+
if (!response || !response.o0) {
|
61
|
+
throw new Error("Invalid response format");
|
62
|
+
}
|
63
|
+
if (response.o0.errors && response.o0.errors.length > 0) {
|
64
|
+
throw new Error(response.o0.errors[0].message || "GraphQL error");
|
65
|
+
}
|
66
|
+
const result = response.o0.data;
|
67
|
+
if (!result || !result.messaging_actors || result.messaging_actors.length === 0) {
|
68
|
+
log.warn("getUserInfo", "No user data found for the provided ID(s)");
|
69
|
+
return callback(null, {});
|
70
|
+
}
|
71
|
+
const formattedData = formatData(result);
|
72
|
+
return callback(null, formattedData);
|
63
73
|
})
|
64
74
|
.catch(err => {
|
65
|
-
log.error("
|
75
|
+
log.error("getUserInfoGraphQL", "Error: " + (err.message || "Unknown error occurred"));
|
66
76
|
callback(err);
|
67
|
-
});
|
77
|
+
});
|
68
78
|
return returnPromise;
|
69
79
|
};
|
70
80
|
};
|