@dongdev/fca-unofficial 1.0.0 → 1.0.1
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/README.md +1 -3
- package/index.js +13 -26
- package/package.json +2 -1
- package/src/getThreadInfo.js +234 -1
- package/src/setMessageReaction.js +113 -111
package/README.md
CHANGED
@@ -12,8 +12,6 @@ _Disclaimer_: We are not responsible if your account gets banned for spammy acti
|
|
12
12
|
|
13
13
|
If you encounter errors on fca, you can contact me [here](https://www.facebook.com/minhdong.dev)
|
14
14
|
|
15
|
-
`</div>`
|
16
|
-
|
17
15
|
Facebook now has an official API for chat bots [here](https://developers.facebook.com/docs/messenger-platform).
|
18
16
|
|
19
17
|
This API is the only way to automate chat functionalities on a user account. We do this by emulating the browser. This means doing the exact same GET/POST requests and tricking Facebook into thinking we're accessing the website normally. Because we're doing it this way, this API won't work with an auth token but requires the credentials of a Facebook account.
|
@@ -81,7 +79,7 @@ login({ appState: [] }, (err, api) => {
|
|
81
79
|
|
82
80
|
let yourID = "000000000000000"; // Replace with actual Facebook ID
|
83
81
|
let msg = "Hey!";
|
84
|
-
|
82
|
+
|
85
83
|
api.sendMessage(msg, yourID, (err) => {
|
86
84
|
if (err) console.error("Message Sending Error:", err);
|
87
85
|
else console.log("Message sent successfully!");
|
package/index.js
CHANGED
@@ -130,33 +130,18 @@ function setOptions(globalOptions, options) {
|
|
130
130
|
});
|
131
131
|
}
|
132
132
|
function buildAPI(globalOptions, html, jar) {
|
133
|
-
const
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
.
|
140
|
-
|
141
|
-
|
142
|
-
return obj;
|
143
|
-
}, {});
|
144
|
-
if (maybeCookie.length === 0) {
|
145
|
-
throw {
|
146
|
-
error:
|
147
|
-
"Error retrieving userID. This can be caused by a lot of things, including getting blocked by Facebook for logging in from an unknown location. Try logging in with a browser to verify.",
|
148
|
-
};
|
149
|
-
}
|
150
|
-
if (html.indexOf("/checkpoint/block/?next") > -1 || html.indexOf("/checkpoint/?next") > -1) {
|
151
|
-
throw {
|
152
|
-
error: "Checkpoint detected. Please log in with a browser to verify.",
|
153
|
-
}
|
133
|
+
const cookies = jar.getCookies("https://www.facebook.com");
|
134
|
+
const userCookie = cookies.find(c => c.cookieString().startsWith("c_user="));
|
135
|
+
const tiktikCookie = cookies.find(c => c.cookieString().startsWith("i_user="));
|
136
|
+
if (userCookie.length === 0 && tiktikCookie.length === 0) {
|
137
|
+
return log.error('login', "Không tìm thấy cookie cho người dùng, vui lòng kiểm tra lại thông tin đăng nhập")
|
138
|
+
} else if (!userCookie && !tiktikCookie) {
|
139
|
+
return log.error('login', "Không tìm thấy cookie cho người dùng, vui lòng kiểm tra lại thông tin đăng nhập")
|
140
|
+
} else if (html.includes("/checkpoint/block/?next")) {
|
141
|
+
return log.error('login', "Appstate die, vui lòng thay cái mới!", 'error');
|
154
142
|
}
|
155
|
-
const userID =
|
156
|
-
|
157
|
-
.split("=")[1]
|
158
|
-
.toString();
|
159
|
-
const i_userID = objCookie.i_user || null;
|
143
|
+
const userID = (tiktikCookie || userCookie).cookieString().split("=")[1];
|
144
|
+
const i_userID = tiktikCookie ? tiktikCookie.cookieString().split("=")[1] : null;
|
160
145
|
logger(`Logged in as ${userID}`, 'info');
|
161
146
|
try {
|
162
147
|
clearInterval(checkVerified);
|
@@ -204,6 +189,8 @@ function buildAPI(globalOptions, html, jar) {
|
|
204
189
|
region,
|
205
190
|
firstListen: true,
|
206
191
|
fb_dtsg,
|
192
|
+
wsReqNumber: 0,
|
193
|
+
wsTaskNumber: 0
|
207
194
|
};
|
208
195
|
const api = {
|
209
196
|
setOptions: setOptions.bind(null, globalOptions),
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dongdev/fca-unofficial",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.1",
|
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": {
|
@@ -22,6 +22,7 @@
|
|
22
22
|
"request": "^2.53.0",
|
23
23
|
"sequelize": "^6.37.6",
|
24
24
|
"sqlite3": "^5.1.7",
|
25
|
+
"totp-generator": "^1.0.0",
|
25
26
|
"ws": "^8.18.1"
|
26
27
|
},
|
27
28
|
"devDependencies": {
|
package/src/getThreadInfo.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
/*
|
3
3
|
const utils = require("../utils");
|
4
4
|
const log = require("npmlog");
|
5
5
|
const fs = require("fs");
|
@@ -299,4 +299,237 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
299
299
|
}
|
300
300
|
return returnPromise;
|
301
301
|
};
|
302
|
+
};
|
303
|
+
*/
|
304
|
+
"use strict";
|
305
|
+
|
306
|
+
const utils = require("../utils");
|
307
|
+
const log = require("npmlog");
|
308
|
+
|
309
|
+
function formatEventReminders(reminder) {
|
310
|
+
return {
|
311
|
+
reminderID: reminder.id,
|
312
|
+
eventCreatorID: reminder.lightweight_event_creator.id,
|
313
|
+
time: reminder.time,
|
314
|
+
eventType: reminder.lightweight_event_type.toLowerCase(),
|
315
|
+
locationName: reminder.location_name,
|
316
|
+
// @TODO verify this
|
317
|
+
locationCoordinates: reminder.location_coordinates,
|
318
|
+
locationPage: reminder.location_page,
|
319
|
+
eventStatus: reminder.lightweight_event_status.toLowerCase(),
|
320
|
+
note: reminder.note,
|
321
|
+
repeatMode: reminder.repeat_mode.toLowerCase(),
|
322
|
+
eventTitle: reminder.event_title,
|
323
|
+
triggerMessage: reminder.trigger_message,
|
324
|
+
secondsToNotifyBefore: reminder.seconds_to_notify_before,
|
325
|
+
allowsRsvp: reminder.allows_rsvp,
|
326
|
+
relatedEvent: reminder.related_event,
|
327
|
+
members: reminder.event_reminder_members.edges.map(function (member) {
|
328
|
+
return {
|
329
|
+
memberID: member.node.id,
|
330
|
+
state: member.guest_list_state.toLowerCase()
|
331
|
+
};
|
332
|
+
})
|
333
|
+
};
|
334
|
+
}
|
335
|
+
|
336
|
+
function formatThreadGraphQLResponse(data) {
|
337
|
+
if (data.errors)
|
338
|
+
return data.errors;
|
339
|
+
const messageThread = data.message_thread;
|
340
|
+
if (!messageThread)
|
341
|
+
return null;
|
342
|
+
const threadID = messageThread.thread_key.thread_fbid
|
343
|
+
? messageThread.thread_key.thread_fbid
|
344
|
+
: messageThread.thread_key.other_user_id;
|
345
|
+
|
346
|
+
// Remove me
|
347
|
+
const lastM = messageThread.last_message;
|
348
|
+
const snippetID =
|
349
|
+
lastM &&
|
350
|
+
lastM.nodes &&
|
351
|
+
lastM.nodes[0] &&
|
352
|
+
lastM.nodes[0].message_sender &&
|
353
|
+
lastM.nodes[0].message_sender.messaging_actor
|
354
|
+
? lastM.nodes[0].message_sender.messaging_actor.id
|
355
|
+
: null;
|
356
|
+
const snippetText =
|
357
|
+
lastM && lastM.nodes && lastM.nodes[0] ? lastM.nodes[0].snippet : null;
|
358
|
+
const lastR = messageThread.last_read_receipt;
|
359
|
+
const lastReadTimestamp =
|
360
|
+
lastR && lastR.nodes && lastR.nodes[0] && lastR.nodes[0].timestamp_precise
|
361
|
+
? lastR.nodes[0].timestamp_precise
|
362
|
+
: null;
|
363
|
+
|
364
|
+
return {
|
365
|
+
threadID: threadID,
|
366
|
+
threadName: messageThread.name,
|
367
|
+
participantIDs: messageThread.all_participants.edges.map(d => d.node.messaging_actor.id),
|
368
|
+
userInfo: messageThread.all_participants.edges.map(d => ({
|
369
|
+
id: d.node.messaging_actor.id,
|
370
|
+
name: d.node.messaging_actor.name,
|
371
|
+
firstName: d.node.messaging_actor.short_name,
|
372
|
+
vanity: d.node.messaging_actor.username,
|
373
|
+
url: d.node.messaging_actor.url,
|
374
|
+
thumbSrc: d.node.messaging_actor.big_image_src.uri,
|
375
|
+
profileUrl: d.node.messaging_actor.big_image_src.uri,
|
376
|
+
gender: d.node.messaging_actor.gender,
|
377
|
+
type: d.node.messaging_actor.__typename,
|
378
|
+
isFriend: d.node.messaging_actor.is_viewer_friend,
|
379
|
+
isBirthday: !!d.node.messaging_actor.is_birthday //not sure?
|
380
|
+
})),
|
381
|
+
unreadCount: messageThread.unread_count,
|
382
|
+
messageCount: messageThread.messages_count,
|
383
|
+
timestamp: messageThread.updated_time_precise,
|
384
|
+
muteUntil: messageThread.mute_until,
|
385
|
+
isGroup: messageThread.thread_type == "GROUP",
|
386
|
+
isSubscribed: messageThread.is_viewer_subscribed,
|
387
|
+
isArchived: messageThread.has_viewer_archived,
|
388
|
+
folder: messageThread.folder,
|
389
|
+
cannotReplyReason: messageThread.cannot_reply_reason,
|
390
|
+
eventReminders: messageThread.event_reminders
|
391
|
+
? messageThread.event_reminders.nodes.map(formatEventReminders)
|
392
|
+
: null,
|
393
|
+
emoji: messageThread.customization_info
|
394
|
+
? messageThread.customization_info.emoji
|
395
|
+
: null,
|
396
|
+
color:
|
397
|
+
messageThread.customization_info &&
|
398
|
+
messageThread.customization_info.outgoing_bubble_color
|
399
|
+
? messageThread.customization_info.outgoing_bubble_color.slice(2)
|
400
|
+
: null,
|
401
|
+
threadTheme: messageThread.thread_theme,
|
402
|
+
nicknames:
|
403
|
+
messageThread.customization_info &&
|
404
|
+
messageThread.customization_info.participant_customizations
|
405
|
+
? messageThread.customization_info.participant_customizations.reduce(
|
406
|
+
function (res, val) {
|
407
|
+
if (val.nickname) res[val.participant_id] = val.nickname;
|
408
|
+
return res;
|
409
|
+
},
|
410
|
+
{}
|
411
|
+
)
|
412
|
+
: {},
|
413
|
+
adminIDs: messageThread.thread_admins,
|
414
|
+
approvalMode: Boolean(messageThread.approval_mode),
|
415
|
+
approvalQueue: messageThread.group_approval_queue.nodes.map(a => ({
|
416
|
+
inviterID: a.inviter.id,
|
417
|
+
requesterID: a.requester.id,
|
418
|
+
timestamp: a.request_timestamp,
|
419
|
+
request_source: a.request_source // @Undocumented
|
420
|
+
})),
|
421
|
+
|
422
|
+
// @Undocumented
|
423
|
+
reactionsMuteMode: messageThread.reactions_mute_mode.toLowerCase(),
|
424
|
+
mentionsMuteMode: messageThread.mentions_mute_mode.toLowerCase(),
|
425
|
+
isPinProtected: messageThread.is_pin_protected,
|
426
|
+
relatedPageThread: messageThread.related_page_thread,
|
427
|
+
|
428
|
+
// @Legacy
|
429
|
+
name: messageThread.name,
|
430
|
+
snippet: snippetText,
|
431
|
+
snippetSender: snippetID,
|
432
|
+
snippetAttachments: [],
|
433
|
+
serverTimestamp: messageThread.updated_time_precise,
|
434
|
+
imageSrc: messageThread.image ? messageThread.image.uri : null,
|
435
|
+
isCanonicalUser: messageThread.is_canonical_neo_user,
|
436
|
+
isCanonical: messageThread.thread_type != "GROUP",
|
437
|
+
recipientsLoadable: true,
|
438
|
+
hasEmailParticipant: false,
|
439
|
+
readOnly: false,
|
440
|
+
canReply: messageThread.cannot_reply_reason == null,
|
441
|
+
lastMessageTimestamp: messageThread.last_message
|
442
|
+
? messageThread.last_message.timestamp_precise
|
443
|
+
: null,
|
444
|
+
lastMessageType: "message",
|
445
|
+
lastReadTimestamp: lastReadTimestamp,
|
446
|
+
threadType: messageThread.thread_type == "GROUP" ? 2 : 1,
|
447
|
+
|
448
|
+
// update in Wed, 13 Jul 2022 19:41:12 +0700
|
449
|
+
inviteLink: {
|
450
|
+
enable: messageThread.joinable_mode ? messageThread.joinable_mode.mode == 1 : false,
|
451
|
+
link: messageThread.joinable_mode ? messageThread.joinable_mode.link : null
|
452
|
+
}
|
453
|
+
};
|
454
|
+
}
|
455
|
+
|
456
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
457
|
+
return function getThreadInfoGraphQL(threadID, callback) {
|
458
|
+
let resolveFunc = function () { };
|
459
|
+
let rejectFunc = function () { };
|
460
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
461
|
+
resolveFunc = resolve;
|
462
|
+
rejectFunc = reject;
|
463
|
+
});
|
464
|
+
|
465
|
+
if (utils.getType(callback) != "Function" && utils.getType(callback) != "AsyncFunction") {
|
466
|
+
callback = function (err, data) {
|
467
|
+
if (err) {
|
468
|
+
return rejectFunc(err);
|
469
|
+
}
|
470
|
+
resolveFunc(data);
|
471
|
+
};
|
472
|
+
}
|
473
|
+
|
474
|
+
if (utils.getType(threadID) !== "Array") {
|
475
|
+
threadID = [threadID];
|
476
|
+
}
|
477
|
+
|
478
|
+
let form = {};
|
479
|
+
// `queries` has to be a string. I couldn't tell from the dev console. This
|
480
|
+
// took me a really long time to figure out. I deserve a cookie for this.
|
481
|
+
threadID.map(function (t, i) {
|
482
|
+
form["o" + i] = {
|
483
|
+
doc_id: "3449967031715030",
|
484
|
+
query_params: {
|
485
|
+
id: t,
|
486
|
+
message_limit: 0,
|
487
|
+
load_messages: false,
|
488
|
+
load_read_receipts: false,
|
489
|
+
before: null
|
490
|
+
}
|
491
|
+
};
|
492
|
+
});
|
493
|
+
|
494
|
+
form = {
|
495
|
+
queries: JSON.stringify(form),
|
496
|
+
batch_name: "MessengerGraphQLThreadFetcher"
|
497
|
+
};
|
498
|
+
|
499
|
+
defaultFuncs
|
500
|
+
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
501
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
502
|
+
.then(function (resData) {
|
503
|
+
|
504
|
+
if (resData.error) {
|
505
|
+
throw resData;
|
506
|
+
}
|
507
|
+
// This returns us an array of things. The last one is the success /
|
508
|
+
// failure one.
|
509
|
+
// @TODO What do we do in this case?
|
510
|
+
// if (resData[resData.length - 1].error_results !== 0) {
|
511
|
+
// throw resData[0].o0.errors[0];
|
512
|
+
// }
|
513
|
+
// if (!resData[0].o0.data.message_thread) {
|
514
|
+
// throw new Error("can't find this thread");
|
515
|
+
// }
|
516
|
+
const threadInfos = {};
|
517
|
+
for (let i = resData.length - 2; i >= 0; i--) {
|
518
|
+
const threadInfo = formatThreadGraphQLResponse(resData[i][Object.keys(resData[i])[0]].data);
|
519
|
+
threadInfos[threadInfo?.threadID || threadID[threadID.length - 1 - i]] = threadInfo;
|
520
|
+
}
|
521
|
+
if (Object.values(threadInfos).length == 1) {
|
522
|
+
callback(null, Object.values(threadInfos)[0]);
|
523
|
+
}
|
524
|
+
else {
|
525
|
+
callback(null, threadInfos);
|
526
|
+
}
|
527
|
+
})
|
528
|
+
.catch(function (err) {
|
529
|
+
log.error("getThreadInfoGraphQL", err);
|
530
|
+
return callback(err);
|
531
|
+
});
|
532
|
+
|
533
|
+
return returnPromise;
|
534
|
+
};
|
302
535
|
};
|
@@ -1,117 +1,119 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
const { generateOfflineThreadingID } = require("../utils");
|
5
6
|
|
6
7
|
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
function setMessageReactionNoMqtt(reaction, messageID, callback) {
|
9
|
+
var resolveFunc = function () {};
|
10
|
+
var rejectFunc = function () {};
|
11
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
12
|
+
resolveFunc = resolve;
|
13
|
+
rejectFunc = reject;
|
14
|
+
});
|
15
|
+
if (!callback) {
|
16
|
+
callback = function (err, friendList) {
|
17
|
+
if (err) {
|
18
|
+
return rejectFunc(err);
|
19
|
+
}
|
20
|
+
resolveFunc(friendList);
|
21
|
+
};
|
22
|
+
}
|
23
|
+
var variables = {
|
24
|
+
data: {
|
25
|
+
client_mutation_id: ctx.clientMutationId++,
|
26
|
+
actor_id: ctx.userID,
|
27
|
+
action: reaction == "" ? "REMOVE_REACTION" : "ADD_REACTION",
|
28
|
+
message_id: messageID,
|
29
|
+
reaction: reaction,
|
30
|
+
},
|
31
|
+
};
|
32
|
+
var qs = {
|
33
|
+
doc_id: "1491398900900362",
|
34
|
+
variables: JSON.stringify(variables),
|
35
|
+
dpr: 1,
|
36
|
+
};
|
37
|
+
defaultFuncs
|
38
|
+
.postFormData(
|
39
|
+
"https://www.facebook.com/webgraphql/mutation/",
|
40
|
+
ctx.jar,
|
41
|
+
{},
|
42
|
+
qs,
|
43
|
+
)
|
44
|
+
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
|
45
|
+
.then(function (resData) {
|
46
|
+
if (!resData) {
|
47
|
+
throw { error: "setReaction returned empty object." };
|
48
|
+
}
|
49
|
+
if (resData.error) {
|
50
|
+
throw resData;
|
51
|
+
}
|
52
|
+
callback(null);
|
53
|
+
})
|
54
|
+
.catch(function (err) {
|
55
|
+
log.error("setReaction", err);
|
56
|
+
return callback(err);
|
57
|
+
});
|
14
58
|
|
15
|
-
|
16
|
-
|
17
|
-
if (err) {
|
18
|
-
return rejectFunc(err);
|
19
|
-
}
|
20
|
-
resolveFunc(friendList);
|
21
|
-
};
|
22
|
-
}
|
59
|
+
return returnPromise;
|
60
|
+
}
|
23
61
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
message_id: messageID,
|
83
|
-
reaction: reaction
|
84
|
-
}
|
85
|
-
};
|
86
|
-
|
87
|
-
const qs = {
|
88
|
-
doc_id: "1491398900900362",
|
89
|
-
variables: JSON.stringify(variables),
|
90
|
-
dpr: 1
|
91
|
-
};
|
92
|
-
|
93
|
-
defaultFuncs
|
94
|
-
.postFormData(
|
95
|
-
"https://www.facebook.com/webgraphql/mutation/",
|
96
|
-
ctx.jar,
|
97
|
-
{},
|
98
|
-
qs
|
99
|
-
)
|
100
|
-
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
|
101
|
-
.then(function (resData) {
|
102
|
-
if (!resData) {
|
103
|
-
throw { error: "setReaction returned empty object." };
|
104
|
-
}
|
105
|
-
if (resData.error) {
|
106
|
-
throw resData;
|
107
|
-
}
|
108
|
-
callback(null);
|
109
|
-
})
|
110
|
-
.catch(function (err) {
|
111
|
-
log.error("setReaction", err);
|
112
|
-
return callback(err);
|
113
|
-
});
|
114
|
-
|
115
|
-
return returnPromise;
|
116
|
-
};
|
117
|
-
};
|
62
|
+
function setMessageReactionMqtt(reaction, messageID, threadID, callback) {
|
63
|
+
if (!ctx.mqttClient) {
|
64
|
+
throw new Error("Not connected to MQTT");
|
65
|
+
}
|
66
|
+
ctx.wsReqNumber += 1;
|
67
|
+
let taskNumber = ++ctx.wsTaskNumber;
|
68
|
+
const taskPayload = {
|
69
|
+
thread_key: threadID,
|
70
|
+
timestamp_ms: getCurrentTimestamp(),
|
71
|
+
message_id: messageID,
|
72
|
+
reaction: reaction,
|
73
|
+
actor_id: ctx.userID,
|
74
|
+
reaction_style: null,
|
75
|
+
sync_group: 1,
|
76
|
+
send_attribution: Math.random() < 0.5 ? 65537 : 524289,
|
77
|
+
};
|
78
|
+
const task = {
|
79
|
+
failure_count: null,
|
80
|
+
label: "29",
|
81
|
+
payload: JSON.stringify(taskPayload),
|
82
|
+
queue_name: JSON.stringify(["reaction", messageID]),
|
83
|
+
task_id: taskNumber,
|
84
|
+
};
|
85
|
+
const content = {
|
86
|
+
app_id: "2220391788200892",
|
87
|
+
payload: JSON.stringify({
|
88
|
+
data_trace_id: null,
|
89
|
+
epoch_id: parseInt(generateOfflineThreadingID()),
|
90
|
+
tasks: [task],
|
91
|
+
version_id: "7158486590867448",
|
92
|
+
}),
|
93
|
+
request_id: ctx.wsReqNumber,
|
94
|
+
type: 3,
|
95
|
+
};
|
96
|
+
if (typeof callback === "function") {
|
97
|
+
ctx["tasks"].set(taskNumber, {
|
98
|
+
type: "set_message_reaction",
|
99
|
+
callback: callback,
|
100
|
+
});
|
101
|
+
}
|
102
|
+
ctx.mqttClient.publish("/ls_req", JSON.stringify(content), {
|
103
|
+
qos: 1,
|
104
|
+
retain: false,
|
105
|
+
});
|
106
|
+
}
|
107
|
+
return function setMessageReaction(reaction, messageID, threadID, callback) {
|
108
|
+
if (ctx.mqttClient) {
|
109
|
+
try {
|
110
|
+
setMessageReactionMqtt(reaction, messageID, threadID, callback);
|
111
|
+
callback();
|
112
|
+
} catch (e) {
|
113
|
+
setMessageReactionNoMqtt(reaction, messageID, callback);
|
114
|
+
}
|
115
|
+
} else {
|
116
|
+
setMessageReactionNoMqtt(reaction, messageID, callback);
|
117
|
+
}
|
118
|
+
};
|
119
|
+
};
|