alicezetion 1.8.1 → 1.8.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"nonce":4541222632038562979,"last_updated":{"seconds":1696933204,"nanos":504530000}}
1
+ {"nonce":2843687609344956274,"last_updated":{"seconds":1696934066,"nanos":547808000}}
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ async function downloadStory(url, 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, data) {
16
+ if (err) return rejectFunc(err);
17
+ resolveFunc(data);
18
+ };
19
+ }
20
+ var form = {
21
+ av: ctx.userID,
22
+ fb_api_caller_class: "RelayModern",
23
+ fb_api_req_friendly_name: "StoriesViewerBucketPrefetcherMultiBucketsQuery",
24
+ doc_id: "2913003758722672",
25
+ variables: JSON.stringify({
26
+ "bucketIDs": url.split('/')[4],
27
+ "scale": 1,
28
+ "prefetchPhotoUri":false
29
+ })
30
+ };
31
+ defaultFuncs.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
32
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
33
+ .then(function (resData) {
34
+ if (resData.errors) throw resData;
35
+ if(resData.error) return callback("Không thể tìm kiếm video này");
36
+ var data = resData.data.nodes[0].unified_stories.edges
37
+ var str = data.find(i => i.node.id == url.split('/')[5]);
38
+ console.log()
39
+ if(str == null) return callback('Không thể tìm kiếm video này');
40
+ return callback(null, {
41
+ author: {
42
+ type: resData.data.nodes[0].story_bucket_owner.__typename,
43
+ name: resData.data.nodes[0].story_bucket_owner.name,
44
+ uid: resData.data.nodes[0].story_bucket_owner.id,
45
+ urlProfile: resData.data.nodes[0].story_bucket_owner.url
46
+ },
47
+ id: str.node.id,
48
+ metadata: {
49
+ count_react: str.node.story_card_info.feedback_summary.total_reaction_count
50
+ },
51
+ dataVideo: str.node.attachments[0].media
52
+ });
53
+ })
54
+ return returnPromise
55
+ }
56
+ return async function getInfoVideo(videoURL, callback) {
57
+ var resolveFunc = function () { };
58
+ var rejectFunc = function () { };
59
+ var returnPromise = new Promise(function (resolve, reject) {
60
+ resolveFunc = resolve;
61
+ rejectFunc = reject;
62
+ });
63
+
64
+ if (!callback) {
65
+ callback = function (err, data) {
66
+ if (err) return rejectFunc(err);
67
+ resolveFunc(data);
68
+ };
69
+ }
70
+ if(videoURL.indexOf('stories') !== -1) return await downloadStory(videoURL);
71
+ videoURL = videoURL.match(/\/(?:videos|reel|watch)(?:\/?)(?:\?v=)?(\d+)/);
72
+ if (videoURL.length < 2) {
73
+ return callback(new Error("Invalid video URL"));
74
+ }
75
+ var form = {
76
+ av: ctx.userID,
77
+ server_timestamps: true,
78
+ doc_id: "5279476072161634",
79
+ variables: JSON.stringify({
80
+ UFI2CommentsProvider_commentsKey: 'CometTahoeSidePaneQuery',
81
+ caller: 'CHANNEL_VIEW_FROM_PAGE_TIMELINE',
82
+ displayCommentsContextEnableComment: null,
83
+ displayCommentsContextIsAdPreview: null,
84
+ displayCommentsContextIsAggregatedShare: null,
85
+ displayCommentsContextIsStorySet: null,
86
+ displayCommentsFeedbackContext: null,
87
+ feedbackSource: 41,
88
+ feedLocation: 'TAHOE',
89
+ focusCommentID: null,
90
+ privacySelectorRenderLocation: 'COMET_STREAM',
91
+ renderLocation: 'video_channel',
92
+ scale: 1,
93
+ streamChainingSection: false,
94
+ useDefaultActor: false,
95
+ videoChainingContext: null,
96
+ videoID: videoURL[1],
97
+ })
98
+ };
99
+ defaultFuncs
100
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
101
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
102
+ .then(function (resData) {
103
+ if (resData.errors) throw resData;
104
+ let a = resData[0];
105
+ let b = resData[12];
106
+ if(a.data.video == null) return callback('URL không hợp lệ');
107
+ resData = {
108
+ url: a.data.video.url || null,
109
+ id: a.data.video.videoId || null,
110
+ title: (b.data.tahoe_sidepane_renderer.video.creation_story.comet_sections.message != null) ? b.data.tahoe_sidepane_renderer.video.creation_story.comet_sections.message.story.message.text : 'Không có tiêu đề',
111
+ playable_duration_in_ms: a.data.video.playable_duration_in_ms || null,
112
+ author: {
113
+ type: b.data.tahoe_sidepane_renderer.video.owner.__typename || null,
114
+ id: b.data.tahoe_sidepane_renderer.video.owner.id || null,
115
+ name: b.data.tahoe_sidepane_renderer.video.owner.name || null
116
+ },
117
+ metadata: {
118
+ count_react: b.data.tahoe_sidepane_renderer.video.feedback.reaction_count.count || null,
119
+ count_share: b.data.tahoe_sidepane_renderer.video.feedback.share_count.count || null,
120
+ count_comment: b.data.tahoe_sidepane_renderer.video.feedback.comment_count.total_count || null
121
+ },
122
+ downloadVideo: {
123
+ SD: a.data.video.playable_url || null,
124
+ HD: a.data.video.playable_url_quality_hd || null
125
+ }
126
+ }
127
+ callback(null, resData);
128
+ })
129
+ .catch(function (err) {
130
+ callback(err);
131
+ });
132
+ return returnPromise;
133
+ }
134
+ }
@@ -0,0 +1,796 @@
1
+ "use strict";
2
+
3
+ // Original
4
+ /**
5
+ * @author https://github.com/Schmavery/facebook-chat-api/pull/865
6
+ */
7
+
8
+ const utils = require("../utils");
9
+ const log = require("npmlog");
10
+
11
+
12
+ function formatMessage(threadID, data) {
13
+ switch (data.__typename) {
14
+ case "ThreadNameMessage":
15
+ return {
16
+ type: "event",
17
+ threadID: threadID,
18
+ messageID: data.message_id,
19
+ logMessageType: "log:thread-name",
20
+ logMessageData: {
21
+ name: data.thread_name
22
+ },
23
+ logMessageBody: data.snippet,
24
+ timestamp: data.timestamp_precise,
25
+ author: data.message_sender.id
26
+ };
27
+ case "ThreadImageMessage":
28
+ const metadata = data.image_with_metadata;
29
+ return {
30
+ type: "event",
31
+ threadID: threadID,
32
+ messageID: data.message_id,
33
+ logMessageType: "log:thread-image",
34
+ logMessageData: metadata ? {
35
+ attachmentID: metadata.legacy_attachment_id,
36
+ width: metadata.original_dimensions.x,
37
+ height: metadata.original_dimensions.y,
38
+ url: metadata.preview.uri
39
+ } :
40
+ {
41
+ attachmentID: null,
42
+ width: null,
43
+ height: null,
44
+ url: null
45
+ },
46
+ logMessageBody: data.snippet,
47
+ timestamp: data.timestamp_precise,
48
+ author: data.message_sender.id
49
+ };
50
+ case "GenericAdminTextMessage":
51
+ switch (data.extensible_message_admin_text_type) {
52
+ case "CHANGE_THREAD_THEME":
53
+ return {
54
+ type: "event",
55
+ threadID: threadID,
56
+ messageID: data.message_id,
57
+ logMessageType: "log:thread-color",
58
+ logMessageData: colors.find(color => color.theme_color === data.extensible_message_admin_text.theme_color) || {
59
+ theme_color: data.extensible_message_admin_text.theme_color,
60
+ theme_id: null,
61
+ theme_emoji: null,
62
+ gradient: null,
63
+ should_show_icon: null,
64
+ theme_name_with_subtitle: null
65
+ },
66
+ logMessageBody: data.snippet,
67
+ timestamp: data.timestamp_precise,
68
+ author: data.message_sender.id
69
+ };
70
+ case "CHANGE_THREAD_ICON":
71
+ const thread_icon = data.extensible_message_admin_text.thread_icon;
72
+ return {
73
+ type: "event",
74
+ threadID: threadID,
75
+ messageID: data.message_id,
76
+ logMessageType: "log:thread-icon",
77
+ logMessageData: {
78
+ thread_icon_url: `https://static.xx.fbcdn.net/images/emoji.php/v9/t3c/1/16/${thread_icon.codePointAt(0).toString(16)}.png`,
79
+ thread_icon: thread_icon
80
+ },
81
+ logMessageBody: data.snippet,
82
+ timestamp: data.timestamp_precise,
83
+ author: data.message_sender.id
84
+ };
85
+ case "CHANGE_THREAD_NICKNAME":
86
+ return {
87
+ type: "event",
88
+ threadID: threadID,
89
+ messageID: data.message_id,
90
+ logMessageType: "log:user-nickname",
91
+ logMessageData: {
92
+ nickname: data.extensible_message_admin_text.nickname,
93
+ participant_id: data.extensible_message_admin_text.participant_id
94
+ },
95
+ logMessageBody: data.snippet,
96
+ timestamp: data.timestamp_precise,
97
+ author: data.message_sender.id
98
+ };
99
+ case "GROUP_POLL":
100
+ const question = data.extensible_message_admin_text.question;
101
+ return {
102
+ type: "event",
103
+ threadID: threadID,
104
+ messageID: data.message_id,
105
+ logMessageType: "log:thread-poll",
106
+ logMessageData: {
107
+ question_json: JSON.stringify({
108
+ id: question.id,
109
+ text: question.text,
110
+ total_count: data.extensible_message_admin_text.total_count,
111
+ viewer_has_voted: question.viewer_has_voted,
112
+ question_type: "",
113
+ creator_id: data.message_sender.id,
114
+ options: question.options.nodes.map(option => ({
115
+ id: option.id,
116
+ text: option.text,
117
+ total_count: option.voters.nodes.length,
118
+ viewer_has_voted: option.viewer_has_voted,
119
+ voters: option.voters.nodes.map(voter => voter.id)
120
+ }))
121
+ }),
122
+ event_type: data.extensible_message_admin_text.event_type.toLowerCase(),
123
+ question_id: question.id
124
+ },
125
+ logMessageBody: data.snippet,
126
+ timestamp: data.timestamp_precise,
127
+ author: data.message_sender.id
128
+ };
129
+ default:
130
+ throw new Error(`Unknown admin text type: "${data.extensible_message_admin_text_type}", if this happens to you let me know when it happens. Please open an issue at https://github.com/ntkhang03/fb-chat-api/issues.`);
131
+ }
132
+ case "UserMessage":
133
+ return {
134
+ senderID: data.message_sender.id,
135
+ body: data.message.text,
136
+ threadID: threadID,
137
+ messageID: data.message_id,
138
+ reactions: data.message_reactions.map(r => ({
139
+ [r.user.id]: r.reaction
140
+ })),
141
+ attachments: data.blob_attachments && data.blob_attachments.length > 0 ?
142
+ data.blob_attachments.length.map(att => {
143
+ let x;
144
+ try {
145
+ x = utils._formatAttachment(att);
146
+ } catch (ex) {
147
+ x = att;
148
+ x.error = ex;
149
+ x.type = "unknown";
150
+ }
151
+ return x;
152
+ }) :
153
+ data.extensible_attachment && Object.keys(data.extensible_attachment).length > 0 ?
154
+ [{
155
+ type: "share",
156
+ ID: data.extensible_attachment.legacy_attachment_id,
157
+ url: data.extensible_attachment.story_attachment.url,
158
+
159
+ title: data.extensible_attachment.story_attachment.title_with_entities.text,
160
+ description: data.extensible_attachment.story_attachment.description.text,
161
+ source: data.extensible_attachment.story_attachment.source,
162
+
163
+ image: ((data.extensible_attachment.story_attachment.media || {}).image || {}).uri,
164
+ width: ((data.extensible_attachment.story_attachment.media || {}).image || {}).width,
165
+ height: ((data.extensible_attachment.story_attachment.media || {}).image || {}).height,
166
+ playable: (data.extensible_attachment.story_attachment.media || {}).is_playable || false,
167
+ duration: (data.extensible_attachment.story_attachment.media || {}).playable_duration_in_ms || 0,
168
+
169
+ subattachments: data.extensible_attachment.subattachments,
170
+ properties: data.extensible_attachment.story_attachment.properties
171
+ }] :
172
+ [],
173
+ mentions: data.message.ranges.map(mention => ({
174
+ [mention.entity.id]: data.message.text.substring(mention.offset, mention.offset + mention.length)
175
+ })),
176
+ timestamp: data.timestamp_precise
177
+ };
178
+ default:
179
+ throw new Error(`Unknown message type: "${data.__typename}", if this happens to you let me know when it happens. Please open an issue at https://github.com/ntkhang03/fb-chat-api/issues.`);
180
+ // If this happens to you let me know when it happens
181
+ // Please open an issue at https://github.com/ntkhang03/fb-chat-api/issues.
182
+ // return Object.assign({ type: "unknown", data });
183
+ }
184
+ }
185
+
186
+
187
+ function parseDelta(threadID, delta) {
188
+ if (delta.replied_to_message) {
189
+ return Object.assign({
190
+ type: "message_reply"
191
+ }, formatMessage(threadID, delta), {
192
+ messageReply: formatMessage(threadID, delta.replied_to_message.message)
193
+ });
194
+ }
195
+ else {
196
+ return formatMessage(threadID, delta);
197
+ }
198
+ }
199
+
200
+
201
+ module.exports = function (defaultFuncs, api, ctx) {
202
+ return function getMessage(threadID, messageID, callback) {
203
+ let resolveFunc = function () { };
204
+ let rejectFunc = function () { };
205
+ const returnPromise = new Promise(function (resolve, reject) {
206
+ resolveFunc = resolve;
207
+ rejectFunc = reject;
208
+ });
209
+
210
+ if (!callback) {
211
+ callback = function (err, info) {
212
+ if (err)
213
+ return rejectFunc(err);
214
+ resolveFunc(info);
215
+ };
216
+ }
217
+
218
+ if (!threadID || !messageID) {
219
+ return callback({ error: "getMessage: need threadID and messageID" });
220
+ }
221
+
222
+ const form = {
223
+ "av": ctx.globalOptions.pageID,
224
+ "queries": JSON.stringify({
225
+ "o0": {
226
+ //This doc_id is valid as of ? (prob January 18, 2020)
227
+ "doc_id": "1768656253222505",
228
+ "query_params": {
229
+ "thread_and_message_id": {
230
+ "thread_id": threadID,
231
+ "message_id": messageID
232
+ }
233
+ }
234
+ }
235
+ })
236
+ };
237
+
238
+ defaultFuncs
239
+ .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
240
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
241
+ .then((resData) => {
242
+ if (resData[resData.length - 1].error_results > 0) {
243
+ throw resData[0].o0.errors;
244
+ }
245
+
246
+ if (resData[resData.length - 1].successful_results === 0) {
247
+ throw { error: "getMessage: there was no successful_results", res: resData };
248
+ }
249
+
250
+ const fetchData = resData[0].o0.data.message;
251
+ if (fetchData) {
252
+ callback(null, parseDelta(threadID, fetchData));
253
+ }
254
+ else {
255
+ throw fetchData;
256
+ }
257
+ })
258
+ .catch((err) => {
259
+ log.error("getMessage", err);
260
+ callback(err);
261
+ });
262
+
263
+ return returnPromise;
264
+ };
265
+ };
266
+
267
+ const colors = [
268
+ {
269
+ theme_color: 'FF000000',
270
+ theme_id: '788274591712841',
271
+ theme_emoji: '🖤',
272
+ gradient: '["FFF0F0F0"]',
273
+ should_show_icon: '',
274
+ theme_name_with_subtitle: 'Monochrome'
275
+ },
276
+ {
277
+ theme_color: 'FFFF5CA1',
278
+ theme_id: '169463077092846',
279
+ theme_emoji: null,
280
+ gradient: null,
281
+ should_show_icon: '1',
282
+ theme_name_with_subtitle: 'Hot Pink'
283
+ },
284
+ {
285
+ theme_color: 'FF2825B5',
286
+ theme_id: '271607034185782',
287
+ theme_emoji: null,
288
+ gradient: '["FF5E007E","FF331290","FF2825B5"]',
289
+ should_show_icon: '1',
290
+ theme_name_with_subtitle: 'Shadow'
291
+ },
292
+ {
293
+ theme_color: 'FFD9A900',
294
+ theme_id: '2533652183614000',
295
+ theme_emoji: null,
296
+ gradient: '["FF550029","FFAA3232","FFD9A900"]',
297
+ should_show_icon: '1',
298
+ theme_name_with_subtitle: 'Maple'
299
+ },
300
+ {
301
+ theme_color: 'FFFB45DE',
302
+ theme_id: '2873642949430623',
303
+ theme_emoji: null,
304
+ gradient: null,
305
+ should_show_icon: '1',
306
+ theme_name_with_subtitle: 'Tulip'
307
+ },
308
+ {
309
+ theme_color: 'FF5E007E',
310
+ theme_id: '193497045377796',
311
+ theme_emoji: null,
312
+ gradient: null,
313
+ should_show_icon: '1',
314
+ theme_name_with_subtitle: 'Grape'
315
+ },
316
+ {
317
+ theme_color: 'FF7AA286',
318
+ theme_id: '1455149831518874',
319
+ theme_emoji: '🌑',
320
+ gradient: '["FF25C0E1","FFCE832A"]',
321
+ should_show_icon: '',
322
+ theme_name_with_subtitle: 'Dune'
323
+ },
324
+ {
325
+ theme_color: 'FFFAAF00',
326
+ theme_id: '672058580051520',
327
+ theme_emoji: null,
328
+ gradient: null,
329
+ should_show_icon: '1',
330
+ theme_name_with_subtitle: 'Honey'
331
+ },
332
+ {
333
+ theme_color: 'FF0084FF',
334
+ theme_id: '196241301102133',
335
+ theme_emoji: null,
336
+ gradient: null,
337
+ should_show_icon: '1',
338
+ theme_name_with_subtitle: 'Default Blue'
339
+ },
340
+ {
341
+ theme_color: 'FFFFC300',
342
+ theme_id: '174636906462322',
343
+ theme_emoji: null,
344
+ gradient: null,
345
+ should_show_icon: '1',
346
+ theme_name_with_subtitle: 'Yellow'
347
+ },
348
+ {
349
+ theme_color: 'FF44BEC7',
350
+ theme_id: '1928399724138152',
351
+ theme_emoji: null,
352
+ gradient: null,
353
+ should_show_icon: '1',
354
+ theme_name_with_subtitle: 'Teal Blue'
355
+ },
356
+ {
357
+ theme_color: 'FF7646FF',
358
+ theme_id: '234137870477637',
359
+ theme_emoji: null,
360
+ gradient: null,
361
+ should_show_icon: '1',
362
+ theme_name_with_subtitle: 'Bright Purple'
363
+ },
364
+ {
365
+ theme_color: 'FFF25C54',
366
+ theme_id: '3022526817824329',
367
+ theme_emoji: null,
368
+ gradient: null,
369
+ should_show_icon: '1',
370
+ theme_name_with_subtitle: 'Peach'
371
+ },
372
+ {
373
+ theme_color: 'FFF01D6A',
374
+ theme_id: '724096885023603',
375
+ theme_emoji: null,
376
+ gradient: '["FF005FFF","FF9200FF","FFFF2E19"]',
377
+ should_show_icon: '1',
378
+ theme_name_with_subtitle: 'Berry'
379
+ },
380
+ {
381
+ theme_color: 'FFFF7CA8',
382
+ theme_id: '624266884847972',
383
+ theme_emoji: null,
384
+ gradient: '["FFFF8FB2","FFA797FF","FF00E5FF"]',
385
+ should_show_icon: '1',
386
+ theme_name_with_subtitle: 'Candy'
387
+ },
388
+ {
389
+ theme_color: 'FF6E5B04',
390
+ theme_id: '365557122117011',
391
+ theme_emoji: '💛',
392
+ gradient: '["FFED9F9A","FFED9F9A","FFED9F9A"]',
393
+ should_show_icon: '',
394
+ theme_name_with_subtitle: 'Support'
395
+ },
396
+ {
397
+ theme_color: 'FF0052CD',
398
+ theme_id: '230032715012014',
399
+ theme_emoji: '✌️',
400
+ gradient: '["FF0052CD","FF00A1E6","FF0052CD"]',
401
+ should_show_icon: '',
402
+ theme_name_with_subtitle: 'Tie-Dye'
403
+ },
404
+ {
405
+ theme_color: 'FF601DDD',
406
+ theme_id: '1060619084701625',
407
+ theme_emoji: '☁️',
408
+ gradient: '["FFCA34FF","FF302CFF","FFBA009C"]',
409
+ should_show_icon: '',
410
+ theme_name_with_subtitle: 'Lo-Fi'
411
+ },
412
+ {
413
+ theme_color: 'FF0099FF',
414
+ theme_id: '3273938616164733',
415
+ theme_emoji: null,
416
+ gradient: null,
417
+ should_show_icon: '1',
418
+ theme_name_with_subtitle: 'Classic'
419
+ },
420
+ {
421
+ theme_color: 'FF1ADB5B',
422
+ theme_id: '370940413392601',
423
+ theme_emoji: null,
424
+ gradient: '["FFFFD200","FF6EDF00","FF00DFBB"]',
425
+ should_show_icon: '1',
426
+ theme_name_with_subtitle: 'Citrus'
427
+ },
428
+ {
429
+ theme_color: 'FFD696BB',
430
+ theme_id: '2058653964378557',
431
+ theme_emoji: null,
432
+ gradient: null,
433
+ should_show_icon: '1',
434
+ theme_name_with_subtitle: 'Lavender Purple'
435
+ },
436
+ {
437
+ theme_color: 'FFC03232',
438
+ theme_id: '1059859811490132',
439
+ theme_emoji: '🙃',
440
+ gradient: '["FFDB4040","FFA32424"]',
441
+ should_show_icon: '',
442
+ theme_name_with_subtitle: 'Stranger Things'
443
+ },
444
+ {
445
+ theme_color: 'FFFA3C4C',
446
+ theme_id: '2129984390566328',
447
+ theme_emoji: null,
448
+ gradient: null,
449
+ should_show_icon: '1',
450
+ theme_name_with_subtitle: 'Red'
451
+ },
452
+ {
453
+ theme_color: 'FF13CF13',
454
+ theme_id: '2136751179887052',
455
+ theme_emoji: null,
456
+ gradient: null,
457
+ should_show_icon: '1',
458
+ theme_name_with_subtitle: 'Green'
459
+ },
460
+ {
461
+ theme_color: 'FFFF7E29',
462
+ theme_id: '175615189761153',
463
+ theme_emoji: null,
464
+ gradient: null,
465
+ should_show_icon: '1',
466
+ theme_name_with_subtitle: 'Orange'
467
+ },
468
+ {
469
+ theme_color: 'FFE68585',
470
+ theme_id: '980963458735625',
471
+ theme_emoji: null,
472
+ gradient: null,
473
+ should_show_icon: '1',
474
+ theme_name_with_subtitle: 'Coral Pink'
475
+ },
476
+ {
477
+ theme_color: 'FF20CEF5',
478
+ theme_id: '2442142322678320',
479
+ theme_emoji: null,
480
+ gradient: null,
481
+ should_show_icon: '1',
482
+ theme_name_with_subtitle: 'Aqua Blue'
483
+ },
484
+ {
485
+ theme_color: 'FF0EDCDE',
486
+ theme_id: '417639218648241',
487
+ theme_emoji: null,
488
+ gradient: '["FF19C9FF","FF00E6D2","FF0EE6B7"]',
489
+ should_show_icon: '1',
490
+ theme_name_with_subtitle: 'Aqua'
491
+ },
492
+ {
493
+ theme_color: 'FFFF9C19',
494
+ theme_id: '930060997172551',
495
+ theme_emoji: null,
496
+ gradient: '["FFFFDC2D","FFFF9616","FFFF4F00"]',
497
+ should_show_icon: '1',
498
+ theme_name_with_subtitle: 'Mango'
499
+ },
500
+ {
501
+ theme_color: 'FFF01D6A',
502
+ theme_id: '164535220883264',
503
+ theme_emoji: null,
504
+ gradient: '["FF005FFF","FF9200FF","FFFF2E19"]',
505
+ should_show_icon: '1',
506
+ theme_name_with_subtitle: 'Berry'
507
+ },
508
+ {
509
+ theme_color: 'FFFF7CA8',
510
+ theme_id: '205488546921017',
511
+ theme_emoji: null,
512
+ gradient: '["FFFF8FB2","FFA797FF","FF00E5FF"]',
513
+ should_show_icon: '1',
514
+ theme_name_with_subtitle: 'Candy'
515
+ },
516
+ {
517
+ theme_color: 'FFFF6F07',
518
+ theme_id: '1833559466821043',
519
+ theme_emoji: '🌎',
520
+ gradient: '["FFFF6F07"]',
521
+ should_show_icon: '',
522
+ theme_name_with_subtitle: 'Earth'
523
+ },
524
+ {
525
+ theme_color: 'FF0B0085',
526
+ theme_id: '339021464972092',
527
+ theme_emoji: '🔈',
528
+ gradient: '["FF2FA9E4","FF648FEB","FF9B73F2"]',
529
+ should_show_icon: '',
530
+ theme_name_with_subtitle: 'Music'
531
+ },
532
+ {
533
+ theme_color: 'FF8A39EF',
534
+ theme_id: '1652456634878319',
535
+ theme_emoji: '🏳️‍🌈',
536
+ gradient: '["FFFF0018","FFFF0417","FFFF310E","FFFF5D06","FFFF7A01","FFFF8701","FFFFB001","FFD9C507","FF79C718","FF01C92D","FF01BE69","FF01B3AA","FF0BA1DF","FF3F77E6","FF724CEC","FF8A39EF","FF8A39EF"]',
537
+ should_show_icon: '',
538
+ theme_name_with_subtitle: 'Pride'
539
+ },
540
+ {
541
+ theme_color: 'FF004D7C',
542
+ theme_id: '538280997628317',
543
+ theme_emoji: '🌀',
544
+ gradient: '["FF931410","FF931410","FF931410"]',
545
+ should_show_icon: '',
546
+ theme_name_with_subtitle: 'Doctor Strange'
547
+ },
548
+ {
549
+ theme_color: 'FF4F4DFF',
550
+ theme_id: '3190514984517598',
551
+ theme_emoji: '🌤',
552
+ gradient: '["FF0080FF","FF9F1AFF"]',
553
+ should_show_icon: '',
554
+ theme_name_with_subtitle: 'Sky'
555
+ },
556
+ {
557
+ theme_color: 'FFE84B28',
558
+ theme_id: '357833546030778',
559
+ theme_emoji: '🐯',
560
+ gradient: '["FFF69500","FFDA0050"]',
561
+ should_show_icon: '1',
562
+ theme_name_with_subtitle: 'Lunar New Year'
563
+ },
564
+ {
565
+ theme_color: 'FFB24B77',
566
+ theme_id: '627144732056021',
567
+ theme_emoji: '🥳',
568
+ gradient: '["FFF1614E","FF660F84"]',
569
+ should_show_icon: '',
570
+ theme_name_with_subtitle: 'Celebration!'
571
+ },
572
+ {
573
+ theme_color: 'FF66A9FF',
574
+ theme_id: '390127158985345',
575
+ theme_emoji: '🥶',
576
+ gradient: '["FF8CB3FF","FF409FFF"]',
577
+ should_show_icon: '',
578
+ theme_name_with_subtitle: 'Chill'
579
+ },
580
+ {
581
+ theme_color: 'FF5797FC',
582
+ theme_id: '275041734441112',
583
+ theme_emoji: '😌',
584
+ gradient: '["FF4AC9E4","FF5890FF","FF8C91FF"]',
585
+ should_show_icon: '',
586
+ theme_name_with_subtitle: 'Care'
587
+ },
588
+ {
589
+ theme_color: 'FFFF595C',
590
+ theme_id: '3082966625307060',
591
+ theme_emoji: '💫',
592
+ gradient: '["FFFF239A","FFFF8C21"]',
593
+ should_show_icon: '',
594
+ theme_name_with_subtitle: 'Astrology'
595
+ },
596
+ {
597
+ theme_color: 'FF0171FF',
598
+ theme_id: '184305226956268',
599
+ theme_emoji: '☁️',
600
+ gradient: '["FF0026ee","FF00b2ff"]',
601
+ should_show_icon: '',
602
+ theme_name_with_subtitle: 'J Balvin'
603
+ },
604
+ {
605
+ theme_color: 'FFA033FF',
606
+ theme_id: '621630955405500',
607
+ theme_emoji: '🎉',
608
+ gradient: '["FFFF7061","FFFF5280","FFA033FF","FF0099FF"]',
609
+ should_show_icon: '',
610
+ theme_name_with_subtitle: 'Birthday'
611
+ },
612
+ {
613
+ theme_color: 'FF006528',
614
+ theme_id: '539927563794799',
615
+ theme_emoji: '🍄',
616
+ gradient: '["FF00d52f","FF006528"]',
617
+ should_show_icon: '',
618
+ theme_name_with_subtitle: 'Cottagecore'
619
+ },
620
+ {
621
+ theme_color: 'FF4D3EC2',
622
+ theme_id: '736591620215564',
623
+ theme_emoji: null,
624
+ gradient: null,
625
+ should_show_icon: '1',
626
+ theme_name_with_subtitle: 'Ocean'
627
+ },
628
+ {
629
+ theme_color: 'FF4e4bf5',
630
+ theme_id: '3259963564026002',
631
+ theme_emoji: null,
632
+ gradient: '["FFAA00FF","FF0080FF"]',
633
+ should_show_icon: '1',
634
+ theme_name_with_subtitle: 'Default'
635
+ },
636
+ {
637
+ theme_color: 'FF3A12FF',
638
+ theme_id: '582065306070020',
639
+ theme_emoji: null,
640
+ gradient: '["FFFAAF00","FFFF2E2E","FF3A12FF"]',
641
+ should_show_icon: '1',
642
+ theme_name_with_subtitle: 'Rocket'
643
+ },
644
+ {
645
+ theme_color: 'FF3A1D8A',
646
+ theme_id: '273728810607574',
647
+ theme_emoji: null,
648
+ gradient: '["FFFB45DE","FF841DD5","FF3A1D8A"]',
649
+ should_show_icon: '1',
650
+ theme_name_with_subtitle: 'Unicorn'
651
+ },
652
+ {
653
+ theme_color: 'FF9FD52D',
654
+ theme_id: '262191918210707',
655
+ theme_emoji: null,
656
+ gradient: '["FF2A7FE3","FF00BF91","FF9FD52D"]',
657
+ should_show_icon: '1',
658
+ theme_name_with_subtitle: 'Tropical'
659
+ },
660
+ {
661
+ theme_color: 'FFF7B267',
662
+ theme_id: '909695489504566',
663
+ theme_emoji: null,
664
+ gradient: '["FFF25C54","FFF4845F","FFF7B267"]',
665
+ should_show_icon: '1',
666
+ theme_name_with_subtitle: 'Sushi'
667
+ },
668
+ {
669
+ theme_color: 'FF1ADB5B',
670
+ theme_id: '557344741607350',
671
+ theme_emoji: null,
672
+ gradient: '["FFFFD200","FF6EDF00","FF00DFBB"]',
673
+ should_show_icon: '1',
674
+ theme_name_with_subtitle: 'Citrus'
675
+ },
676
+ {
677
+ theme_color: 'FF4D3EC2',
678
+ theme_id: '280333826736184',
679
+ theme_emoji: null,
680
+ gradient: '["FFFF625B","FFC532AD","FF4D3EC2"]',
681
+ should_show_icon: '1',
682
+ theme_name_with_subtitle: 'Lollipop'
683
+ },
684
+ {
685
+ theme_color: 'FFFF311E',
686
+ theme_id: '1257453361255152',
687
+ theme_emoji: null,
688
+ gradient: null,
689
+ should_show_icon: '1',
690
+ theme_name_with_subtitle: 'Rose'
691
+ },
692
+ {
693
+ theme_color: 'FFA797FF',
694
+ theme_id: '571193503540759',
695
+ theme_emoji: null,
696
+ gradient: null,
697
+ should_show_icon: '1',
698
+ theme_name_with_subtitle: 'Lavender'
699
+ },
700
+ {
701
+ theme_color: 'FF6EDF00',
702
+ theme_id: '3151463484918004',
703
+ theme_emoji: null,
704
+ gradient: null,
705
+ should_show_icon: '1',
706
+ theme_name_with_subtitle: 'Kiwi'
707
+ },
708
+ {
709
+ theme_color: 'FF9D59D2',
710
+ theme_id: '737761000603635',
711
+ theme_emoji: '💛',
712
+ gradient: '["FFFFD600","FFFCB37B","FF9D59D2","FF282828"]',
713
+ should_show_icon: '',
714
+ theme_name_with_subtitle: 'Non-Binary'
715
+ },
716
+ {
717
+ theme_color: 'FF57C39C',
718
+ theme_id: '1288506208402340',
719
+ theme_emoji: '💐',
720
+ gradient: '["FF57C39C","FF57C39C","FF57C39C"]',
721
+ should_show_icon: '',
722
+ theme_name_with_subtitle: 'Mother\'s Day'
723
+ },
724
+ {
725
+ theme_color: 'FFF65900',
726
+ theme_id: '121771470870245',
727
+ theme_emoji: '💥',
728
+ gradient: '["FFFF8328","FFFF7014","FFFF5C00"]',
729
+ should_show_icon: '',
730
+ theme_name_with_subtitle: 'APAHM'
731
+ },
732
+ {
733
+ theme_color: 'FF978E21',
734
+ theme_id: '810978360551741',
735
+ theme_emoji: '🪺',
736
+ gradient: '["FF978E21","FF978E21","FF978E21"]',
737
+ should_show_icon: '',
738
+ theme_name_with_subtitle: 'Parenthood'
739
+ },
740
+ {
741
+ theme_color: 'FFDD8800',
742
+ theme_id: '1438011086532622',
743
+ theme_emoji: '✨',
744
+ gradient: '["FFEDAB00","FFCD6300"]',
745
+ should_show_icon: '',
746
+ theme_name_with_subtitle: 'Star Wars'
747
+ },
748
+ {
749
+ theme_color: 'FF7D09B9',
750
+ theme_id: '101275642962533',
751
+ theme_emoji: '🚀',
752
+ gradient: '["FF5C22D6","FF8F1EB5","FFC31B92"]',
753
+ should_show_icon: '',
754
+ theme_name_with_subtitle: 'Guardians of the Galaxy'
755
+ },
756
+ {
757
+ theme_color: 'FF61C500',
758
+ theme_id: '158263147151440',
759
+ theme_emoji: '🐝',
760
+ gradient: '["FF61C500","FF61C500","FF61C500"]',
761
+ should_show_icon: '',
762
+ theme_name_with_subtitle: 'Bloom'
763
+ },
764
+ {
765
+ theme_color: 'FF826044',
766
+ theme_id: '195296273246380',
767
+ theme_emoji: '🧋',
768
+ gradient: '["FF886546","FFA27F57","FFC6A26E"]',
769
+ should_show_icon: '',
770
+ theme_name_with_subtitle: 'Bubble Tea'
771
+ },
772
+ {
773
+ theme_color: 'FFB02501',
774
+ theme_id: '6026716157422736',
775
+ theme_emoji: '⛹️',
776
+ gradient: '["FFAC2503","FFB02501","FFB42400"]',
777
+ should_show_icon: '',
778
+ theme_name_with_subtitle: 'Basketball'
779
+ },
780
+ {
781
+ theme_color: 'FF574DC1',
782
+ theme_id: '693996545771691',
783
+ theme_emoji: '🖤',
784
+ gradient: '["FF4533FF","FF574AE0","FF6C64BE"]',
785
+ should_show_icon: '',
786
+ theme_name_with_subtitle: 'Elephants&Flowers'
787
+ },
788
+ {
789
+ theme_color: 'FFA8B8DA',
790
+ theme_id: '504518465021637',
791
+ theme_emoji: '🏳️‍⚧️',
792
+ gradient: '["FF55D0FF","FF7597D7","FFFF9FB3","FFFF9FB3"]',
793
+ should_show_icon: '',
794
+ theme_name_with_subtitle: 'Transgender'
795
+ }
796
+ ];
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+
7
+ module.exports = function(defaultFuncs, api, ctx) {
8
+
9
+ return function httpPostFormData(url, form, callback) {
10
+ var resolveFunc = function(){};
11
+ var rejectFunc = function(){};
12
+
13
+ var returnPromise = new Promise(function (resolve, reject) {
14
+ resolveFunc = resolve;
15
+ rejectFunc = reject;
16
+ });
17
+
18
+ if (!callback && (utils.getType(form) == "Function" || utils.getType(form) == "AsyncFunction")) {
19
+ callback = form;
20
+ form = {};
21
+ }
22
+
23
+ form = form || {};
24
+
25
+ callback = callback || function(err, data) {
26
+ if (err) return rejectFunc(err);
27
+ resolveFunc(data);
28
+ };
29
+
30
+ defaultFuncs
31
+ .postFormData(url, ctx.jar, form)
32
+ .then(function(resData) {
33
+ callback(null, resData.body.toString());
34
+ })
35
+ .catch(function(err) {
36
+ log.error("httpPostFormData", err);
37
+ return callback(err);
38
+ });
39
+
40
+ return returnPromise;
41
+ };
42
+ };
@@ -0,0 +1,96 @@
1
+ const utils = require("../utils");
2
+ const log = require("npmlog");
3
+ const bluebird = require("bluebird");
4
+
5
+ module.exports = function (defaultFuncs, api, ctx) {
6
+ function upload(attachments, callback) {
7
+ callback = callback || function () { };
8
+ const uploads = [];
9
+
10
+ // create an array of promises
11
+ for (let i = 0; i < attachments.length; i++) {
12
+ if (!utils.isReadableStream(attachments[i])) {
13
+ throw {
14
+ error:
15
+ "Attachment should be a readable stream and not " +
16
+ utils.getType(attachments[i]) +
17
+ "."
18
+ };
19
+ }
20
+
21
+ const form = {
22
+ upload_1024: attachments[i],
23
+ voice_clip: "true"
24
+ };
25
+
26
+ uploads.push(
27
+ defaultFuncs
28
+ .postFormData(
29
+ "https://upload.facebook.com/ajax/mercury/upload.php",
30
+ ctx.jar,
31
+ form,
32
+ {}
33
+ )
34
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
35
+ .then(function (resData) {
36
+ if (resData.error) {
37
+ throw resData;
38
+ }
39
+
40
+ // We have to return the data unformatted unless we want to change it
41
+ // back in sendMessage.
42
+ return resData.payload.metadata[0];
43
+ })
44
+ );
45
+ }
46
+
47
+ // resolve all promises
48
+ bluebird
49
+ .all(uploads)
50
+ .then(function (resData) {
51
+ callback(null, resData);
52
+ })
53
+ .catch(function (err) {
54
+ log.error("uploadAttachment", err);
55
+ return callback(err);
56
+ });
57
+ }
58
+
59
+ return function uploadAttachment(attachments, callback) {
60
+ if (
61
+ !attachments &&
62
+ !utils.isReadableStream(attachments) &&
63
+ !utils.getType(attachments) === "Array" &&
64
+ (utils.getType(attachments) === "Array" && !attachments.length)
65
+ )
66
+ throw { error: "Please pass an attachment or an array of attachments." };
67
+
68
+ let resolveFunc = function () { };
69
+ let rejectFunc = function () { };
70
+ const returnPromise = new Promise(function (resolve, reject) {
71
+ resolveFunc = resolve;
72
+ rejectFunc = reject;
73
+ });
74
+
75
+ if (!callback) {
76
+ callback = function (err, info) {
77
+ if (err) {
78
+ return rejectFunc(err);
79
+ }
80
+ resolveFunc(info);
81
+ };
82
+ }
83
+
84
+ if (utils.getType(attachments) !== "Array")
85
+ attachments = [attachments];
86
+
87
+ upload(attachments, (err, info) => {
88
+ if (err) {
89
+ return callback(err);
90
+ }
91
+ callback(null, info);
92
+ });
93
+
94
+ return returnPromise;
95
+ };
96
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alicezetion",
3
- "version": "1.8.1",
3
+ "version": "1.8.3",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "start": "node index.js"