stfca 1.0.1 → 1.0.3

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.
Files changed (141) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +45 -2
  3. package/checkUpdate.js +109 -0
  4. package/index.js +460 -1
  5. package/package.json +22 -46
  6. package/src/{api/action/addExternalModule.js → addExternalModule.js} +25 -25
  7. package/src/addUserToGroup.js +115 -0
  8. package/src/changeAdminStatus.js +103 -0
  9. package/src/changeArchivedStatus.js +55 -0
  10. package/src/{api/action/changeAvatar.js → changeAvatar.js} +136 -137
  11. package/src/changeAvatarV2.js +86 -0
  12. package/src/changeAvt.js +85 -0
  13. package/src/{api/action/changeBio.js → changeBio.js} +76 -75
  14. package/src/{api/messaging/changeBlockedStatus.js → changeBlockedStatus.js} +49 -48
  15. package/src/changeBlockedStatusMqtt.js +80 -0
  16. package/src/changeCover.js +72 -0
  17. package/src/changeGroupImage.js +135 -0
  18. package/src/changeName.js +79 -0
  19. package/src/changeNickname.js +59 -0
  20. package/src/changeThreadColor.js +65 -0
  21. package/src/changeThreadEmoji.js +55 -0
  22. package/src/changeUsername.js +59 -0
  23. package/src/createCommentPost.js +230 -0
  24. package/src/{api/messaging/createNewGroup.js → createNewGroup.js} +88 -88
  25. package/src/createPoll.js +71 -0
  26. package/src/createPost.js +276 -0
  27. package/src/{api/messaging/deleteMessage.js → deleteMessage.js} +56 -56
  28. package/src/{api/messaging/deleteThread.js → deleteThread.js} +56 -56
  29. package/src/editMessage.js +68 -0
  30. package/src/editMessageOld.js +67 -0
  31. package/src/follow.js +74 -0
  32. package/src/forwardAttachment.js +60 -0
  33. package/src/getAccess.js +112 -0
  34. package/src/getAvatarUser.js +78 -0
  35. package/src/{api/action/getCurrentUserID.js → getCurrentUserID.js} +7 -7
  36. package/src/{api/messaging/getEmojiUrl.js → getEmojiUrl.js} +2 -2
  37. package/src/{api/messaging/getFriendsList.js → getFriendsList.js} +83 -82
  38. package/src/{api/messaging/getMessage.js → getMessage.js} +847 -829
  39. package/src/getRegion.js +7 -0
  40. package/src/{api/threads/getThreadHistory.js → getThreadHistory.js} +680 -664
  41. package/src/getThreadHistoryDeprecated.js +71 -0
  42. package/src/getThreadInfo.js +232 -0
  43. package/src/getThreadInfoDeprecated.js +56 -0
  44. package/src/getThreadList.js +213 -0
  45. package/src/getThreadListDeprecated.js +46 -0
  46. package/src/getThreadPictures.js +59 -0
  47. package/src/getUID.js +119 -0
  48. package/src/{api/users/getUserID.js → getUserID.js} +61 -65
  49. package/src/getUserInfo.js +66 -0
  50. package/src/handleFriendRequest.js +46 -0
  51. package/src/handleMessageRequest.js +47 -0
  52. package/src/httpGet.js +49 -0
  53. package/src/httpPost.js +48 -0
  54. package/src/listenMqtt.js +833 -0
  55. package/src/logout.js +75 -0
  56. package/src/markAsDelivered.js +47 -0
  57. package/src/markAsRead.js +70 -0
  58. package/src/markAsReadAll.js +40 -0
  59. package/src/markAsSeen.js +48 -0
  60. package/src/muteThread.js +45 -0
  61. package/src/refreshFb_dtsg.js +89 -0
  62. package/src/removeUserFromGroup.js +79 -0
  63. package/src/{api/messaging/resolvePhotoUrl.js → resolvePhotoUrl.js} +45 -43
  64. package/src/{api/messaging/searchForThread.js → searchForThread.js} +53 -52
  65. package/src/searchStickers.js +53 -0
  66. package/src/sendMessage.js +379 -0
  67. package/src/{api/messaging/sendMessageMqtt.js → sendMessageMqtt.js} +322 -323
  68. package/src/sendTypingIndicator.js +101 -0
  69. package/src/sendTypingIndicatorV2.js +28 -0
  70. package/src/setMessageReaction.js +122 -0
  71. package/src/setMessageReactionMqtt.js +62 -0
  72. package/src/{api/action/setPostReaction.js → setPostReaction.js} +112 -106
  73. package/src/setStoryReaction.js +64 -0
  74. package/src/setTitle.js +90 -0
  75. package/src/shareContact.js +110 -0
  76. package/src/shareLink.js +59 -0
  77. package/src/stopListenMqtt.js +23 -0
  78. package/src/{api/messaging/threadColors.js → threadColors.js} +131 -128
  79. package/src/{api/action/unfriend.js → unfriend.js} +52 -54
  80. package/src/unsendMessage.js +45 -0
  81. package/src/{api/messaging/uploadAttachment.js → uploadAttachment.js} +93 -95
  82. package/utils.js +2876 -0
  83. package/LICENSE-MIT +0 -4
  84. package/index.d.ts +0 -615
  85. package/module/config.js +0 -33
  86. package/module/login.js +0 -48
  87. package/module/loginHelper.js +0 -722
  88. package/module/options.js +0 -44
  89. package/src/api/action/handleFriendRequest.js +0 -57
  90. package/src/api/action/logout.js +0 -76
  91. package/src/api/action/refreshFb_dtsg.js +0 -71
  92. package/src/api/http/httpGet.js +0 -46
  93. package/src/api/http/httpPost.js +0 -52
  94. package/src/api/http/postFormData.js +0 -47
  95. package/src/api/messaging/addUserToGroup.js +0 -68
  96. package/src/api/messaging/changeAdminStatus.js +0 -122
  97. package/src/api/messaging/changeArchivedStatus.js +0 -55
  98. package/src/api/messaging/changeGroupImage.js +0 -90
  99. package/src/api/messaging/changeNickname.js +0 -70
  100. package/src/api/messaging/changeThreadColor.js +0 -79
  101. package/src/api/messaging/changeThreadEmoji.js +0 -106
  102. package/src/api/messaging/createPoll.js +0 -43
  103. package/src/api/messaging/editMessage.js +0 -68
  104. package/src/api/messaging/forwardAttachment.js +0 -51
  105. package/src/api/messaging/handleMessageRequest.js +0 -65
  106. package/src/api/messaging/markAsDelivered.js +0 -57
  107. package/src/api/messaging/markAsRead.js +0 -88
  108. package/src/api/messaging/markAsReadAll.js +0 -49
  109. package/src/api/messaging/markAsSeen.js +0 -61
  110. package/src/api/messaging/muteThread.js +0 -50
  111. package/src/api/messaging/removeUserFromGroup.js +0 -105
  112. package/src/api/messaging/sendMessage.js +0 -379
  113. package/src/api/messaging/sendTypingIndicator.js +0 -67
  114. package/src/api/messaging/setMessageReaction.js +0 -75
  115. package/src/api/messaging/setTitle.js +0 -119
  116. package/src/api/messaging/shareContact.js +0 -49
  117. package/src/api/messaging/unsendMessage.js +0 -81
  118. package/src/api/socket/core/connectMqtt.js +0 -179
  119. package/src/api/socket/core/getSeqID.js +0 -25
  120. package/src/api/socket/core/getTaskResponseData.js +0 -22
  121. package/src/api/socket/core/markDelivery.js +0 -12
  122. package/src/api/socket/core/parseDelta.js +0 -351
  123. package/src/api/socket/detail/buildStream.js +0 -208
  124. package/src/api/socket/detail/constants.js +0 -24
  125. package/src/api/socket/listenMqtt.js +0 -133
  126. package/src/api/threads/getThreadInfo.js +0 -358
  127. package/src/api/threads/getThreadList.js +0 -248
  128. package/src/api/threads/getThreadPictures.js +0 -78
  129. package/src/api/users/getUserInfo.js +0 -319
  130. package/src/api/users/getUserInfoV2.js +0 -133
  131. package/src/core/sendReqMqtt.js +0 -63
  132. package/src/database/models/index.js +0 -49
  133. package/src/database/models/thread.js +0 -31
  134. package/src/database/models/user.js +0 -32
  135. package/src/database/threadData.js +0 -98
  136. package/src/database/userData.js +0 -89
  137. package/src/utils/client.js +0 -214
  138. package/src/utils/constants.js +0 -23
  139. package/src/utils/format.js +0 -1111
  140. package/src/utils/headers.js +0 -41
  141. package/src/utils/request.js +0 -215
@@ -1,829 +1,847 @@
1
- "use strict";
2
-
3
- const log = require("npmlog");
4
- const { _formatAttachment } = require("../../utils/format");
5
- const { parseAndCheckLogin } = require("../../utils/client");
6
- function formatMessage(threadID, data) {
7
- switch (data.__typename) {
8
- case "ThreadNameMessage":
9
- return {
10
- type: "event",
11
- threadID: threadID,
12
- messageID: data.message_id,
13
- logMessageType: "log:thread-name",
14
- logMessageData: {
15
- name: data.thread_name
16
- },
17
- logMessageBody: data.snippet,
18
- timestamp: data.timestamp_precise,
19
- author: data.message_sender.id
20
- };
21
- case "ThreadImageMessage":
22
- const metadata = data.image_with_metadata;
23
- return {
24
- type: "event",
25
- threadID: threadID,
26
- messageID: data.message_id,
27
- logMessageType: "log:thread-image",
28
- logMessageData: metadata
29
- ? {
30
- attachmentID: metadata.legacy_attachment_id,
31
- width: metadata.original_dimensions.x,
32
- height: metadata.original_dimensions.y,
33
- url: metadata.preview.uri
34
- }
35
- : {
36
- attachmentID: null,
37
- width: null,
38
- height: null,
39
- url: null
40
- },
41
- logMessageBody: data.snippet,
42
- timestamp: data.timestamp_precise,
43
- author: data.message_sender.id
44
- };
45
- case "GenericAdminTextMessage":
46
- switch (data.extensible_message_admin_text_type) {
47
- case "CHANGE_THREAD_THEME":
48
- return {
49
- type: "event",
50
- threadID: threadID,
51
- messageID: data.message_id,
52
- logMessageType: "log:thread-color",
53
- logMessageData: colors.find(
54
- color =>
55
- color.theme_color ===
56
- data.extensible_message_admin_text.theme_color
57
- ) || {
58
- theme_color: data.extensible_message_admin_text.theme_color,
59
- theme_id: null,
60
- theme_emoji: null,
61
- gradient: null,
62
- should_show_icon: null,
63
- theme_name_with_subtitle: null
64
- },
65
- logMessageBody: data.snippet,
66
- timestamp: data.timestamp_precise,
67
- author: data.message_sender.id
68
- };
69
- case "CHANGE_THREAD_ICON":
70
- const thread_icon = data.extensible_message_admin_text.thread_icon;
71
- return {
72
- type: "event",
73
- threadID: threadID,
74
- messageID: data.message_id,
75
- logMessageType: "log:thread-icon",
76
- logMessageData: {
77
- thread_icon_url: `https://static.xx.fbcdn.net/images/emoji.php/v9/t3c/1/16/${thread_icon
78
- .codePointAt(0)
79
- .toString(16)}.png`,
80
- thread_icon: thread_icon
81
- },
82
- logMessageBody: data.snippet,
83
- timestamp: data.timestamp_precise,
84
- author: data.message_sender.id
85
- };
86
- case "CHANGE_THREAD_NICKNAME":
87
- return {
88
- type: "event",
89
- threadID: threadID,
90
- messageID: data.message_id,
91
- logMessageType: "log:user-nickname",
92
- logMessageData: {
93
- nickname: data.extensible_message_admin_text.nickname,
94
- participant_id: data.extensible_message_admin_text.participant_id
95
- },
96
- logMessageBody: data.snippet,
97
- timestamp: data.timestamp_precise,
98
- author: data.message_sender.id
99
- };
100
- case "GROUP_POLL":
101
- const question = data.extensible_message_admin_text.question;
102
- return {
103
- type: "event",
104
- threadID: threadID,
105
- messageID: data.message_id,
106
- logMessageType: "log:thread-poll",
107
- logMessageData: {
108
- question_json: JSON.stringify({
109
- id: question.id,
110
- text: question.text,
111
- total_count: data.extensible_message_admin_text.total_count,
112
- viewer_has_voted: question.viewer_has_voted,
113
- question_type: "",
114
- creator_id: data.message_sender.id,
115
- options: question.options.nodes.map(option => ({
116
- id: option.id,
117
- text: option.text,
118
- total_count: option.voters.nodes.length,
119
- viewer_has_voted: option.viewer_has_voted,
120
- voters: option.voters.nodes.map(voter => voter.id)
121
- }))
122
- }),
123
- event_type: data.extensible_message_admin_text.event_type.toLowerCase(),
124
- question_id: question.id
125
- },
126
- logMessageBody: data.snippet,
127
- timestamp: data.timestamp_precise,
128
- author: data.message_sender.id
129
- };
130
- default:
131
- throw new Error(
132
- `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.`
133
- );
134
- }
135
- case "UserMessage":
136
- return {
137
- senderID: data.message_sender.id,
138
- body: data.message.text,
139
- threadID: threadID,
140
- messageID: data.message_id,
141
- reactions: data.message_reactions.map(r => ({
142
- [r.user.id]: r.reaction
143
- })),
144
- attachments:
145
- data.blob_attachments && data.blob_attachments.length > 0
146
- ? data.blob_attachments.length.map(att => {
147
- let x;
148
- try {
149
- x = _formatAttachment(att);
150
- } catch (ex) {
151
- x = att;
152
- x.error = ex;
153
- x.type = "unknown";
154
- }
155
- return x;
156
- })
157
- : data.extensible_attachment &&
158
- Object.keys(data.extensible_attachment).length > 0
159
- ? [
160
- {
161
- type: "share",
162
- ID: data.extensible_attachment.legacy_attachment_id,
163
- url: data.extensible_attachment.story_attachment.url,
164
-
165
- title:
166
- data.extensible_attachment.story_attachment
167
- .title_with_entities.text,
168
- description:
169
- data.extensible_attachment.story_attachment.description
170
- .text,
171
- source: data.extensible_attachment.story_attachment.source,
172
-
173
- image: (
174
- (data.extensible_attachment.story_attachment.media || {})
175
- .image || {}
176
- ).uri,
177
- width: (
178
- (data.extensible_attachment.story_attachment.media || {})
179
- .image || {}
180
- ).width,
181
- height: (
182
- (data.extensible_attachment.story_attachment.media || {})
183
- .image || {}
184
- ).height,
185
- playable:
186
- (data.extensible_attachment.story_attachment.media || {})
187
- .is_playable || false,
188
- duration:
189
- (data.extensible_attachment.story_attachment.media || {})
190
- .playable_duration_in_ms || 0,
191
-
192
- subattachments: data.extensible_attachment.subattachments,
193
- properties:
194
- data.extensible_attachment.story_attachment.properties
195
- }
196
- ]
197
- : [],
198
- mentions: data.message.ranges.map(mention => ({
199
- [mention.entity.id]: data.message.text.substring(
200
- mention.offset,
201
- mention.offset + mention.length
202
- )
203
- })),
204
- timestamp: data.timestamp_precise
205
- };
206
- default:
207
- throw new Error(
208
- `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.`
209
- );
210
- // If this happens to you let me know when it happens
211
- // Please open an issue at https://github.com/ntkhang03/fb-chat-api/issues.
212
- // return Object.assign({ type: "unknown", data });
213
- }
214
- }
215
-
216
- function parseDelta(threadID, delta) {
217
- if (delta.replied_to_message) {
218
- return Object.assign(
219
- {
220
- type: "message_reply"
221
- },
222
- formatMessage(threadID, delta),
223
- {
224
- messageReply: formatMessage(threadID, delta.replied_to_message.message)
225
- }
226
- );
227
- } else {
228
- return formatMessage(threadID, delta);
229
- }
230
- }
231
-
232
- module.exports = function(defaultFuncs, api, ctx) {
233
- return function getMessage(threadID, messageID, callback) {
234
- let resolveFunc = function() {};
235
- let rejectFunc = function() {};
236
- const returnPromise = new Promise(function(resolve, reject) {
237
- resolveFunc = resolve;
238
- rejectFunc = reject;
239
- });
240
-
241
- if (!callback) {
242
- callback = function(err, info) {
243
- if (err) return rejectFunc(err);
244
- resolveFunc(info);
245
- };
246
- }
247
-
248
- if (!threadID || !messageID) {
249
- return callback({ error: "getMessage: need threadID and messageID" });
250
- }
251
-
252
- const form = {
253
- av: ctx.globalOptions.pageID,
254
- queries: JSON.stringify({
255
- o0: {
256
- //This doc_id is valid as of ? (prob January 18, 2020)
257
- doc_id: "1768656253222505",
258
- query_params: {
259
- thread_and_message_id: {
260
- thread_id: threadID,
261
- message_id: messageID
262
- }
263
- }
264
- }
265
- })
266
- };
267
-
268
- defaultFuncs
269
- .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
270
- .then(parseAndCheckLogin(ctx, defaultFuncs))
271
- .then(resData => {
272
- if (resData[resData.length - 1].error_results > 0) {
273
- throw resData[0].o0.errors;
274
- }
275
-
276
- if (resData[resData.length - 1].successful_results === 0) {
277
- throw {
278
- error: "getMessage: there was no successful_results",
279
- res: resData
280
- };
281
- }
282
-
283
- const fetchData = resData[0].o0.data.message;
284
- if (fetchData) {
285
- callback(null, parseDelta(threadID, fetchData));
286
- } else {
287
- throw fetchData;
288
- }
289
- })
290
- .catch(err => {
291
- log.error("getMessage", err);
292
- callback(err);
293
- });
294
-
295
- return returnPromise;
296
- };
297
- };
298
-
299
- const colors = [
300
- {
301
- theme_color: "FF000000",
302
- theme_id: "788274591712841",
303
- theme_emoji: "🖤",
304
- gradient: '["FFF0F0F0"]',
305
- should_show_icon: "",
306
- theme_name_with_subtitle: "Monochrome"
307
- },
308
- {
309
- theme_color: "FFFF5CA1",
310
- theme_id: "169463077092846",
311
- theme_emoji: null,
312
- gradient: null,
313
- should_show_icon: "1",
314
- theme_name_with_subtitle: "Hot Pink"
315
- },
316
- {
317
- theme_color: "FF2825B5",
318
- theme_id: "271607034185782",
319
- theme_emoji: null,
320
- gradient: '["FF5E007E","FF331290","FF2825B5"]',
321
- should_show_icon: "1",
322
- theme_name_with_subtitle: "Shadow"
323
- },
324
- {
325
- theme_color: "FFD9A900",
326
- theme_id: "2533652183614000",
327
- theme_emoji: null,
328
- gradient: '["FF550029","FFAA3232","FFD9A900"]',
329
- should_show_icon: "1",
330
- theme_name_with_subtitle: "Maple"
331
- },
332
- {
333
- theme_color: "FFFB45DE",
334
- theme_id: "2873642949430623",
335
- theme_emoji: null,
336
- gradient: null,
337
- should_show_icon: "1",
338
- theme_name_with_subtitle: "Tulip"
339
- },
340
- {
341
- theme_color: "FF5E007E",
342
- theme_id: "193497045377796",
343
- theme_emoji: null,
344
- gradient: null,
345
- should_show_icon: "1",
346
- theme_name_with_subtitle: "Grape"
347
- },
348
- {
349
- theme_color: "FF7AA286",
350
- theme_id: "1455149831518874",
351
- theme_emoji: "🌑",
352
- gradient: '["FF25C0E1","FFCE832A"]',
353
- should_show_icon: "",
354
- theme_name_with_subtitle: "Dune"
355
- },
356
- {
357
- theme_color: "FFFAAF00",
358
- theme_id: "672058580051520",
359
- theme_emoji: null,
360
- gradient: null,
361
- should_show_icon: "1",
362
- theme_name_with_subtitle: "Honey"
363
- },
364
- {
365
- theme_color: "FF0084FF",
366
- theme_id: "196241301102133",
367
- theme_emoji: null,
368
- gradient: null,
369
- should_show_icon: "1",
370
- theme_name_with_subtitle: "Default Blue"
371
- },
372
- {
373
- theme_color: "FFFFC300",
374
- theme_id: "174636906462322",
375
- theme_emoji: null,
376
- gradient: null,
377
- should_show_icon: "1",
378
- theme_name_with_subtitle: "Yellow"
379
- },
380
- {
381
- theme_color: "FF44BEC7",
382
- theme_id: "1928399724138152",
383
- theme_emoji: null,
384
- gradient: null,
385
- should_show_icon: "1",
386
- theme_name_with_subtitle: "Teal Blue"
387
- },
388
- {
389
- theme_color: "FF7646FF",
390
- theme_id: "234137870477637",
391
- theme_emoji: null,
392
- gradient: null,
393
- should_show_icon: "1",
394
- theme_name_with_subtitle: "Bright Purple"
395
- },
396
- {
397
- theme_color: "FFF25C54",
398
- theme_id: "3022526817824329",
399
- theme_emoji: null,
400
- gradient: null,
401
- should_show_icon: "1",
402
- theme_name_with_subtitle: "Peach"
403
- },
404
- {
405
- theme_color: "FFF01D6A",
406
- theme_id: "724096885023603",
407
- theme_emoji: null,
408
- gradient: '["FF005FFF","FF9200FF","FFFF2E19"]',
409
- should_show_icon: "1",
410
- theme_name_with_subtitle: "Berry"
411
- },
412
- {
413
- theme_color: "FFFF7CA8",
414
- theme_id: "624266884847972",
415
- theme_emoji: null,
416
- gradient: '["FFFF8FB2","FFA797FF","FF00E5FF"]',
417
- should_show_icon: "1",
418
- theme_name_with_subtitle: "Candy"
419
- },
420
- {
421
- theme_color: "FF6E5B04",
422
- theme_id: "365557122117011",
423
- theme_emoji: "💛",
424
- gradient: '["FFED9F9A","FFED9F9A","FFED9F9A"]',
425
- should_show_icon: "",
426
- theme_name_with_subtitle: "Support"
427
- },
428
- {
429
- theme_color: "FF0052CD",
430
- theme_id: "230032715012014",
431
- theme_emoji: "✌️",
432
- gradient: '["FF0052CD","FF00A1E6","FF0052CD"]',
433
- should_show_icon: "",
434
- theme_name_with_subtitle: "Tie-Dye"
435
- },
436
- {
437
- theme_color: "FF601DDD",
438
- theme_id: "1060619084701625",
439
- theme_emoji: "☁️",
440
- gradient: '["FFCA34FF","FF302CFF","FFBA009C"]',
441
- should_show_icon: "",
442
- theme_name_with_subtitle: "Lo-Fi"
443
- },
444
- {
445
- theme_color: "FF0099FF",
446
- theme_id: "3273938616164733",
447
- theme_emoji: null,
448
- gradient: null,
449
- should_show_icon: "1",
450
- theme_name_with_subtitle: "Classic"
451
- },
452
- {
453
- theme_color: "FF1ADB5B",
454
- theme_id: "370940413392601",
455
- theme_emoji: null,
456
- gradient: '["FFFFD200","FF6EDF00","FF00DFBB"]',
457
- should_show_icon: "1",
458
- theme_name_with_subtitle: "Citrus"
459
- },
460
- {
461
- theme_color: "FFD696BB",
462
- theme_id: "2058653964378557",
463
- theme_emoji: null,
464
- gradient: null,
465
- should_show_icon: "1",
466
- theme_name_with_subtitle: "Lavender Purple"
467
- },
468
- {
469
- theme_color: "FFC03232",
470
- theme_id: "1059859811490132",
471
- theme_emoji: "🙃",
472
- gradient: '["FFDB4040","FFA32424"]',
473
- should_show_icon: "",
474
- theme_name_with_subtitle: "Stranger Things"
475
- },
476
- {
477
- theme_color: "FFFA3C4C",
478
- theme_id: "2129984390566328",
479
- theme_emoji: null,
480
- gradient: null,
481
- should_show_icon: "1",
482
- theme_name_with_subtitle: "Red"
483
- },
484
- {
485
- theme_color: "FF13CF13",
486
- theme_id: "2136751179887052",
487
- theme_emoji: null,
488
- gradient: null,
489
- should_show_icon: "1",
490
- theme_name_with_subtitle: "Green"
491
- },
492
- {
493
- theme_color: "FFFF7E29",
494
- theme_id: "175615189761153",
495
- theme_emoji: null,
496
- gradient: null,
497
- should_show_icon: "1",
498
- theme_name_with_subtitle: "Orange"
499
- },
500
- {
501
- theme_color: "FFE68585",
502
- theme_id: "980963458735625",
503
- theme_emoji: null,
504
- gradient: null,
505
- should_show_icon: "1",
506
- theme_name_with_subtitle: "Coral Pink"
507
- },
508
- {
509
- theme_color: "FF20CEF5",
510
- theme_id: "2442142322678320",
511
- theme_emoji: null,
512
- gradient: null,
513
- should_show_icon: "1",
514
- theme_name_with_subtitle: "Aqua Blue"
515
- },
516
- {
517
- theme_color: "FF0EDCDE",
518
- theme_id: "417639218648241",
519
- theme_emoji: null,
520
- gradient: '["FF19C9FF","FF00E6D2","FF0EE6B7"]',
521
- should_show_icon: "1",
522
- theme_name_with_subtitle: "Aqua"
523
- },
524
- {
525
- theme_color: "FFFF9C19",
526
- theme_id: "930060997172551",
527
- theme_emoji: null,
528
- gradient: '["FFFFDC2D","FFFF9616","FFFF4F00"]',
529
- should_show_icon: "1",
530
- theme_name_with_subtitle: "Mango"
531
- },
532
- {
533
- theme_color: "FFF01D6A",
534
- theme_id: "164535220883264",
535
- theme_emoji: null,
536
- gradient: '["FF005FFF","FF9200FF","FFFF2E19"]',
537
- should_show_icon: "1",
538
- theme_name_with_subtitle: "Berry"
539
- },
540
- {
541
- theme_color: "FFFF7CA8",
542
- theme_id: "205488546921017",
543
- theme_emoji: null,
544
- gradient: '["FFFF8FB2","FFA797FF","FF00E5FF"]',
545
- should_show_icon: "1",
546
- theme_name_with_subtitle: "Candy"
547
- },
548
- {
549
- theme_color: "FFFF6F07",
550
- theme_id: "1833559466821043",
551
- theme_emoji: "🌎",
552
- gradient: '["FFFF6F07"]',
553
- should_show_icon: "",
554
- theme_name_with_subtitle: "Earth"
555
- },
556
- {
557
- theme_color: "FF0B0085",
558
- theme_id: "339021464972092",
559
- theme_emoji: "🔈",
560
- gradient: '["FF2FA9E4","FF648FEB","FF9B73F2"]',
561
- should_show_icon: "",
562
- theme_name_with_subtitle: "Music"
563
- },
564
- {
565
- theme_color: "FF8A39EF",
566
- theme_id: "1652456634878319",
567
- theme_emoji: "🏳️‍🌈",
568
- gradient:
569
- '["FFFF0018","FFFF0417","FFFF310E","FFFF5D06","FFFF7A01","FFFF8701","FFFFB001","FFD9C507","FF79C718","FF01C92D","FF01BE69","FF01B3AA","FF0BA1DF","FF3F77E6","FF724CEC","FF8A39EF","FF8A39EF"]',
570
- should_show_icon: "",
571
- theme_name_with_subtitle: "Pride"
572
- },
573
- {
574
- theme_color: "FF004D7C",
575
- theme_id: "538280997628317",
576
- theme_emoji: "🌀",
577
- gradient: '["FF931410","FF931410","FF931410"]',
578
- should_show_icon: "",
579
- theme_name_with_subtitle: "Doctor Strange"
580
- },
581
- {
582
- theme_color: "FF4F4DFF",
583
- theme_id: "3190514984517598",
584
- theme_emoji: "🌤",
585
- gradient: '["FF0080FF","FF9F1AFF"]',
586
- should_show_icon: "",
587
- theme_name_with_subtitle: "Sky"
588
- },
589
- {
590
- theme_color: "FFE84B28",
591
- theme_id: "357833546030778",
592
- theme_emoji: "🐯",
593
- gradient: '["FFF69500","FFDA0050"]',
594
- should_show_icon: "1",
595
- theme_name_with_subtitle: "Lunar New Year"
596
- },
597
- {
598
- theme_color: "FFB24B77",
599
- theme_id: "627144732056021",
600
- theme_emoji: "🥳",
601
- gradient: '["FFF1614E","FF660F84"]',
602
- should_show_icon: "",
603
- theme_name_with_subtitle: "Celebration!"
604
- },
605
- {
606
- theme_color: "FF66A9FF",
607
- theme_id: "390127158985345",
608
- theme_emoji: "🥶",
609
- gradient: '["FF8CB3FF","FF409FFF"]',
610
- should_show_icon: "",
611
- theme_name_with_subtitle: "Chill"
612
- },
613
- {
614
- theme_color: "FF5797FC",
615
- theme_id: "275041734441112",
616
- theme_emoji: "😌",
617
- gradient: '["FF4AC9E4","FF5890FF","FF8C91FF"]',
618
- should_show_icon: "",
619
- theme_name_with_subtitle: "Care"
620
- },
621
- {
622
- theme_color: "FFFF595C",
623
- theme_id: "3082966625307060",
624
- theme_emoji: "💫",
625
- gradient: '["FFFF239A","FFFF8C21"]',
626
- should_show_icon: "",
627
- theme_name_with_subtitle: "Astrology"
628
- },
629
- {
630
- theme_color: "FF0171FF",
631
- theme_id: "184305226956268",
632
- theme_emoji: "☁️",
633
- gradient: '["FF0026ee","FF00b2ff"]',
634
- should_show_icon: "",
635
- theme_name_with_subtitle: "J Balvin"
636
- },
637
- {
638
- theme_color: "FFA033FF",
639
- theme_id: "621630955405500",
640
- theme_emoji: "🎉",
641
- gradient: '["FFFF7061","FFFF5280","FFA033FF","FF0099FF"]',
642
- should_show_icon: "",
643
- theme_name_with_subtitle: "Birthday"
644
- },
645
- {
646
- theme_color: "FF006528",
647
- theme_id: "539927563794799",
648
- theme_emoji: "🍄",
649
- gradient: '["FF00d52f","FF006528"]',
650
- should_show_icon: "",
651
- theme_name_with_subtitle: "Cottagecore"
652
- },
653
- {
654
- theme_color: "FF4D3EC2",
655
- theme_id: "736591620215564",
656
- theme_emoji: null,
657
- gradient: null,
658
- should_show_icon: "1",
659
- theme_name_with_subtitle: "Ocean"
660
- },
661
- {
662
- theme_color: "FF4e4bf5",
663
- theme_id: "3259963564026002",
664
- theme_emoji: null,
665
- gradient: '["FFAA00FF","FF0080FF"]',
666
- should_show_icon: "1",
667
- theme_name_with_subtitle: "Default"
668
- },
669
- {
670
- theme_color: "FF3A12FF",
671
- theme_id: "582065306070020",
672
- theme_emoji: null,
673
- gradient: '["FFFAAF00","FFFF2E2E","FF3A12FF"]',
674
- should_show_icon: "1",
675
- theme_name_with_subtitle: "Rocket"
676
- },
677
- {
678
- theme_color: "FF3A1D8A",
679
- theme_id: "273728810607574",
680
- theme_emoji: null,
681
- gradient: '["FFFB45DE","FF841DD5","FF3A1D8A"]',
682
- should_show_icon: "1",
683
- theme_name_with_subtitle: "Unicorn"
684
- },
685
- {
686
- theme_color: "FF9FD52D",
687
- theme_id: "262191918210707",
688
- theme_emoji: null,
689
- gradient: '["FF2A7FE3","FF00BF91","FF9FD52D"]',
690
- should_show_icon: "1",
691
- theme_name_with_subtitle: "Tropical"
692
- },
693
- {
694
- theme_color: "FFF7B267",
695
- theme_id: "909695489504566",
696
- theme_emoji: null,
697
- gradient: '["FFF25C54","FFF4845F","FFF7B267"]',
698
- should_show_icon: "1",
699
- theme_name_with_subtitle: "Sushi"
700
- },
701
- {
702
- theme_color: "FF1ADB5B",
703
- theme_id: "557344741607350",
704
- theme_emoji: null,
705
- gradient: '["FFFFD200","FF6EDF00","FF00DFBB"]',
706
- should_show_icon: "1",
707
- theme_name_with_subtitle: "Citrus"
708
- },
709
- {
710
- theme_color: "FF4D3EC2",
711
- theme_id: "280333826736184",
712
- theme_emoji: null,
713
- gradient: '["FFFF625B","FFC532AD","FF4D3EC2"]',
714
- should_show_icon: "1",
715
- theme_name_with_subtitle: "Lollipop"
716
- },
717
- {
718
- theme_color: "FFFF311E",
719
- theme_id: "1257453361255152",
720
- theme_emoji: null,
721
- gradient: null,
722
- should_show_icon: "1",
723
- theme_name_with_subtitle: "Rose"
724
- },
725
- {
726
- theme_color: "FFA797FF",
727
- theme_id: "571193503540759",
728
- theme_emoji: null,
729
- gradient: null,
730
- should_show_icon: "1",
731
- theme_name_with_subtitle: "Lavender"
732
- },
733
- {
734
- theme_color: "FF6EDF00",
735
- theme_id: "3151463484918004",
736
- theme_emoji: null,
737
- gradient: null,
738
- should_show_icon: "1",
739
- theme_name_with_subtitle: "Kiwi"
740
- },
741
- {
742
- theme_color: "FF9D59D2",
743
- theme_id: "737761000603635",
744
- theme_emoji: "💛",
745
- gradient: '["FFFFD600","FFFCB37B","FF9D59D2","FF282828"]',
746
- should_show_icon: "",
747
- theme_name_with_subtitle: "Non-Binary"
748
- },
749
- {
750
- theme_color: "FF57C39C",
751
- theme_id: "1288506208402340",
752
- theme_emoji: "💐",
753
- gradient: '["FF57C39C","FF57C39C","FF57C39C"]',
754
- should_show_icon: "",
755
- theme_name_with_subtitle: "Mother's Day"
756
- },
757
- {
758
- theme_color: "FFF65900",
759
- theme_id: "121771470870245",
760
- theme_emoji: "💥",
761
- gradient: '["FFFF8328","FFFF7014","FFFF5C00"]',
762
- should_show_icon: "",
763
- theme_name_with_subtitle: "APAHM"
764
- },
765
- {
766
- theme_color: "FF978E21",
767
- theme_id: "810978360551741",
768
- theme_emoji: "🪺",
769
- gradient: '["FF978E21","FF978E21","FF978E21"]',
770
- should_show_icon: "",
771
- theme_name_with_subtitle: "Parenthood"
772
- },
773
- {
774
- theme_color: "FFDD8800",
775
- theme_id: "1438011086532622",
776
- theme_emoji: "",
777
- gradient: '["FFEDAB00","FFCD6300"]',
778
- should_show_icon: "",
779
- theme_name_with_subtitle: "Star Wars"
780
- },
781
- {
782
- theme_color: "FF7D09B9",
783
- theme_id: "101275642962533",
784
- theme_emoji: "🚀",
785
- gradient: '["FF5C22D6","FF8F1EB5","FFC31B92"]',
786
- should_show_icon: "",
787
- theme_name_with_subtitle: "Guardians of the Galaxy"
788
- },
789
- {
790
- theme_color: "FF61C500",
791
- theme_id: "158263147151440",
792
- theme_emoji: "🐝",
793
- gradient: '["FF61C500","FF61C500","FF61C500"]',
794
- should_show_icon: "",
795
- theme_name_with_subtitle: "Bloom"
796
- },
797
- {
798
- theme_color: "FF826044",
799
- theme_id: "195296273246380",
800
- theme_emoji: "🧋",
801
- gradient: '["FF886546","FFA27F57","FFC6A26E"]',
802
- should_show_icon: "",
803
- theme_name_with_subtitle: "Bubble Tea"
804
- },
805
- {
806
- theme_color: "FFB02501",
807
- theme_id: "6026716157422736",
808
- theme_emoji: "⛹️",
809
- gradient: '["FFAC2503","FFB02501","FFB42400"]',
810
- should_show_icon: "",
811
- theme_name_with_subtitle: "Basketball"
812
- },
813
- {
814
- theme_color: "FF574DC1",
815
- theme_id: "693996545771691",
816
- theme_emoji: "🖤",
817
- gradient: '["FF4533FF","FF574AE0","FF6C64BE"]',
818
- should_show_icon: "",
819
- theme_name_with_subtitle: "Elephants&Flowers"
820
- },
821
- {
822
- theme_color: "FFA8B8DA",
823
- theme_id: "504518465021637",
824
- theme_emoji: "🏳️‍⚧️",
825
- gradient: '["FF55D0FF","FF7597D7","FFFF9FB3","FFFF9FB3"]',
826
- should_show_icon: "",
827
- theme_name_with_subtitle: "Transgender"
828
- }
829
- ];
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
+ // ST | Sheikh Tamim
10
+
11
+ function formatMessage(threadID, data) {
12
+ if (!data || !data.__typename) {
13
+ return {
14
+ type: "unknown",
15
+ threadID: threadID,
16
+ messageID: data && data.message_id ? data.message_id : null,
17
+ body: "",
18
+ attachments: [],
19
+ mentions: [],
20
+ timestamp: data && data.timestamp_precise ? data.timestamp_precise : Date.now(),
21
+ error: "Invalid message data structure"
22
+ };
23
+ }
24
+
25
+ switch (data.__typename) {
26
+ case "ThreadNameMessage":
27
+ return {
28
+ type: "event",
29
+ threadID: threadID,
30
+ messageID: data.message_id,
31
+ logMessageType: "log:thread-name",
32
+ logMessageData: {
33
+ name: data.thread_name,
34
+ },
35
+ logMessageBody: data.snippet,
36
+ timestamp: data.timestamp_precise,
37
+ author: data.message_sender.id,
38
+ };
39
+ case "ThreadImageMessage":
40
+ const metadata = data.image_with_metadata;
41
+ return {
42
+ type: "event",
43
+ threadID: threadID,
44
+ messageID: data.message_id,
45
+ logMessageType: "log:thread-image",
46
+ logMessageData: metadata
47
+ ? {
48
+ attachmentID: metadata.legacy_attachment_id,
49
+ width: metadata.original_dimensions.x,
50
+ height: metadata.original_dimensions.y,
51
+ url: metadata.preview.uri,
52
+ }
53
+ : {
54
+ attachmentID: null,
55
+ width: null,
56
+ height: null,
57
+ url: null,
58
+ },
59
+ logMessageBody: data.snippet,
60
+ timestamp: data.timestamp_precise,
61
+ author: data.message_sender.id,
62
+ };
63
+ case "GenericAdminTextMessage":
64
+ switch (data.extensible_message_admin_text_type) {
65
+ case "CHANGE_THREAD_THEME":
66
+ return {
67
+ type: "event",
68
+ threadID: threadID,
69
+ messageID: data.message_id,
70
+ logMessageType: "log:thread-color",
71
+ logMessageData: colors.find(
72
+ (color) =>
73
+ color.theme_color ===
74
+ data.extensible_message_admin_text.theme_color,
75
+ ) || {
76
+ theme_color: data.extensible_message_admin_text.theme_color,
77
+ theme_id: null,
78
+ theme_emoji: null,
79
+ gradient: null,
80
+ should_show_icon: null,
81
+ theme_name_with_subtitle: null,
82
+ },
83
+ logMessageBody: data.snippet,
84
+ timestamp: data.timestamp_precise,
85
+ author: data.message_sender.id,
86
+ };
87
+ case "CHANGE_THREAD_ICON":
88
+ const thread_icon = data.extensible_message_admin_text.thread_icon;
89
+ return {
90
+ type: "event",
91
+ threadID: threadID,
92
+ messageID: data.message_id,
93
+ logMessageType: "log:thread-icon",
94
+ logMessageData: {
95
+ thread_icon_url: `https://static.xx.fbcdn.net/images/emoji.php/v9/t3c/1/16/${thread_icon
96
+ .codePointAt(0)
97
+ .toString(16)}.png`,
98
+ thread_icon: thread_icon,
99
+ },
100
+ logMessageBody: data.snippet,
101
+ timestamp: data.timestamp_precise,
102
+ author: data.message_sender.id,
103
+ };
104
+ case "CHANGE_THREAD_NICKNAME":
105
+ return {
106
+ type: "event",
107
+ threadID: threadID,
108
+ messageID: data.message_id,
109
+ logMessageType: "log:user-nickname",
110
+ logMessageData: {
111
+ nickname: data.extensible_message_admin_text.nickname,
112
+ participant_id: data.extensible_message_admin_text.participant_id,
113
+ },
114
+ logMessageBody: data.snippet,
115
+ timestamp: data.timestamp_precise,
116
+ author: data.message_sender.id,
117
+ };
118
+ case "GROUP_POLL":
119
+ const question = data.extensible_message_admin_text.question;
120
+ return {
121
+ type: "event",
122
+ threadID: threadID,
123
+ messageID: data.message_id,
124
+ logMessageType: "log:thread-poll",
125
+ logMessageData: {
126
+ question_json: JSON.stringify({
127
+ id: question.id,
128
+ text: question.text,
129
+ total_count: data.extensible_message_admin_text.total_count,
130
+ viewer_has_voted: question.viewer_has_voted,
131
+ question_type: "",
132
+ creator_id: data.message_sender.id,
133
+ options: question.options.nodes.map((option) => ({
134
+ id: option.id,
135
+ text: option.text,
136
+ total_count: option.voters.nodes.length,
137
+ viewer_has_voted: option.viewer_has_voted,
138
+ voters: option.voters.nodes.map((voter) => voter.id),
139
+ })),
140
+ }),
141
+ event_type:
142
+ data.extensible_message_admin_text.event_type.toLowerCase(),
143
+ question_id: question.id,
144
+ },
145
+ logMessageBody: data.snippet,
146
+ timestamp: data.timestamp_precise,
147
+ author: data.message_sender.id,
148
+ };
149
+ default:
150
+ throw new Error(
151
+ `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.`,
152
+ );
153
+ }
154
+ case "UserMessage":
155
+ return {
156
+ senderID: data.message_sender ? data.message_sender.id : null,
157
+ body: data.message && data.message.text ? data.message.text : "",
158
+ threadID: threadID,
159
+ messageID: data.message_id,
160
+ reactions: data.message_reactions && Array.isArray(data.message_reactions) ? data.message_reactions.map((r) => ({
161
+ [r.user && r.user.id ? r.user.id : "unknown"]: r.reaction || "",
162
+ })) : [],
163
+ attachments:
164
+ data.blob_attachments && data.blob_attachments.length > 0
165
+ ? (data.blob_attachments || []).map((att) => {
166
+ let x;
167
+ try {
168
+ x = utils._formatAttachment(att);
169
+ } catch (ex) {
170
+ x = att;
171
+ x.error = ex;
172
+ x.type = "unknown";
173
+ }
174
+ return x;
175
+ })
176
+ : data.extensible_attachment &&
177
+ Object.keys(data.extensible_attachment).length > 0
178
+ ? [
179
+ {
180
+ type: "share",
181
+ ID: data.extensible_attachment.legacy_attachment_id || null,
182
+ url: data.extensible_attachment.story_attachment ? data.extensible_attachment.story_attachment.url : null,
183
+
184
+ title: data.extensible_attachment.story_attachment &&
185
+ data.extensible_attachment.story_attachment.title_with_entities ?
186
+ data.extensible_attachment.story_attachment.title_with_entities.text : "",
187
+ description: data.extensible_attachment.story_attachment &&
188
+ data.extensible_attachment.story_attachment.description ?
189
+ data.extensible_attachment.story_attachment.description.text : "",
190
+ source: data.extensible_attachment.story_attachment ? data.extensible_attachment.story_attachment.source : null,
191
+
192
+ image: (
193
+ (data.extensible_attachment.story_attachment && data.extensible_attachment.story_attachment.media || {})
194
+ .image || {}
195
+ ).uri || null,
196
+ width: (
197
+ (data.extensible_attachment.story_attachment && data.extensible_attachment.story_attachment.media || {})
198
+ .image || {}
199
+ ).width || null,
200
+ height: (
201
+ (data.extensible_attachment.story_attachment && data.extensible_attachment.story_attachment.media || {})
202
+ .image || {}
203
+ ).height || null,
204
+ playable:
205
+ (data.extensible_attachment.story_attachment && data.extensible_attachment.story_attachment.media || {})
206
+ .is_playable || false,
207
+ duration:
208
+ (data.extensible_attachment.story_attachment && data.extensible_attachment.story_attachment.media || {})
209
+ .playable_duration_in_ms || 0,
210
+
211
+ subattachments: data.extensible_attachment.subattachments || [],
212
+ properties: data.extensible_attachment.story_attachment ? data.extensible_attachment.story_attachment.properties : {},
213
+ },
214
+ ]
215
+ : [],
216
+ mentions: data.message && data.message.ranges && data.message.text ? data.message.ranges.map((mention) => ({
217
+ [mention.entity && mention.entity.id ? mention.entity.id : "unknown"]: data.message.text.substring(
218
+ mention.offset || 0,
219
+ (mention.offset || 0) + (mention.length || 0),
220
+ ),
221
+ })) : [],
222
+ timestamp: data.timestamp_precise,
223
+ };
224
+ default:
225
+ throw new Error(
226
+ `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.`,
227
+ );
228
+ // If this happens to you let me know when it happens
229
+ // Please open an issue at https://github.com/ntkhang03/fb-chat-api/issues.
230
+ // return Object.assign({ type: "unknown", data });
231
+ }
232
+ }
233
+
234
+ function parseDelta(threadID, delta) {
235
+ if (delta.replied_to_message) {
236
+ return Object.assign(
237
+ {
238
+ type: "message_reply",
239
+ },
240
+ formatMessage(threadID, delta),
241
+ {
242
+ messageReply: formatMessage(threadID, delta.replied_to_message.message),
243
+ },
244
+ );
245
+ } else {
246
+ return formatMessage(threadID, delta);
247
+ }
248
+ }
249
+
250
+ module.exports = function (defaultFuncs, api, ctx) {
251
+ return function getMessage(threadID, messageID, callback) {
252
+ let resolveFunc = function () {};
253
+ let rejectFunc = function () {};
254
+ const returnPromise = new Promise(function (resolve, reject) {
255
+ resolveFunc = resolve;
256
+ rejectFunc = reject;
257
+ });
258
+
259
+ if (!callback) {
260
+ callback = function (err, info) {
261
+ if (err) return rejectFunc(err);
262
+ resolveFunc(info);
263
+ };
264
+ }
265
+
266
+ if (!threadID || !messageID) {
267
+ return callback({ error: "getMessage: need threadID and messageID" });
268
+ }
269
+
270
+ const form = {
271
+ av: ctx.globalOptions.pageID,
272
+ queries: JSON.stringify({
273
+ o0: {
274
+ //This doc_id is valid as of ? (prob January 18, 2020)
275
+ doc_id: "1768656253222505",
276
+ query_params: {
277
+ thread_and_message_id: {
278
+ thread_id: threadID,
279
+ message_id: messageID,
280
+ },
281
+ },
282
+ },
283
+ }),
284
+ };
285
+
286
+ defaultFuncs
287
+ .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
288
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
289
+ .then((resData) => {
290
+ if (resData[resData.length - 1].error_results > 0) {
291
+ throw resData[0].o0.errors;
292
+ }
293
+
294
+ if (resData[resData.length - 1].successful_results === 0) {
295
+ throw {
296
+ error: "getMessage: there was no successful_results",
297
+ res: resData,
298
+ };
299
+ }
300
+
301
+ const fetchData = resData[0].o0.data.message;
302
+ if (fetchData) {
303
+ callback(null, parseDelta(threadID, fetchData));
304
+ } else {
305
+ throw fetchData;
306
+ }
307
+ })
308
+ .catch((err) => {
309
+ console.error("getMessage", err);
310
+ callback(err);
311
+ });
312
+
313
+ return returnPromise;
314
+ };
315
+ };
316
+
317
+ const colors = [
318
+ {
319
+ theme_color: "FF000000",
320
+ theme_id: "788274591712841",
321
+ theme_emoji: "🖤",
322
+ gradient: '["FFF0F0F0"]',
323
+ should_show_icon: "",
324
+ theme_name_with_subtitle: "Monochrome",
325
+ },
326
+ {
327
+ theme_color: "FFFF5CA1",
328
+ theme_id: "169463077092846",
329
+ theme_emoji: null,
330
+ gradient: null,
331
+ should_show_icon: "1",
332
+ theme_name_with_subtitle: "Hot Pink",
333
+ },
334
+ {
335
+ theme_color: "FF2825B5",
336
+ theme_id: "271607034185782",
337
+ theme_emoji: null,
338
+ gradient: '["FF5E007E","FF331290","FF2825B5"]',
339
+ should_show_icon: "1",
340
+ theme_name_with_subtitle: "Shadow",
341
+ },
342
+ {
343
+ theme_color: "FFD9A900",
344
+ theme_id: "2533652183614000",
345
+ theme_emoji: null,
346
+ gradient: '["FF550029","FFAA3232","FFD9A900"]',
347
+ should_show_icon: "1",
348
+ theme_name_with_subtitle: "Maple",
349
+ },
350
+ {
351
+ theme_color: "FFFB45DE",
352
+ theme_id: "2873642949430623",
353
+ theme_emoji: null,
354
+ gradient: null,
355
+ should_show_icon: "1",
356
+ theme_name_with_subtitle: "Tulip",
357
+ },
358
+ {
359
+ theme_color: "FF5E007E",
360
+ theme_id: "193497045377796",
361
+ theme_emoji: null,
362
+ gradient: null,
363
+ should_show_icon: "1",
364
+ theme_name_with_subtitle: "Grape",
365
+ },
366
+ {
367
+ theme_color: "FF7AA286",
368
+ theme_id: "1455149831518874",
369
+ theme_emoji: "🌑",
370
+ gradient: '["FF25C0E1","FFCE832A"]',
371
+ should_show_icon: "",
372
+ theme_name_with_subtitle: "Dune",
373
+ },
374
+ {
375
+ theme_color: "FFFAAF00",
376
+ theme_id: "672058580051520",
377
+ theme_emoji: null,
378
+ gradient: null,
379
+ should_show_icon: "1",
380
+ theme_name_with_subtitle: "Honey",
381
+ },
382
+ {
383
+ theme_color: "FF0084FF",
384
+ theme_id: "196241301102133",
385
+ theme_emoji: null,
386
+ gradient: null,
387
+ should_show_icon: "1",
388
+ theme_name_with_subtitle: "Default Blue",
389
+ },
390
+ {
391
+ theme_color: "FFFFC300",
392
+ theme_id: "174636906462322",
393
+ theme_emoji: null,
394
+ gradient: null,
395
+ should_show_icon: "1",
396
+ theme_name_with_subtitle: "Yellow",
397
+ },
398
+ {
399
+ theme_color: "FF44BEC7",
400
+ theme_id: "1928399724138152",
401
+ theme_emoji: null,
402
+ gradient: null,
403
+ should_show_icon: "1",
404
+ theme_name_with_subtitle: "Teal Blue",
405
+ },
406
+ {
407
+ theme_color: "FF7646FF",
408
+ theme_id: "234137870477637",
409
+ theme_emoji: null,
410
+ gradient: null,
411
+ should_show_icon: "1",
412
+ theme_name_with_subtitle: "Bright Purple",
413
+ },
414
+ {
415
+ theme_color: "FFF25C54",
416
+ theme_id: "3022526817824329",
417
+ theme_emoji: null,
418
+ gradient: null,
419
+ should_show_icon: "1",
420
+ theme_name_with_subtitle: "Peach",
421
+ },
422
+ {
423
+ theme_color: "FFF01D6A",
424
+ theme_id: "724096885023603",
425
+ theme_emoji: null,
426
+ gradient: '["FF005FFF","FF9200FF","FFFF2E19"]',
427
+ should_show_icon: "1",
428
+ theme_name_with_subtitle: "Berry",
429
+ },
430
+ {
431
+ theme_color: "FFFF7CA8",
432
+ theme_id: "624266884847972",
433
+ theme_emoji: null,
434
+ gradient: '["FFFF8FB2","FFA797FF","FF00E5FF"]',
435
+ should_show_icon: "1",
436
+ theme_name_with_subtitle: "Candy",
437
+ },
438
+ {
439
+ theme_color: "FF6E5B04",
440
+ theme_id: "365557122117011",
441
+ theme_emoji: "💛",
442
+ gradient: '["FFED9F9A","FFED9F9A","FFED9F9A"]',
443
+ should_show_icon: "",
444
+ theme_name_with_subtitle: "Support",
445
+ },
446
+ {
447
+ theme_color: "FF0052CD",
448
+ theme_id: "230032715012014",
449
+ theme_emoji: "✌️",
450
+ gradient: '["FF0052CD","FF00A1E6","FF0052CD"]',
451
+ should_show_icon: "",
452
+ theme_name_with_subtitle: "Tie-Dye",
453
+ },
454
+ {
455
+ theme_color: "FF601DDD",
456
+ theme_id: "1060619084701625",
457
+ theme_emoji: "☁️",
458
+ gradient: '["FFCA34FF","FF302CFF","FFBA009C"]',
459
+ should_show_icon: "",
460
+ theme_name_with_subtitle: "Lo-Fi",
461
+ },
462
+ {
463
+ theme_color: "FF0099FF",
464
+ theme_id: "3273938616164733",
465
+ theme_emoji: null,
466
+ gradient: null,
467
+ should_show_icon: "1",
468
+ theme_name_with_subtitle: "Classic",
469
+ },
470
+ {
471
+ theme_color: "FF1ADB5B",
472
+ theme_id: "370940413392601",
473
+ theme_emoji: null,
474
+ gradient: '["FFFFD200","FF6EDF00","FF00DFBB"]',
475
+ should_show_icon: "1",
476
+ theme_name_with_subtitle: "Citrus",
477
+ },
478
+ {
479
+ theme_color: "FFD696BB",
480
+ theme_id: "2058653964378557",
481
+ theme_emoji: null,
482
+ gradient: null,
483
+ should_show_icon: "1",
484
+ theme_name_with_subtitle: "Lavender Purple",
485
+ },
486
+ {
487
+ theme_color: "FFC03232",
488
+ theme_id: "1059859811490132",
489
+ theme_emoji: "🙃",
490
+ gradient: '["FFDB4040","FFA32424"]',
491
+ should_show_icon: "",
492
+ theme_name_with_subtitle: "Stranger Things",
493
+ },
494
+ {
495
+ theme_color: "FFFA3C4C",
496
+ theme_id: "2129984390566328",
497
+ theme_emoji: null,
498
+ gradient: null,
499
+ should_show_icon: "1",
500
+ theme_name_with_subtitle: "Red",
501
+ },
502
+ {
503
+ theme_color: "FF13CF13",
504
+ theme_id: "2136751179887052",
505
+ theme_emoji: null,
506
+ gradient: null,
507
+ should_show_icon: "1",
508
+ theme_name_with_subtitle: "Green",
509
+ },
510
+ {
511
+ theme_color: "FFFF7E29",
512
+ theme_id: "175615189761153",
513
+ theme_emoji: null,
514
+ gradient: null,
515
+ should_show_icon: "1",
516
+ theme_name_with_subtitle: "Orange",
517
+ },
518
+ {
519
+ theme_color: "FFE68585",
520
+ theme_id: "980963458735625",
521
+ theme_emoji: null,
522
+ gradient: null,
523
+ should_show_icon: "1",
524
+ theme_name_with_subtitle: "Coral Pink",
525
+ },
526
+ {
527
+ theme_color: "FF20CEF5",
528
+ theme_id: "2442142322678320",
529
+ theme_emoji: null,
530
+ gradient: null,
531
+ should_show_icon: "1",
532
+ theme_name_with_subtitle: "Aqua Blue",
533
+ },
534
+ {
535
+ theme_color: "FF0EDCDE",
536
+ theme_id: "417639218648241",
537
+ theme_emoji: null,
538
+ gradient: '["FF19C9FF","FF00E6D2","FF0EE6B7"]',
539
+ should_show_icon: "1",
540
+ theme_name_with_subtitle: "Aqua",
541
+ },
542
+ {
543
+ theme_color: "FFFF9C19",
544
+ theme_id: "930060997172551",
545
+ theme_emoji: null,
546
+ gradient: '["FFFFDC2D","FFFF9616","FFFF4F00"]',
547
+ should_show_icon: "1",
548
+ theme_name_with_subtitle: "Mango",
549
+ },
550
+ {
551
+ theme_color: "FFF01D6A",
552
+ theme_id: "164535220883264",
553
+ theme_emoji: null,
554
+ gradient: '["FF005FFF","FF9200FF","FFFF2E19"]',
555
+ should_show_icon: "1",
556
+ theme_name_with_subtitle: "Berry",
557
+ },
558
+ {
559
+ theme_color: "FFFF7CA8",
560
+ theme_id: "205488546921017",
561
+ theme_emoji: null,
562
+ gradient: '["FFFF8FB2","FFA797FF","FF00E5FF"]',
563
+ should_show_icon: "1",
564
+ theme_name_with_subtitle: "Candy",
565
+ },
566
+ {
567
+ theme_color: "FFFF6F07",
568
+ theme_id: "1833559466821043",
569
+ theme_emoji: "🌎",
570
+ gradient: '["FFFF6F07"]',
571
+ should_show_icon: "",
572
+ theme_name_with_subtitle: "Earth",
573
+ },
574
+ {
575
+ theme_color: "FF0B0085",
576
+ theme_id: "339021464972092",
577
+ theme_emoji: "🔈",
578
+ gradient: '["FF2FA9E4","FF648FEB","FF9B73F2"]',
579
+ should_show_icon: "",
580
+ theme_name_with_subtitle: "Music",
581
+ },
582
+ {
583
+ theme_color: "FF8A39EF",
584
+ theme_id: "1652456634878319",
585
+ theme_emoji: "🏳️‍🌈",
586
+ gradient:
587
+ '["FFFF0018","FFFF0417","FFFF310E","FFFF5D06","FFFF7A01","FFFF8701","FFFFB001","FFD9C507","FF79C718","FF01C92D","FF01BE69","FF01B3AA","FF0BA1DF","FF3F77E6","FF724CEC","FF8A39EF","FF8A39EF"]',
588
+ should_show_icon: "",
589
+ theme_name_with_subtitle: "Pride",
590
+ },
591
+ {
592
+ theme_color: "FF004D7C",
593
+ theme_id: "538280997628317",
594
+ theme_emoji: "🌀",
595
+ gradient: '["FF931410","FF931410","FF931410"]',
596
+ should_show_icon: "",
597
+ theme_name_with_subtitle: "Doctor Strange",
598
+ },
599
+ {
600
+ theme_color: "FF4F4DFF",
601
+ theme_id: "3190514984517598",
602
+ theme_emoji: "🌤",
603
+ gradient: '["FF0080FF","FF9F1AFF"]',
604
+ should_show_icon: "",
605
+ theme_name_with_subtitle: "Sky",
606
+ },
607
+ {
608
+ theme_color: "FFE84B28",
609
+ theme_id: "357833546030778",
610
+ theme_emoji: "🐯",
611
+ gradient: '["FFF69500","FFDA0050"]',
612
+ should_show_icon: "1",
613
+ theme_name_with_subtitle: "Lunar New Year",
614
+ },
615
+ {
616
+ theme_color: "FFB24B77",
617
+ theme_id: "627144732056021",
618
+ theme_emoji: "🥳",
619
+ gradient: '["FFF1614E","FF660F84"]',
620
+ should_show_icon: "",
621
+ theme_name_with_subtitle: "Celebration!",
622
+ },
623
+ {
624
+ theme_color: "FF66A9FF",
625
+ theme_id: "390127158985345",
626
+ theme_emoji: "🥶",
627
+ gradient: '["FF8CB3FF","FF409FFF"]',
628
+ should_show_icon: "",
629
+ theme_name_with_subtitle: "Chill",
630
+ },
631
+ {
632
+ theme_color: "FF5797FC",
633
+ theme_id: "275041734441112",
634
+ theme_emoji: "😌",
635
+ gradient: '["FF4AC9E4","FF5890FF","FF8C91FF"]',
636
+ should_show_icon: "",
637
+ theme_name_with_subtitle: "Care",
638
+ },
639
+ {
640
+ theme_color: "FFFF595C",
641
+ theme_id: "3082966625307060",
642
+ theme_emoji: "💫",
643
+ gradient: '["FFFF239A","FFFF8C21"]',
644
+ should_show_icon: "",
645
+ theme_name_with_subtitle: "Astrology",
646
+ },
647
+ {
648
+ theme_color: "FF0171FF",
649
+ theme_id: "184305226956268",
650
+ theme_emoji: "☁️",
651
+ gradient: '["FF0026ee","FF00b2ff"]',
652
+ should_show_icon: "",
653
+ theme_name_with_subtitle: "J Balvin",
654
+ },
655
+ {
656
+ theme_color: "FFA033FF",
657
+ theme_id: "621630955405500",
658
+ theme_emoji: "🎉",
659
+ gradient: '["FFFF7061","FFFF5280","FFA033FF","FF0099FF"]',
660
+ should_show_icon: "",
661
+ theme_name_with_subtitle: "Birthday",
662
+ },
663
+ {
664
+ theme_color: "FF006528",
665
+ theme_id: "539927563794799",
666
+ theme_emoji: "🍄",
667
+ gradient: '["FF00d52f","FF006528"]',
668
+ should_show_icon: "",
669
+ theme_name_with_subtitle: "Cottagecore",
670
+ },
671
+ {
672
+ theme_color: "FF4D3EC2",
673
+ theme_id: "736591620215564",
674
+ theme_emoji: null,
675
+ gradient: null,
676
+ should_show_icon: "1",
677
+ theme_name_with_subtitle: "Ocean",
678
+ },
679
+ {
680
+ theme_color: "FF4e4bf5",
681
+ theme_id: "3259963564026002",
682
+ theme_emoji: null,
683
+ gradient: '["FFAA00FF","FF0080FF"]',
684
+ should_show_icon: "1",
685
+ theme_name_with_subtitle: "Default",
686
+ },
687
+ {
688
+ theme_color: "FF3A12FF",
689
+ theme_id: "582065306070020",
690
+ theme_emoji: null,
691
+ gradient: '["FFFAAF00","FFFF2E2E","FF3A12FF"]',
692
+ should_show_icon: "1",
693
+ theme_name_with_subtitle: "Rocket",
694
+ },
695
+ {
696
+ theme_color: "FF3A1D8A",
697
+ theme_id: "273728810607574",
698
+ theme_emoji: null,
699
+ gradient: '["FFFB45DE","FF841DD5","FF3A1D8A"]',
700
+ should_show_icon: "1",
701
+ theme_name_with_subtitle: "Unicorn",
702
+ },
703
+ {
704
+ theme_color: "FF9FD52D",
705
+ theme_id: "262191918210707",
706
+ theme_emoji: null,
707
+ gradient: '["FF2A7FE3","FF00BF91","FF9FD52D"]',
708
+ should_show_icon: "1",
709
+ theme_name_with_subtitle: "Tropical",
710
+ },
711
+ {
712
+ theme_color: "FFF7B267",
713
+ theme_id: "909695489504566",
714
+ theme_emoji: null,
715
+ gradient: '["FFF25C54","FFF4845F","FFF7B267"]',
716
+ should_show_icon: "1",
717
+ theme_name_with_subtitle: "Sushi",
718
+ },
719
+ {
720
+ theme_color: "FF1ADB5B",
721
+ theme_id: "557344741607350",
722
+ theme_emoji: null,
723
+ gradient: '["FFFFD200","FF6EDF00","FF00DFBB"]',
724
+ should_show_icon: "1",
725
+ theme_name_with_subtitle: "Citrus",
726
+ },
727
+ {
728
+ theme_color: "FF4D3EC2",
729
+ theme_id: "280333826736184",
730
+ theme_emoji: null,
731
+ gradient: '["FFFF625B","FFC532AD","FF4D3EC2"]',
732
+ should_show_icon: "1",
733
+ theme_name_with_subtitle: "Lollipop",
734
+ },
735
+ {
736
+ theme_color: "FFFF311E",
737
+ theme_id: "1257453361255152",
738
+ theme_emoji: null,
739
+ gradient: null,
740
+ should_show_icon: "1",
741
+ theme_name_with_subtitle: "Rose",
742
+ },
743
+ {
744
+ theme_color: "FFA797FF",
745
+ theme_id: "571193503540759",
746
+ theme_emoji: null,
747
+ gradient: null,
748
+ should_show_icon: "1",
749
+ theme_name_with_subtitle: "Lavender",
750
+ },
751
+ {
752
+ theme_color: "FF6EDF00",
753
+ theme_id: "3151463484918004",
754
+ theme_emoji: null,
755
+ gradient: null,
756
+ should_show_icon: "1",
757
+ theme_name_with_subtitle: "Kiwi",
758
+ },
759
+ {
760
+ theme_color: "FF9D59D2",
761
+ theme_id: "737761000603635",
762
+ theme_emoji: "💛",
763
+ gradient: '["FFFFD600","FFFCB37B","FF9D59D2","FF282828"]',
764
+ should_show_icon: "",
765
+ theme_name_with_subtitle: "Non-Binary",
766
+ },
767
+ {
768
+ theme_color: "FF57C39C",
769
+ theme_id: "1288506208402340",
770
+ theme_emoji: "💐",
771
+ gradient: '["FF57C39C","FF57C39C","FF57C39C"]',
772
+ should_show_icon: "",
773
+ theme_name_with_subtitle: "Mother's Day",
774
+ },
775
+ {
776
+ theme_color: "FFF65900",
777
+ theme_id: "121771470870245",
778
+ theme_emoji: "💥",
779
+ gradient: '["FFFF8328","FFFF7014","FFFF5C00"]',
780
+ should_show_icon: "",
781
+ theme_name_with_subtitle: "APAHM",
782
+ },
783
+ {
784
+ theme_color: "FF978E21",
785
+ theme_id: "810978360551741",
786
+ theme_emoji: "🪺",
787
+ gradient: '["FF978E21","FF978E21","FF978E21"]',
788
+ should_show_icon: "",
789
+ theme_name_with_subtitle: "Parenthood",
790
+ },
791
+ {
792
+ theme_color: "FFDD8800",
793
+ theme_id: "1438011086532622",
794
+ theme_emoji: "",
795
+ gradient: '["FFEDAB00","FFCD6300"]',
796
+ should_show_icon: "",
797
+ theme_name_with_subtitle: "Star Wars",
798
+ },
799
+ {
800
+ theme_color: "FF7D09B9",
801
+ theme_id: "101275642962533",
802
+ theme_emoji: "🚀",
803
+ gradient: '["FF5C22D6","FF8F1EB5","FFC31B92"]',
804
+ should_show_icon: "",
805
+ theme_name_with_subtitle: "Guardians of the Galaxy",
806
+ },
807
+ {
808
+ theme_color: "FF61C500",
809
+ theme_id: "158263147151440",
810
+ theme_emoji: "🐝",
811
+ gradient: '["FF61C500","FF61C500","FF61C500"]',
812
+ should_show_icon: "",
813
+ theme_name_with_subtitle: "Bloom",
814
+ },
815
+ {
816
+ theme_color: "FF826044",
817
+ theme_id: "195296273246380",
818
+ theme_emoji: "🧋",
819
+ gradient: '["FF886546","FFA27F57","FFC6A26E"]',
820
+ should_show_icon: "",
821
+ theme_name_with_subtitle: "Bubble Tea",
822
+ },
823
+ {
824
+ theme_color: "FFB02501",
825
+ theme_id: "6026716157422736",
826
+ theme_emoji: "⛹️",
827
+ gradient: '["FFAC2503","FFB02501","FFB42400"]',
828
+ should_show_icon: "",
829
+ theme_name_with_subtitle: "Basketball",
830
+ },
831
+ {
832
+ theme_color: "FF574DC1",
833
+ theme_id: "693996545771691",
834
+ theme_emoji: "🖤",
835
+ gradient: '["FF4533FF","FF574AE0","FF6C64BE"]',
836
+ should_show_icon: "",
837
+ theme_name_with_subtitle: "Elephants&Flowers",
838
+ },
839
+ {
840
+ theme_color: "FFA8B8DA",
841
+ theme_id: "504518465021637",
842
+ theme_emoji: "🏳️‍⚧️",
843
+ gradient: '["FF55D0FF","FF7597D7","FFFF9FB3","FFFF9FB3"]',
844
+ should_show_icon: "",
845
+ theme_name_with_subtitle: "Transgender",
846
+ },
847
+ ];