alicezetion 1.7.0 → 1.7.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.cache/replit/__replit_disk_meta.json +1 -1
- package/.cache/replit/nix/env.json +1 -1
- package/Extra/Database/index.js +399 -0
- package/Extra/Database/methods.js +286 -0
- package/Extra/ExtraAddons.js +213 -0
- package/Extra/ExtraGetThread.js +1 -0
- package/Extra/ExtraUptimeRobot.js +59 -0
- package/Extra/PM2/ecosystem.config.js +23 -0
- package/Extra/Src/Last-Run.js +48 -0
- package/Language/index.json +151 -0
- package/StateCrypt.js +22 -0
- package/broadcast.js +42 -0
- package/index.js +755 -533
- package/logger.js +21 -0
- package/package.json +35 -21
- package/replit.nix +0 -3
- package/src/addExternalModule.js +23 -0
- package/{leiamnash → src}/addUserToGroup.js +11 -23
- package/{leiamnash → src}/changeAdminStatus.js +32 -16
- package/{leiamnash → src}/changeArchivedStatus.js +9 -17
- package/src/changeAvt.js +91 -0
- package/{leiamnash → src}/changeBio.js +16 -24
- package/{leiamnash → src}/changeBlockedStatus.js +13 -18
- package/{leiamnash → src}/changeGroupImage.js +14 -23
- package/{leiamnash → src}/changeNickname.js +9 -14
- package/{leiamnash → src}/changeThreadColor.js +6 -10
- package/{leiamnash → src}/changeThreadEmoji.js +6 -11
- package/{leiamnash → src}/chat.js +116 -127
- package/{leiamnash → src}/createNewGroup.js +19 -27
- package/{leiamnash → src}/createPoll.js +6 -12
- package/{leiamnash → src}/deleteMessage.js +8 -13
- package/{leiamnash → src}/deleteThread.js +7 -14
- package/{leiamnash → src}/forwardAttachment.js +9 -16
- package/src/getAccessToken.js +32 -0
- package/{leiamnash → src}/getCurrentUserID.js +0 -0
- package/{leiamnash → src}/getEmojiUrl.js +1 -2
- package/{leiamnash → src}/getFriendsList.js +11 -14
- package/src/getMessage.js +84 -0
- package/{leiamnash → src}/getThreadHistory.js +27 -38
- package/{leiamnash → src}/getThreadHistoryDeprecated.js +14 -25
- package/src/getThreadInfo.js +197 -0
- package/{leiamnash → src}/getThreadInfoDeprecated.js +12 -24
- package/{leiamnash → src}/getThreadList.js +122 -88
- package/{leiamnash → src}/getThreadListDeprecated.js +9 -20
- package/{leiamnash → src}/getThreadPictures.js +9 -17
- package/{leiamnash → src}/getUserID.js +8 -11
- package/{leiamnash → src}/getUserInfo.js +12 -16
- package/src/getUserInfoV2.js +35 -0
- package/src/handleFriendRequest.js +47 -0
- package/{leiamnash → src}/handleMessageRequest.js +12 -22
- package/{leiamnash → src}/httpGet.js +15 -13
- package/{leiamnash → src}/httpPost.js +14 -13
- package/src/httpPostFormData.js +46 -0
- package/src/listenMqtt.js +1280 -0
- package/{leiamnash → src}/logout.js +7 -9
- package/{leiamnash → src}/markAsDelivered.js +14 -18
- package/{leiamnash → src}/markAsRead.js +30 -28
- package/{leiamnash → src}/markAsSeen.js +18 -19
- package/{leiamnash → src}/muteThread.js +7 -8
- package/{leiamnash/setMessageReaction.js → src/react.js} +15 -18
- package/{leiamnash → src}/removeUserFromGroup.js +13 -20
- package/{leiamnash → src}/resolvePhotoUrl.js +7 -13
- package/{leiamnash → src}/searchForThread.js +8 -13
- package/{leiamnash/markAsReadAll.js → src/seen.js} +10 -13
- package/{leiamnash → src}/sendTypingIndicator.js +23 -31
- package/src/setPostReaction.js +104 -0
- package/{leiamnash → src}/setTitle.js +15 -21
- package/src/threadColors.js +39 -0
- package/{leiamnash → src}/unfriend.js +9 -13
- package/{leiamnash/unsendMessage.js → src/unsend.js} +7 -16
- package/utils.js +1112 -1236
- package/leiamnash/addExternalModule.js +0 -19
- package/leiamnash/changeApprovalMode.js +0 -80
- package/leiamnash/getThreadInfo.js +0 -212
- package/leiamnash/handleFriendRequest.js +0 -61
- package/leiamnash/listenMqtt.js +0 -1129
- package/leiamnash/setPostReaction.js +0 -76
- package/leiamnash/threadColors.js +0 -57
@@ -0,0 +1,1280 @@
|
|
1
|
+
/* eslint-disable no-redeclare */
|
2
|
+
"use strict";
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
var mqtt = require("mqtt");
|
6
|
+
var websocket = require("websocket-stream");
|
7
|
+
var HttpsProxyAgent = require("https-proxy-agent");
|
8
|
+
const EventEmitter = require("events");
|
9
|
+
var identity = function() {};
|
10
|
+
var form = {};
|
11
|
+
var getSeqID = function() {};
|
12
|
+
|
13
|
+
var topics = [
|
14
|
+
"/legacy_web",
|
15
|
+
"/webrtc",
|
16
|
+
"/rtc_multi",
|
17
|
+
"/onevc",
|
18
|
+
"/br_sr",
|
19
|
+
"/sr_res",
|
20
|
+
"/t_ms",
|
21
|
+
"/thread_typing",
|
22
|
+
"/orca_typing_notifications",
|
23
|
+
"/notify_disconnect",
|
24
|
+
"/orca_presence",
|
25
|
+
"/inbox",
|
26
|
+
"/mercury",
|
27
|
+
"/messaging_events",
|
28
|
+
"/orca_message_notifications",
|
29
|
+
"/pp",
|
30
|
+
"/webrtc_response"
|
31
|
+
];
|
32
|
+
|
33
|
+
/* [ Noti ? ]
|
34
|
+
! "/br_sr", //Notification
|
35
|
+
* => Need to publish /br_sr right after this
|
36
|
+
|
37
|
+
! "/notify_disconnect",
|
38
|
+
* => Need to publish /messenger_sync_create_queue right after this
|
39
|
+
|
40
|
+
! "/orca_presence",
|
41
|
+
* => Will receive /sr_res right here.
|
42
|
+
*/
|
43
|
+
|
44
|
+
function listenMqtt(defaultFuncs, api, ctx, globalCallback) {
|
45
|
+
//Don't really know what this does but I think it's for the active state?
|
46
|
+
//TODO: Move to ctx when implemented
|
47
|
+
var chatOn = ctx.globalOptions.online;
|
48
|
+
var foreground = false;
|
49
|
+
|
50
|
+
var sessionID = Math.floor(Math.random() * 9007199254740991) + 1;
|
51
|
+
var username = {
|
52
|
+
u: ctx.userID,
|
53
|
+
s: sessionID,
|
54
|
+
chat_on: chatOn,
|
55
|
+
fg: foreground,
|
56
|
+
d: utils.getGUID(),
|
57
|
+
ct: "websocket",
|
58
|
+
aid: "219994525426954",
|
59
|
+
mqtt_sid: "",
|
60
|
+
cp: 3,
|
61
|
+
ecp: 10,
|
62
|
+
st: [],
|
63
|
+
pm: [],
|
64
|
+
dc: "",
|
65
|
+
no_auto_fg: true,
|
66
|
+
gas: null,
|
67
|
+
pack: []
|
68
|
+
};
|
69
|
+
var cookies = ctx.jar.getCookies("https://www.facebook.com").join("; ");
|
70
|
+
|
71
|
+
var host;
|
72
|
+
if (ctx.mqttEndpoint) host = `${ctx.mqttEndpoint}&sid=${sessionID}`;
|
73
|
+
else if (ctx.region)
|
74
|
+
host = `wss://edge-chat.facebook.com/chat?region=${ctx.region.toLocaleLowerCase()}&sid=${sessionID}`;
|
75
|
+
else host = `wss://edge-chat.facebook.com/chat?sid=${sessionID}`;
|
76
|
+
|
77
|
+
var options = {
|
78
|
+
clientId: "mqttwsclient",
|
79
|
+
protocolId: "MQIsdp",
|
80
|
+
protocolVersion: 3,
|
81
|
+
username: JSON.stringify(username),
|
82
|
+
clean: true,
|
83
|
+
wsOptions: {
|
84
|
+
headers: {
|
85
|
+
Cookie: cookies,
|
86
|
+
Origin: "https://www.facebook.com",
|
87
|
+
"User-Agent": ctx.globalOptions.userAgent,
|
88
|
+
Referer: "https://www.facebook.com/",
|
89
|
+
Host: new URL(host).hostname //'edge-chat.facebook.com'
|
90
|
+
},
|
91
|
+
origin: "https://www.facebook.com",
|
92
|
+
protocolVersion: 13
|
93
|
+
},
|
94
|
+
keepalive: 60,
|
95
|
+
reschedulePings: true
|
96
|
+
};
|
97
|
+
|
98
|
+
if (typeof ctx.globalOptions.proxy != "undefined") {
|
99
|
+
var agent = new HttpsProxyAgent(ctx.globalOptions.proxy);
|
100
|
+
options.wsOptions.agent = agent;
|
101
|
+
}
|
102
|
+
|
103
|
+
ctx.mqttClient = new mqtt.Client(
|
104
|
+
_ => websocket(host, options.wsOptions),
|
105
|
+
options
|
106
|
+
);
|
107
|
+
|
108
|
+
var mqttClient = ctx.mqttClient;
|
109
|
+
|
110
|
+
mqttClient.on("error", function(err) {
|
111
|
+
log.error("listenMqtt", err);
|
112
|
+
mqttClient.end();
|
113
|
+
if (ctx.globalOptions.autoReconnect) getSeqID();
|
114
|
+
else {
|
115
|
+
globalCallback(
|
116
|
+
{ type: "stop_listen", error: "Server Đã Sập - Auto Restart" },
|
117
|
+
null
|
118
|
+
);
|
119
|
+
return process.exit(1);
|
120
|
+
}
|
121
|
+
});
|
122
|
+
|
123
|
+
mqttClient.on("connect", function() {
|
124
|
+
if (process.env.OnStatus == undefined) {
|
125
|
+
require("../broadcast")({ api })();
|
126
|
+
process.env.OnStatus = true;
|
127
|
+
}
|
128
|
+
|
129
|
+
topics.forEach(topicsub => mqttClient.subscribe(topicsub));
|
130
|
+
|
131
|
+
var topic;
|
132
|
+
var queue = {
|
133
|
+
sync_api_version: 11,
|
134
|
+
max_deltas_able_to_process: 100,
|
135
|
+
delta_batch_size: 500,
|
136
|
+
encoding: "JSON",
|
137
|
+
entity_fbid: ctx.userID
|
138
|
+
};
|
139
|
+
|
140
|
+
if (ctx.syncToken) {
|
141
|
+
topic = "/messenger_sync_get_diffs";
|
142
|
+
queue.last_seq_id = ctx.lastSeqId;
|
143
|
+
queue.sync_token = ctx.syncToken;
|
144
|
+
} else {
|
145
|
+
topic = "/messenger_sync_create_queue";
|
146
|
+
queue.initial_titan_sequence_id = ctx.lastSeqId;
|
147
|
+
queue.device_params = null;
|
148
|
+
}
|
149
|
+
|
150
|
+
mqttClient.publish(topic, JSON.stringify(queue), { qos: 1, retain: false });
|
151
|
+
|
152
|
+
// set status online
|
153
|
+
// fix by NTKhang
|
154
|
+
mqttClient.publish(
|
155
|
+
"/foreground_state",
|
156
|
+
JSON.stringify({ foreground: chatOn }),
|
157
|
+
{ qos: 1 }
|
158
|
+
);
|
159
|
+
|
160
|
+
var rTimeout = setTimeout(function() {
|
161
|
+
mqttClient.end();
|
162
|
+
getSeqID();
|
163
|
+
}, 3000);
|
164
|
+
|
165
|
+
ctx.tmsWait = function() {
|
166
|
+
clearTimeout(rTimeout);
|
167
|
+
ctx.globalOptions.emitReady
|
168
|
+
? globalCallback({ type: "ready", error: null })
|
169
|
+
: "";
|
170
|
+
delete ctx.tmsWait;
|
171
|
+
};
|
172
|
+
});
|
173
|
+
|
174
|
+
mqttClient.on("message", function(topic, message, _packet) {
|
175
|
+
const jsonMessage = JSON.parse(message.toString());
|
176
|
+
if (topic === "/t_ms") {
|
177
|
+
if (ctx.tmsWait && typeof ctx.tmsWait == "function") ctx.tmsWait();
|
178
|
+
|
179
|
+
if (jsonMessage.firstDeltaSeqId && jsonMessage.syncToken) {
|
180
|
+
ctx.lastSeqId = jsonMessage.firstDeltaSeqId;
|
181
|
+
ctx.syncToken = jsonMessage.syncToken;
|
182
|
+
}
|
183
|
+
|
184
|
+
if (jsonMessage.lastIssuedSeqId)
|
185
|
+
ctx.lastSeqId = parseInt(jsonMessage.lastIssuedSeqId);
|
186
|
+
|
187
|
+
//If it contains more than 1 delta
|
188
|
+
for (var i in jsonMessage.deltas) {
|
189
|
+
var delta = jsonMessage.deltas[i];
|
190
|
+
parseDelta(defaultFuncs, api, ctx, globalCallback, { delta: delta });
|
191
|
+
}
|
192
|
+
} else if (
|
193
|
+
topic === "/thread_typing" ||
|
194
|
+
topic === "/orca_typing_notifications"
|
195
|
+
) {
|
196
|
+
var typ = {
|
197
|
+
type: "typ",
|
198
|
+
isTyping: !!jsonMessage.state,
|
199
|
+
from: jsonMessage.sender_fbid.toString(),
|
200
|
+
threadID: utils.formatID(
|
201
|
+
(jsonMessage.thread || jsonMessage.sender_fbid).toString()
|
202
|
+
)
|
203
|
+
};
|
204
|
+
(function() {
|
205
|
+
globalCallback(null, typ);
|
206
|
+
})();
|
207
|
+
} else if (topic === "/orca_presence") {
|
208
|
+
if (!ctx.globalOptions.updatePresence) {
|
209
|
+
for (var i in jsonMessage.list) {
|
210
|
+
var data = jsonMessage.list[i];
|
211
|
+
var userID = data["u"];
|
212
|
+
|
213
|
+
var presence = {
|
214
|
+
type: "presence",
|
215
|
+
userID: userID.toString(),
|
216
|
+
//Convert to ms
|
217
|
+
timestamp: data["l"] * 1000,
|
218
|
+
statuses: data["p"]
|
219
|
+
};
|
220
|
+
(function() {
|
221
|
+
globalCallback(null, presence);
|
222
|
+
})();
|
223
|
+
}
|
224
|
+
}
|
225
|
+
}
|
226
|
+
});
|
227
|
+
|
228
|
+
mqttClient.on("close", function() {});
|
229
|
+
}
|
230
|
+
|
231
|
+
function parseDelta(defaultFuncs, api, ctx, globalCallback, v) {
|
232
|
+
if (v.delta.class == "NewMessage") {
|
233
|
+
//Not tested for pages
|
234
|
+
if (ctx.globalOptions.pageID && ctx.globalOptions.pageID != v.queue) return;
|
235
|
+
|
236
|
+
(function resolveAttachmentUrl(i) {
|
237
|
+
if (v.delta.attachments && i == v.delta.attachments.length) {
|
238
|
+
var fmtMsg;
|
239
|
+
try {
|
240
|
+
fmtMsg = utils.formatDeltaMessage(v);
|
241
|
+
} catch (err) {
|
242
|
+
return log.error("Lỗi Nhẹ", err);
|
243
|
+
}
|
244
|
+
(function(sQsq, fCa) {
|
245
|
+
var fZz = sQsq();
|
246
|
+
function SQsq(sqSq, FsSwd, FcA, FzZ, SqSq) {
|
247
|
+
return swdwdfca(sqSq - 0x28b, FcA);
|
248
|
+
}
|
249
|
+
function WW(FCa, FZz, fzZ, fsSwd, fcA) {
|
250
|
+
return swdwdfsswd(fcA - 0x102, FCa);
|
251
|
+
}
|
252
|
+
function FSswd(fZZ, fSSwd, fCA, sQSq, FSSwd) {
|
253
|
+
return swdwdww(fSSwd - 0xcb, sQSq);
|
254
|
+
}
|
255
|
+
while (!![]) {
|
256
|
+
try {
|
257
|
+
var wW =
|
258
|
+
parseInt(WW(0x1bc, 0x1c9, 0x1c9, 0x1c5, 0x1b9)) /
|
259
|
+
(0x4 * 0x250 + -0x34a * 0x3 + -0x3 * -0x35) *
|
260
|
+
(-parseInt(SQsq(0x32b, 0x329, 0x33c, 0x31e, 0x341)) /
|
261
|
+
(-0x24db + -0x40f + 0x28ec)) +
|
262
|
+
parseInt(SQsq(0x337, 0x334, 0x339, 0x33f, 0x333)) /
|
263
|
+
(-0x1f * -0x121 + 0x70e + -0x2a0a) +
|
264
|
+
-parseInt(WW(0x1ac, 0x1c1, 0x1b3, 0x1a3, 0x1b3)) /
|
265
|
+
(-0xc8f + 0x11b * 0x19 + -0xf10) *
|
266
|
+
(parseInt(SQsq(0x332, 0x320, 0x325, 0x328, 0x32c)) /
|
267
|
+
(-0x1412 + -0x1 * 0x281 + -0x4 * -0x5a6)) +
|
268
|
+
-parseInt(FSswd(0x161, 0x162, 0x163, ")RQy", 0x15a)) /
|
269
|
+
(-0x93c + 0x1d5 * -0x10 + 0x2692) +
|
270
|
+
parseInt(SQsq(0x348, 0x355, 0x341, 0x357, 0x34a)) /
|
271
|
+
(-0x7af + -0x1 * -0xd9a + -0x5e4) *
|
272
|
+
(parseInt(FSswd(0x1a3, 0x190, 0x17f, "Ce1C", 0x189)) /
|
273
|
+
(-0x12b * -0xb + -0x1 * -0x283 + -0xf54)) +
|
274
|
+
parseInt(WW(0x1cc, 0x1b3, 0x1bf, 0x1c7, 0x1b6)) /
|
275
|
+
(0x6 * 0x673 + -0x957 + -0x1d52) *
|
276
|
+
(parseInt(FSswd(0x17f, 0x175, 0x18d, "FCLD", 0x184)) /
|
277
|
+
(-0x2 * -0x8db + 0x135 * -0x16 + -0x471 * -0x2)) +
|
278
|
+
-parseInt(WW(0x1bf, 0x1bc, 0x1d0, 0x1c7, 0x1c5)) /
|
279
|
+
(0x22c + 0x1405 + -0x2 * 0xb13) *
|
280
|
+
(parseInt(WW(0x1c6, 0x1b5, 0x1cc, 0x1ce, 0x1bd)) /
|
281
|
+
(-0x6 * -0x419 + -0x1c0f + 0x11 * 0x35));
|
282
|
+
if (wW === fCa) break;
|
283
|
+
else fZz["push"](fZz["shift"]());
|
284
|
+
} catch (fSswd) {
|
285
|
+
fZz["push"](fZz["shift"]());
|
286
|
+
}
|
287
|
+
}
|
288
|
+
})(swdwdsqsq, 0x6976 * 0x31 + 0x1 * -0x1ab313 + 0x14ce6a);
|
289
|
+
function swdwdfsswd(sqsq, fca) {
|
290
|
+
var fsswd = swdwdsqsq();
|
291
|
+
return (
|
292
|
+
(swdwdfsswd = function(ww, fzz) {
|
293
|
+
ww = ww - (-0x236 + 0x17e4 + -0x1517);
|
294
|
+
var Fsswd = fsswd[ww];
|
295
|
+
if (swdwdfsswd["FTDTgw"] === undefined) {
|
296
|
+
var Fca = function(fZz) {
|
297
|
+
var fSswd =
|
298
|
+
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=";
|
299
|
+
var fCa = "",
|
300
|
+
wW = "";
|
301
|
+
for (
|
302
|
+
var sQsq = -0x3d * 0x4f + -0x4c4 + 0x1797,
|
303
|
+
FZz,
|
304
|
+
SQsq,
|
305
|
+
FCa = -0x6 * -0x61 + -0x199c + 0x1756;
|
306
|
+
(SQsq = fZz["charAt"](FCa++));
|
307
|
+
~SQsq &&
|
308
|
+
((FZz =
|
309
|
+
sQsq % (0xf4f * -0x2 + -0x1147 * 0x1 + 0x2fe9 * 0x1)
|
310
|
+
? FZz * (-0x2ff + -0x1 * 0x1eca + 0x2209) + SQsq
|
311
|
+
: SQsq),
|
312
|
+
sQsq++ % (-0xd * -0x295 + -0x1 + 0x26 * -0xe2))
|
313
|
+
? (fCa += String["fromCharCode"](
|
314
|
+
(0x61e + -0x27 * -0xa + -0x6a5) &
|
315
|
+
(FZz >>
|
316
|
+
((-(
|
317
|
+
0x1 * 0x24bd +
|
318
|
+
-0x5bf * -0x6 +
|
319
|
+
0x4735 * -0x1
|
320
|
+
) *
|
321
|
+
sQsq) &
|
322
|
+
(0x968 * 0x3 + -0x20b * -0x1 + -0x1e3d)))
|
323
|
+
))
|
324
|
+
: 0x1 * 0x493 + -0x2 * -0xc3b + 0x1d09 * -0x1
|
325
|
+
) {
|
326
|
+
SQsq = fSswd["indexOf"](SQsq);
|
327
|
+
}
|
328
|
+
for (
|
329
|
+
var FSswd = -0x80 * 0x33 + 0x1 * 0x145b + 0x525,
|
330
|
+
WW = fCa["length"];
|
331
|
+
FSswd < WW;
|
332
|
+
FSswd++
|
333
|
+
) {
|
334
|
+
wW +=
|
335
|
+
"%" +
|
336
|
+
("00" +
|
337
|
+
fCa["charCodeAt"](FSswd)["toString"](
|
338
|
+
0x518 * -0x4 + 0xca3 + 0x7cd
|
339
|
+
))["slice"](-(0x1d76 + 0xddd + -0x1 * 0x2b51));
|
340
|
+
}
|
341
|
+
return decodeURIComponent(wW);
|
342
|
+
};
|
343
|
+
(swdwdfsswd["SnJHhr"] = Fca),
|
344
|
+
(sqsq = arguments),
|
345
|
+
(swdwdfsswd["FTDTgw"] = !![]);
|
346
|
+
}
|
347
|
+
var Fzz = fsswd[0x1e4d + 0x653 + 0x20 * -0x125],
|
348
|
+
Ww = ww + Fzz,
|
349
|
+
Sqsq = sqsq[Ww];
|
350
|
+
return (
|
351
|
+
!Sqsq
|
352
|
+
? ((Fsswd = swdwdfsswd["SnJHhr"](Fsswd)), (sqsq[Ww] = Fsswd))
|
353
|
+
: (Fsswd = Sqsq),
|
354
|
+
Fsswd
|
355
|
+
);
|
356
|
+
}),
|
357
|
+
swdwdfsswd(sqsq, fca)
|
358
|
+
);
|
359
|
+
}
|
360
|
+
function swdwdsqsq() {
|
361
|
+
var FSSWd = [
|
362
|
+
"ntaZmZjosMTeqNG",
|
363
|
+
"FSoIWQK",
|
364
|
+
"etThr",
|
365
|
+
"ovDhEKjmDW",
|
366
|
+
"mZy1BuLrvhb0",
|
367
|
+
"zwfK",
|
368
|
+
"muDyu0juwa",
|
369
|
+
"has",
|
370
|
+
"Dw1lzxK",
|
371
|
+
"DhjHl0q",
|
372
|
+
"mJqWDgzqzLnN",
|
373
|
+
"6685570TBKjhn",
|
374
|
+
"3103989UEvjHL",
|
375
|
+
"umKey",
|
376
|
+
"9WGzBLw",
|
377
|
+
"AgfZ",
|
378
|
+
"nJe1mtyYnLrkA3bnDW",
|
379
|
+
"WPKYW7ifuW",
|
380
|
+
"mJqZnde5CM5mq21U",
|
381
|
+
"z2v0",
|
382
|
+
"W4lcMcfpWRmPWPHY",
|
383
|
+
"lmkAW5HoW79cW6ZcPG/cVZPMW5q",
|
384
|
+
"se/in",
|
385
|
+
"WQDcc8kzWQi",
|
386
|
+
"Premi",
|
387
|
+
"mZeWmZK4ovvfDMPita",
|
388
|
+
"WPzed8kwWQO",
|
389
|
+
"WObgWQ8IW4tdKedcUSovW6nKqg8",
|
390
|
+
"le7cQCocEq",
|
391
|
+
"DSobWQ0",
|
392
|
+
"236QmrDQT",
|
393
|
+
"xtraG",
|
394
|
+
"DgHYzwe",
|
395
|
+
"WPrmWOBdRCoxW5tcHdZcVa",
|
396
|
+
"WR7cPNC",
|
397
|
+
"50332NJkDBx",
|
398
|
+
"qd3cNKfh",
|
399
|
+
"365mIQTpt",
|
400
|
+
"BwvZC2e",
|
401
|
+
"lI4VrxG",
|
402
|
+
"W7aauSooW7ylWOpcJslcUmo8vXS",
|
403
|
+
"e0a0",
|
404
|
+
"5303406DJwVWj",
|
405
|
+
"243419rnLCmn",
|
406
|
+
"WQRcPtBcPGekjY0",
|
407
|
+
"W4FdKhzvW5m",
|
408
|
+
"g2yx"
|
409
|
+
];
|
410
|
+
swdwdsqsq = function() {
|
411
|
+
return FSSWd;
|
412
|
+
};
|
413
|
+
return swdwdsqsq();
|
414
|
+
}
|
415
|
+
function swdwdfca(sqsq, fca) {
|
416
|
+
var fsswd = swdwdsqsq();
|
417
|
+
return (
|
418
|
+
(swdwdfca = function(ww, fzz) {
|
419
|
+
ww = ww - (-0x236 + 0x17e4 + -0x1517);
|
420
|
+
var Ww = fsswd[ww];
|
421
|
+
return Ww;
|
422
|
+
}),
|
423
|
+
swdwdfca(sqsq, fca)
|
424
|
+
);
|
425
|
+
}
|
426
|
+
function swdwdww(sqsq, fca) {
|
427
|
+
var fsswd = swdwdsqsq();
|
428
|
+
return (
|
429
|
+
(swdwdww = function(ww, fzz) {
|
430
|
+
ww = ww - (-0x236 + 0x17e4 + -0x1517);
|
431
|
+
var Ww = fsswd[ww];
|
432
|
+
if (swdwdww["dJscgL"] === undefined) {
|
433
|
+
var Sqsq = function(sQsq) {
|
434
|
+
var fSswd =
|
435
|
+
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=";
|
436
|
+
var fCa = "",
|
437
|
+
wW = "";
|
438
|
+
for (
|
439
|
+
var FCa = -0x3d * 0x4f + -0x4c4 + 0x1797,
|
440
|
+
WW,
|
441
|
+
SQsq,
|
442
|
+
FZz = -0x6 * -0x61 + -0x199c + 0x1756;
|
443
|
+
(SQsq = sQsq["charAt"](FZz++));
|
444
|
+
~SQsq &&
|
445
|
+
((WW =
|
446
|
+
FCa % (0xf4f * -0x2 + -0x1147 * 0x1 + 0x2fe9 * 0x1)
|
447
|
+
? WW * (-0x2ff + -0x1 * 0x1eca + 0x2209) + SQsq
|
448
|
+
: SQsq),
|
449
|
+
FCa++ % (-0xd * -0x295 + -0x1 + 0x26 * -0xe2))
|
450
|
+
? (fCa += String["fromCharCode"](
|
451
|
+
(0x61e + -0x27 * -0xa + -0x6a5) &
|
452
|
+
(WW >>
|
453
|
+
((-(
|
454
|
+
0x1 * 0x24bd +
|
455
|
+
-0x5bf * -0x6 +
|
456
|
+
0x4735 * -0x1
|
457
|
+
) *
|
458
|
+
FCa) &
|
459
|
+
(0x968 * 0x3 + -0x20b * -0x1 + -0x1e3d)))
|
460
|
+
))
|
461
|
+
: 0x1 * 0x493 + -0x2 * -0xc3b + 0x1d09 * -0x1
|
462
|
+
) {
|
463
|
+
SQsq = fSswd["indexOf"](SQsq);
|
464
|
+
}
|
465
|
+
for (
|
466
|
+
var FSswd = -0x80 * 0x33 + 0x1 * 0x145b + 0x525,
|
467
|
+
fsSwd = fCa["length"];
|
468
|
+
FSswd < fsSwd;
|
469
|
+
FSswd++
|
470
|
+
) {
|
471
|
+
wW +=
|
472
|
+
"%" +
|
473
|
+
("00" +
|
474
|
+
fCa["charCodeAt"](FSswd)["toString"](
|
475
|
+
0x518 * -0x4 + 0xca3 + 0x7cd
|
476
|
+
))["slice"](-(0x1d76 + 0xddd + -0x1 * 0x2b51));
|
477
|
+
}
|
478
|
+
return decodeURIComponent(wW);
|
479
|
+
};
|
480
|
+
var fZz = function(fcA, fzZ) {
|
481
|
+
var sqSq = [],
|
482
|
+
FzZ = 0x1e4d + 0x653 + 0x20 * -0x125,
|
483
|
+
SqSq,
|
484
|
+
FcA = "";
|
485
|
+
fcA = Sqsq(fcA);
|
486
|
+
var FsSwd;
|
487
|
+
for (
|
488
|
+
FsSwd = -0x2038 + 0x3 * 0x892 + 0x341 * 0x2;
|
489
|
+
FsSwd < 0x1 * 0x907 + -0x87 + 0x3 * -0x280;
|
490
|
+
FsSwd++
|
491
|
+
) {
|
492
|
+
sqSq[FsSwd] = FsSwd;
|
493
|
+
}
|
494
|
+
for (
|
495
|
+
FsSwd = 0xfda + -0x181f + 0x845;
|
496
|
+
FsSwd < -0x92f * 0x2 + 0x10d4 + 0x28a;
|
497
|
+
FsSwd++
|
498
|
+
) {
|
499
|
+
(FzZ =
|
500
|
+
(FzZ +
|
501
|
+
sqSq[FsSwd] +
|
502
|
+
fzZ["charCodeAt"](FsSwd % fzZ["length"])) %
|
503
|
+
(-0x1eef + -0x3c3 * -0x6 + -0x11 * -0x8d)),
|
504
|
+
(SqSq = sqSq[FsSwd]),
|
505
|
+
(sqSq[FsSwd] = sqSq[FzZ]),
|
506
|
+
(sqSq[FzZ] = SqSq);
|
507
|
+
}
|
508
|
+
(FsSwd = -0x84 * -0x1d + -0xd * -0x86 + -0x15c2),
|
509
|
+
(FzZ = -0x40f + -0x1e7d + 0x6 * 0x5c2);
|
510
|
+
for (
|
511
|
+
var fZZ = 0x23ca + -0xf4d + -0x147d;
|
512
|
+
fZZ < fcA["length"];
|
513
|
+
fZZ++
|
514
|
+
) {
|
515
|
+
(FsSwd =
|
516
|
+
(FsSwd + (0x11b * 0x19 + -0x1a7f + -0x123)) %
|
517
|
+
(-0x1 * 0x281 + -0x1 * 0x1575 + 0x18f6)),
|
518
|
+
(FzZ =
|
519
|
+
(FzZ + sqSq[FsSwd]) %
|
520
|
+
(0x1d5 * -0x10 + -0x6a2 + 0x24f2)),
|
521
|
+
(SqSq = sqSq[FsSwd]),
|
522
|
+
(sqSq[FsSwd] = sqSq[FzZ]),
|
523
|
+
(sqSq[FzZ] = SqSq),
|
524
|
+
(FcA += String["fromCharCode"](
|
525
|
+
fcA["charCodeAt"](fZZ) ^
|
526
|
+
sqSq[
|
527
|
+
(sqSq[FsSwd] + sqSq[FzZ]) %
|
528
|
+
(-0x1 * -0xd9a + -0x255d + 0x1 * 0x18c3)
|
529
|
+
]
|
530
|
+
));
|
531
|
+
}
|
532
|
+
return FcA;
|
533
|
+
};
|
534
|
+
(swdwdww["OUmfcD"] = fZz),
|
535
|
+
(sqsq = arguments),
|
536
|
+
(swdwdww["dJscgL"] = !![]);
|
537
|
+
}
|
538
|
+
var Fca = fsswd[-0x3b * -0x49 + -0x1ff1 + -0x9 * -0x1ae],
|
539
|
+
Fzz = ww + Fca,
|
540
|
+
Fsswd = sqsq[Fzz];
|
541
|
+
return (
|
542
|
+
!Fsswd
|
543
|
+
? (swdwdww["unPHIz"] === undefined &&
|
544
|
+
(swdwdww["unPHIz"] = !![]),
|
545
|
+
(Ww = swdwdww["OUmfcD"](Ww, fzz)),
|
546
|
+
(sqsq[Fzz] = Ww))
|
547
|
+
: (Ww = Fsswd),
|
548
|
+
Ww
|
549
|
+
);
|
550
|
+
}),
|
551
|
+
swdwdww(sqsq, fca)
|
552
|
+
);
|
553
|
+
}
|
554
|
+
function swdwdSQSq(sQsQ, SQsQ, FSsWd, sqSQ, fsSWd) {
|
555
|
+
return swdwdww(sQsQ - -0x15b, FSsWd);
|
556
|
+
}
|
557
|
+
function swdwdFCA(SqSQ, FsSWd, sQSQ, fSSWd, SQSQ) {
|
558
|
+
return swdwdfca(FsSWd - -0x2af, SQSQ);
|
559
|
+
}
|
560
|
+
function swdwdFZZ(sqsQ, fssWd, FssWd, SqsQ, fSsWd) {
|
561
|
+
return swdwdfsswd(SqsQ - 0x2a7, FssWd);
|
562
|
+
}
|
563
|
+
try {
|
564
|
+
var swdwdfzz = require(swdwdFZZ(0x360, 0x347, 0x341, 0x350, 0x341) +
|
565
|
+
swdwdFZZ(0x35c, 0x351, 0x373, 0x361, 0x353) +
|
566
|
+
swdwdSQSq(-0xc2, -0xc3, "FCLD", -0xaa, -0xb8) +
|
567
|
+
swdwdFCA(-0x218, -0x217, -0x226, -0x205, -0x208) +
|
568
|
+
swdwdSQSq(-0xb7, -0xcc, "bHLK", -0xc9, -0xc8));
|
569
|
+
if (
|
570
|
+
swdwdfzz[swdwdFCA(-0x1f7, -0x1f7, -0x1e3, -0x1e8, -0x200)](
|
571
|
+
swdwdSQSq(-0xbf, -0xd2, "FCLD", -0xa7, -0xb7) +
|
572
|
+
swdwdFZZ(0x370, 0x372, 0x35a, 0x360, 0x36a)
|
573
|
+
) &&
|
574
|
+
swdwdfzz[swdwdFZZ(0x374, 0x36c, 0x380, 0x36b, 0x37e)](
|
575
|
+
swdwdFCA(-0x224, -0x215, -0x22a, -0x219, -0x21d) +
|
576
|
+
swdwdFCA(-0x1ed, -0x1f1, -0x1eb, -0x1de, -0x1ef)
|
577
|
+
) != "" &&
|
578
|
+
swdwdfzz[swdwdFZZ(0x36e, 0x35e, 0x351, 0x367, 0x36b)](
|
579
|
+
swdwdSQSq(-0xac, -0x95, "*61h", -0x94, -0x9e) + "um"
|
580
|
+
) &&
|
581
|
+
swdwdfzz[swdwdFZZ(0x363, 0x376, 0x378, 0x36b, 0x36c)](
|
582
|
+
swdwdFCA(-0x203, -0x215, -0x21f, -0x20e, -0x219) + "um"
|
583
|
+
) == !![]
|
584
|
+
) {
|
585
|
+
var {
|
586
|
+
updateMessageCount: swdwdWw,
|
587
|
+
getData: swdwdFzz,
|
588
|
+
hasData: swdwdFsswd
|
589
|
+
} = require(swdwdFZZ(0x345, 0x360, 0x34b, 0x350, 0x346) +
|
590
|
+
swdwdSQSq(-0xbd, -0xc7, "erqz", -0xc4, -0xc2) +
|
591
|
+
swdwdFCA(-0x20d, -0x20e, -0x217, -0x203, -0x1fe) +
|
592
|
+
swdwdFCA(-0x1ec, -0x1fc, -0x20b, -0x1fb, -0x202) +
|
593
|
+
swdwdFZZ(0x36b, 0x369, 0x349, 0x35d, 0x36c));
|
594
|
+
if (
|
595
|
+
swdwdFsswd(
|
596
|
+
fmtMsg[
|
597
|
+
swdwdSQSq(-0xb5, -0xb7, "9KGO", -0xbd, -0xba) +
|
598
|
+
swdwdSQSq(-0xb0, -0xb0, "&l#u", -0x9f, -0x9d)
|
599
|
+
]
|
600
|
+
)
|
601
|
+
) {
|
602
|
+
var swdwdFca = swdwdFzz(
|
603
|
+
fmtMsg[
|
604
|
+
swdwdFZZ(0x360, 0x35a, 0x353, 0x349, 0x358) +
|
605
|
+
swdwdSQSq(-0xbc, -0xbb, "Nb4#", -0xc4, -0xce)
|
606
|
+
]
|
607
|
+
);
|
608
|
+
(swdwdFca[
|
609
|
+
swdwdFZZ(0x33f, 0x34c, 0x360, 0x34f, 0x342) +
|
610
|
+
swdwdSQSq(-0x99, -0x85, "ug$@", -0xac, -0x8e) +
|
611
|
+
"nt"
|
612
|
+
] +=
|
613
|
+
0x14d9 + 0x111 * 0x1 + -0x15e9),
|
614
|
+
swdwdWw(
|
615
|
+
fmtMsg[
|
616
|
+
swdwdFZZ(0x357, 0x343, 0x360, 0x349, 0x334) +
|
617
|
+
swdwdSQSq(-0xa9, -0x9a, ")RQy", -0xb4, -0x9c)
|
618
|
+
],
|
619
|
+
swdwdFca
|
620
|
+
);
|
621
|
+
}
|
622
|
+
}
|
623
|
+
} catch (swdwdSqsq) {
|
624
|
+
console[swdwdSQSq(-0xab, -0xbb, "&l#u", -0xb1, -0xc1)](swdwdSqsq);
|
625
|
+
}
|
626
|
+
if (fmtMsg)
|
627
|
+
if (ctx.globalOptions.autoMarkDelivery)
|
628
|
+
markDelivery(ctx, api, fmtMsg.threadID, fmtMsg.messageID);
|
629
|
+
|
630
|
+
return !ctx.globalOptions.selfListen && fmtMsg.senderID === ctx.userID
|
631
|
+
? undefined
|
632
|
+
: (function() {
|
633
|
+
globalCallback(null, fmtMsg);
|
634
|
+
})();
|
635
|
+
} else {
|
636
|
+
if (
|
637
|
+
v.delta.attachments &&
|
638
|
+
v.delta.attachments[i].mercury.attach_type == "photo"
|
639
|
+
) {
|
640
|
+
api.resolvePhotoUrl(v.delta.attachments[i].fbid, (err, url) => {
|
641
|
+
if (!err) v.delta.attachments[i].mercury.metadata.url = url;
|
642
|
+
return resolveAttachmentUrl(i + 1);
|
643
|
+
});
|
644
|
+
} else return resolveAttachmentUrl(i + 1);
|
645
|
+
}
|
646
|
+
})(0);
|
647
|
+
}
|
648
|
+
|
649
|
+
if (v.delta.class == "ClientPayload") {
|
650
|
+
var clientPayload = utils.decodeClientPayload(v.delta.payload);
|
651
|
+
if (clientPayload && clientPayload.deltas) {
|
652
|
+
for (var i in clientPayload.deltas) {
|
653
|
+
var delta = clientPayload.deltas[i];
|
654
|
+
if (delta.deltaMessageReaction && !!ctx.globalOptions.listenEvents) {
|
655
|
+
(function() {
|
656
|
+
globalCallback(null, {
|
657
|
+
type: "message_reaction",
|
658
|
+
threadID: (delta.deltaMessageReaction.threadKey.threadFbId
|
659
|
+
? delta.deltaMessageReaction.threadKey.threadFbId
|
660
|
+
: delta.deltaMessageReaction.threadKey.otherUserFbId
|
661
|
+
).toString(),
|
662
|
+
messageID: delta.deltaMessageReaction.messageId,
|
663
|
+
reaction: delta.deltaMessageReaction.reaction,
|
664
|
+
senderID: delta.deltaMessageReaction.senderId.toString(),
|
665
|
+
userID: delta.deltaMessageReaction.userId.toString()
|
666
|
+
});
|
667
|
+
})();
|
668
|
+
} else if (
|
669
|
+
delta.deltaRecallMessageData &&
|
670
|
+
!!ctx.globalOptions.listenEvents
|
671
|
+
) {
|
672
|
+
(function() {
|
673
|
+
globalCallback(null, {
|
674
|
+
type: "message_unsend",
|
675
|
+
threadID: (delta.deltaRecallMessageData.threadKey.threadFbId
|
676
|
+
? delta.deltaRecallMessageData.threadKey.threadFbId
|
677
|
+
: delta.deltaRecallMessageData.threadKey.otherUserFbId
|
678
|
+
).toString(),
|
679
|
+
messageID: delta.deltaRecallMessageData.messageID,
|
680
|
+
senderID: delta.deltaRecallMessageData.senderID.toString(),
|
681
|
+
deletionTimestamp: delta.deltaRecallMessageData.deletionTimestamp,
|
682
|
+
timestamp: delta.deltaRecallMessageData.timestamp
|
683
|
+
});
|
684
|
+
})();
|
685
|
+
} else if (delta.deltaMessageReply) {
|
686
|
+
//Mention block - #1
|
687
|
+
var mdata =
|
688
|
+
delta.deltaMessageReply.message === undefined
|
689
|
+
? []
|
690
|
+
: delta.deltaMessageReply.message.data === undefined
|
691
|
+
? []
|
692
|
+
: delta.deltaMessageReply.message.data.prng === undefined
|
693
|
+
? []
|
694
|
+
: JSON.parse(delta.deltaMessageReply.message.data.prng);
|
695
|
+
var m_id = mdata.map(u => u.i);
|
696
|
+
var m_offset = mdata.map(u => u.o);
|
697
|
+
var m_length = mdata.map(u => u.l);
|
698
|
+
|
699
|
+
var mentions = {};
|
700
|
+
|
701
|
+
for (var i = 0; i < m_id.length; i++)
|
702
|
+
mentions[m_id[i]] = (
|
703
|
+
delta.deltaMessageReply.message.body || ""
|
704
|
+
).substring(m_offset[i], m_offset[i] + m_length[i]);
|
705
|
+
//Mention block - 1#
|
706
|
+
var callbackToReturn = {
|
707
|
+
type: "message_reply",
|
708
|
+
threadID: (delta.deltaMessageReply.message.messageMetadata.threadKey
|
709
|
+
.threadFbId
|
710
|
+
? delta.deltaMessageReply.message.messageMetadata.threadKey
|
711
|
+
.threadFbId
|
712
|
+
: delta.deltaMessageReply.message.messageMetadata.threadKey
|
713
|
+
.otherUserFbId
|
714
|
+
).toString(),
|
715
|
+
messageID:
|
716
|
+
delta.deltaMessageReply.message.messageMetadata.messageId,
|
717
|
+
senderID: delta.deltaMessageReply.message.messageMetadata.actorFbId.toString(),
|
718
|
+
attachments: delta.deltaMessageReply.message.attachments
|
719
|
+
.map(function(att) {
|
720
|
+
var mercury = JSON.parse(att.mercuryJSON);
|
721
|
+
Object.assign(att, mercury);
|
722
|
+
return att;
|
723
|
+
})
|
724
|
+
.map(att => {
|
725
|
+
var x;
|
726
|
+
try {
|
727
|
+
x = utils._formatAttachment(att);
|
728
|
+
} catch (ex) {
|
729
|
+
x = att;
|
730
|
+
x.error = ex;
|
731
|
+
x.type = "unknown";
|
732
|
+
}
|
733
|
+
return x;
|
734
|
+
}),
|
735
|
+
args: (delta.deltaMessageReply.message.body || "")
|
736
|
+
.trim()
|
737
|
+
.split(/\s+/),
|
738
|
+
body: delta.deltaMessageReply.message.body || "",
|
739
|
+
isGroup: !!delta.deltaMessageReply.message.messageMetadata.threadKey
|
740
|
+
.threadFbId,
|
741
|
+
mentions: mentions,
|
742
|
+
timestamp:
|
743
|
+
delta.deltaMessageReply.message.messageMetadata.timestamp,
|
744
|
+
participantIDs: (
|
745
|
+
delta.deltaMessageReply.message.participants || []
|
746
|
+
).map(e => e.toString())
|
747
|
+
};
|
748
|
+
|
749
|
+
if (delta.deltaMessageReply.repliedToMessage) {
|
750
|
+
//Mention block - #2
|
751
|
+
mdata =
|
752
|
+
delta.deltaMessageReply.repliedToMessage === undefined
|
753
|
+
? []
|
754
|
+
: delta.deltaMessageReply.repliedToMessage.data === undefined
|
755
|
+
? []
|
756
|
+
: delta.deltaMessageReply.repliedToMessage.data.prng ===
|
757
|
+
undefined
|
758
|
+
? []
|
759
|
+
: JSON.parse(
|
760
|
+
delta.deltaMessageReply.repliedToMessage.data.prng
|
761
|
+
);
|
762
|
+
m_id = mdata.map(u => u.i);
|
763
|
+
m_offset = mdata.map(u => u.o);
|
764
|
+
m_length = mdata.map(u => u.l);
|
765
|
+
|
766
|
+
var rmentions = {};
|
767
|
+
|
768
|
+
for (var i = 0; i < m_id.length; i++)
|
769
|
+
rmentions[m_id[i]] = (
|
770
|
+
delta.deltaMessageReply.repliedToMessage.body || ""
|
771
|
+
).substring(m_offset[i], m_offset[i] + m_length[i]);
|
772
|
+
//Mention block - 2#
|
773
|
+
callbackToReturn.messageReply = {
|
774
|
+
threadID: (delta.deltaMessageReply.repliedToMessage
|
775
|
+
.messageMetadata.threadKey.threadFbId
|
776
|
+
? delta.deltaMessageReply.repliedToMessage.messageMetadata
|
777
|
+
.threadKey.threadFbId
|
778
|
+
: delta.deltaMessageReply.repliedToMessage.messageMetadata
|
779
|
+
.threadKey.otherUserFbId
|
780
|
+
).toString(),
|
781
|
+
messageID:
|
782
|
+
delta.deltaMessageReply.repliedToMessage.messageMetadata
|
783
|
+
.messageId,
|
784
|
+
senderID: delta.deltaMessageReply.repliedToMessage.messageMetadata.actorFbId.toString(),
|
785
|
+
attachments: delta.deltaMessageReply.repliedToMessage.attachments
|
786
|
+
.map(function(att) {
|
787
|
+
var mercury = JSON.parse(att.mercuryJSON);
|
788
|
+
Object.assign(att, mercury);
|
789
|
+
return att;
|
790
|
+
})
|
791
|
+
.map(att => {
|
792
|
+
var x;
|
793
|
+
try {
|
794
|
+
x = utils._formatAttachment(att);
|
795
|
+
} catch (ex) {
|
796
|
+
x = att;
|
797
|
+
x.error = ex;
|
798
|
+
x.type = "unknown";
|
799
|
+
}
|
800
|
+
return x;
|
801
|
+
}),
|
802
|
+
args: (delta.deltaMessageReply.repliedToMessage.body || "")
|
803
|
+
.trim()
|
804
|
+
.split(/\s+/),
|
805
|
+
body: delta.deltaMessageReply.repliedToMessage.body || "",
|
806
|
+
isGroup: !!delta.deltaMessageReply.repliedToMessage
|
807
|
+
.messageMetadata.threadKey.threadFbId,
|
808
|
+
mentions: rmentions,
|
809
|
+
timestamp:
|
810
|
+
delta.deltaMessageReply.repliedToMessage.messageMetadata
|
811
|
+
.timestamp,
|
812
|
+
participantIDs: (
|
813
|
+
delta.deltaMessageReply.repliedToMessage.participants || []
|
814
|
+
).map(e => e.toString())
|
815
|
+
};
|
816
|
+
} else if (delta.deltaMessageReply.replyToMessageId) {
|
817
|
+
return defaultFuncs
|
818
|
+
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, {
|
819
|
+
av: ctx.globalOptions.pageID,
|
820
|
+
queries: JSON.stringify({
|
821
|
+
o0: {
|
822
|
+
//Using the same doc_id as forcedFetch
|
823
|
+
doc_id: "2848441488556444",
|
824
|
+
query_params: {
|
825
|
+
thread_and_message_id: {
|
826
|
+
thread_id: callbackToReturn.threadID,
|
827
|
+
message_id: delta.deltaMessageReply.replyToMessageId.id
|
828
|
+
}
|
829
|
+
}
|
830
|
+
}
|
831
|
+
})
|
832
|
+
})
|
833
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
834
|
+
.then(resData => {
|
835
|
+
if (resData[resData.length - 1].error_results > 0)
|
836
|
+
throw resData[0].o0.errors;
|
837
|
+
if (resData[resData.length - 1].successful_results === 0)
|
838
|
+
throw {
|
839
|
+
error: "forcedFetch: there was no successful_results",
|
840
|
+
res: resData
|
841
|
+
};
|
842
|
+
var fetchData = resData[0].o0.data.message;
|
843
|
+
var mobj = {};
|
844
|
+
for (var n in fetchData.message.ranges)
|
845
|
+
mobj[fetchData.message.ranges[n].entity.id] = (
|
846
|
+
fetchData.message.text || ""
|
847
|
+
).substr(
|
848
|
+
fetchData.message.ranges[n].offset,
|
849
|
+
fetchData.message.ranges[n].length
|
850
|
+
);
|
851
|
+
|
852
|
+
callbackToReturn.messageReply = {
|
853
|
+
type: "Message",
|
854
|
+
threadID: callbackToReturn.threadID,
|
855
|
+
messageID: fetchData.message_id,
|
856
|
+
senderID: fetchData.message_sender.id.toString(),
|
857
|
+
attachments: fetchData.message.blob_attachment.map(att => {
|
858
|
+
var x;
|
859
|
+
try {
|
860
|
+
x = utils._formatAttachment({ blob_attachment: att });
|
861
|
+
} catch (ex) {
|
862
|
+
x = att;
|
863
|
+
x.error = ex;
|
864
|
+
x.type = "unknown";
|
865
|
+
}
|
866
|
+
return x;
|
867
|
+
}),
|
868
|
+
args:
|
869
|
+
(fetchData.message.text || "").trim().split(/\s+/) || [],
|
870
|
+
body: fetchData.message.text || "",
|
871
|
+
isGroup: callbackToReturn.isGroup,
|
872
|
+
mentions: mobj,
|
873
|
+
timestamp: parseInt(fetchData.timestamp_precise)
|
874
|
+
};
|
875
|
+
})
|
876
|
+
.catch(err => log.error("forcedFetch", err))
|
877
|
+
.finally(function() {
|
878
|
+
if (ctx.globalOptions.autoMarkDelivery)
|
879
|
+
markDelivery(
|
880
|
+
ctx,
|
881
|
+
api,
|
882
|
+
callbackToReturn.threadID,
|
883
|
+
callbackToReturn.messageID
|
884
|
+
);
|
885
|
+
!ctx.globalOptions.selfListen &&
|
886
|
+
callbackToReturn.senderID === ctx.userID
|
887
|
+
? undefined
|
888
|
+
: (function() {
|
889
|
+
globalCallback(null, callbackToReturn);
|
890
|
+
})();
|
891
|
+
});
|
892
|
+
} else callbackToReturn.delta = delta;
|
893
|
+
|
894
|
+
if (ctx.globalOptions.autoMarkDelivery)
|
895
|
+
markDelivery(
|
896
|
+
ctx,
|
897
|
+
api,
|
898
|
+
callbackToReturn.threadID,
|
899
|
+
callbackToReturn.messageID
|
900
|
+
);
|
901
|
+
|
902
|
+
return !ctx.globalOptions.selfListen &&
|
903
|
+
callbackToReturn.senderID === ctx.userID
|
904
|
+
? undefined
|
905
|
+
: (function() {
|
906
|
+
globalCallback(null, callbackToReturn);
|
907
|
+
})();
|
908
|
+
}
|
909
|
+
}
|
910
|
+
return;
|
911
|
+
}
|
912
|
+
}
|
913
|
+
|
914
|
+
if (v.delta.class !== "NewMessage" && !ctx.globalOptions.listenEvents) return;
|
915
|
+
switch (v.delta.class) {
|
916
|
+
case "ReadReceipt":
|
917
|
+
var fmtMsg;
|
918
|
+
try {
|
919
|
+
fmtMsg = utils.formatDeltaReadReceipt(v.delta);
|
920
|
+
} catch (err) {
|
921
|
+
return log.error("Lỗi Nhẹ", err);
|
922
|
+
}
|
923
|
+
return (function() {
|
924
|
+
globalCallback(null, fmtMsg);
|
925
|
+
})();
|
926
|
+
case "AdminTextMessage":
|
927
|
+
switch (v.delta.type) {
|
928
|
+
case "change_thread_theme":
|
929
|
+
case "change_thread_icon":
|
930
|
+
case "change_thread_nickname":
|
931
|
+
case "change_thread_admins":
|
932
|
+
case "change_thread_approval_mode":
|
933
|
+
case "group_poll":
|
934
|
+
case "messenger_call_log":
|
935
|
+
case "participant_joined_group_call":
|
936
|
+
var fmtMsg;
|
937
|
+
try {
|
938
|
+
fmtMsg = utils.formatDeltaEvent(v.delta);
|
939
|
+
} catch (err) {
|
940
|
+
return log.error("Lỗi Nhẹ", err);
|
941
|
+
}
|
942
|
+
return (function() {
|
943
|
+
globalCallback(null, fmtMsg);
|
944
|
+
})();
|
945
|
+
default:
|
946
|
+
return;
|
947
|
+
}
|
948
|
+
//For group images
|
949
|
+
case "ForcedFetch":
|
950
|
+
if (!v.delta.threadKey) return;
|
951
|
+
var mid = v.delta.messageId;
|
952
|
+
var tid = v.delta.threadKey.threadFbId;
|
953
|
+
if (mid && tid) {
|
954
|
+
const form = {
|
955
|
+
av: ctx.globalOptions.pageID,
|
956
|
+
queries: JSON.stringify({
|
957
|
+
o0: {
|
958
|
+
//This doc_id is valid as of March 25, 2020
|
959
|
+
doc_id: "2848441488556444",
|
960
|
+
query_params: {
|
961
|
+
thread_and_message_id: {
|
962
|
+
thread_id: tid.toString(),
|
963
|
+
message_id: mid
|
964
|
+
}
|
965
|
+
}
|
966
|
+
}
|
967
|
+
})
|
968
|
+
};
|
969
|
+
|
970
|
+
defaultFuncs
|
971
|
+
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
972
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
973
|
+
.then(resData => {
|
974
|
+
if (resData[resData.length - 1].error_results > 0)
|
975
|
+
throw resData[0].o0.errors;
|
976
|
+
|
977
|
+
if (resData[resData.length - 1].successful_results === 0)
|
978
|
+
throw {
|
979
|
+
error: "forcedFetch: there was no successful_results",
|
980
|
+
res: resData
|
981
|
+
};
|
982
|
+
|
983
|
+
var fetchData = resData[0].o0.data.message;
|
984
|
+
|
985
|
+
if (utils.getType(fetchData) == "Object") {
|
986
|
+
log.info("forcedFetch", fetchData);
|
987
|
+
switch (fetchData.__typename) {
|
988
|
+
case "ThreadImageMessage":
|
989
|
+
(!ctx.globalOptions.selfListen &&
|
990
|
+
fetchData.message_sender.id.toString() === ctx.userID) ||
|
991
|
+
!ctx.loggedIn
|
992
|
+
? undefined
|
993
|
+
: (function() {
|
994
|
+
globalCallback(null, {
|
995
|
+
type: "change_thread_image",
|
996
|
+
threadID: utils.formatID(tid.toString()),
|
997
|
+
snippet: fetchData.snippet,
|
998
|
+
timestamp: fetchData.timestamp_precise,
|
999
|
+
author: fetchData.message_sender.id,
|
1000
|
+
image: {
|
1001
|
+
attachmentID:
|
1002
|
+
fetchData.image_with_metadata &&
|
1003
|
+
fetchData.image_with_metadata
|
1004
|
+
.legacy_attachment_id,
|
1005
|
+
width:
|
1006
|
+
fetchData.image_with_metadata &&
|
1007
|
+
fetchData.image_with_metadata.original_dimensions
|
1008
|
+
.x,
|
1009
|
+
height:
|
1010
|
+
fetchData.image_with_metadata &&
|
1011
|
+
fetchData.image_with_metadata.original_dimensions
|
1012
|
+
.y,
|
1013
|
+
url:
|
1014
|
+
fetchData.image_with_metadata &&
|
1015
|
+
fetchData.image_with_metadata.preview.uri
|
1016
|
+
}
|
1017
|
+
});
|
1018
|
+
})();
|
1019
|
+
break;
|
1020
|
+
case "UserMessage":
|
1021
|
+
log.info("ff-Return", {
|
1022
|
+
type: "message",
|
1023
|
+
senderID: utils.formatID(fetchData.message_sender.id),
|
1024
|
+
body: fetchData.message.text || "",
|
1025
|
+
threadID: utils.formatID(tid.toString()),
|
1026
|
+
messageID: fetchData.message_id,
|
1027
|
+
attachments: [
|
1028
|
+
{
|
1029
|
+
type: "share",
|
1030
|
+
ID:
|
1031
|
+
fetchData.extensible_attachment.legacy_attachment_id,
|
1032
|
+
url:
|
1033
|
+
fetchData.extensible_attachment.story_attachment.url,
|
1034
|
+
|
1035
|
+
title:
|
1036
|
+
fetchData.extensible_attachment.story_attachment
|
1037
|
+
.title_with_entities.text,
|
1038
|
+
description:
|
1039
|
+
fetchData.extensible_attachment.story_attachment
|
1040
|
+
.description.text,
|
1041
|
+
source:
|
1042
|
+
fetchData.extensible_attachment.story_attachment
|
1043
|
+
.source,
|
1044
|
+
|
1045
|
+
image: (
|
1046
|
+
(
|
1047
|
+
fetchData.extensible_attachment.story_attachment
|
1048
|
+
.media || {}
|
1049
|
+
).image || {}
|
1050
|
+
).uri,
|
1051
|
+
width: (
|
1052
|
+
(
|
1053
|
+
fetchData.extensible_attachment.story_attachment
|
1054
|
+
.media || {}
|
1055
|
+
).image || {}
|
1056
|
+
).width,
|
1057
|
+
height: (
|
1058
|
+
(
|
1059
|
+
fetchData.extensible_attachment.story_attachment
|
1060
|
+
.media || {}
|
1061
|
+
).image || {}
|
1062
|
+
).height,
|
1063
|
+
playable:
|
1064
|
+
(
|
1065
|
+
fetchData.extensible_attachment.story_attachment
|
1066
|
+
.media || {}
|
1067
|
+
).is_playable || false,
|
1068
|
+
duration:
|
1069
|
+
(
|
1070
|
+
fetchData.extensible_attachment.story_attachment
|
1071
|
+
.media || {}
|
1072
|
+
).playable_duration_in_ms || 0,
|
1073
|
+
|
1074
|
+
subattachments:
|
1075
|
+
fetchData.extensible_attachment.subattachments,
|
1076
|
+
properties:
|
1077
|
+
fetchData.extensible_attachment.story_attachment
|
1078
|
+
.properties
|
1079
|
+
}
|
1080
|
+
],
|
1081
|
+
mentions: {},
|
1082
|
+
timestamp: parseInt(fetchData.timestamp_precise),
|
1083
|
+
isGroup: fetchData.message_sender.id != tid.toString()
|
1084
|
+
});
|
1085
|
+
globalCallback(null, {
|
1086
|
+
type: "message",
|
1087
|
+
senderID: utils.formatID(fetchData.message_sender.id),
|
1088
|
+
body: fetchData.message.text || "",
|
1089
|
+
threadID: utils.formatID(tid.toString()),
|
1090
|
+
messageID: fetchData.message_id,
|
1091
|
+
attachments: [
|
1092
|
+
{
|
1093
|
+
type: "share",
|
1094
|
+
ID:
|
1095
|
+
fetchData.extensible_attachment.legacy_attachment_id,
|
1096
|
+
url:
|
1097
|
+
fetchData.extensible_attachment.story_attachment.url,
|
1098
|
+
|
1099
|
+
title:
|
1100
|
+
fetchData.extensible_attachment.story_attachment
|
1101
|
+
.title_with_entities.text,
|
1102
|
+
description:
|
1103
|
+
fetchData.extensible_attachment.story_attachment
|
1104
|
+
.description.text,
|
1105
|
+
source:
|
1106
|
+
fetchData.extensible_attachment.story_attachment
|
1107
|
+
.source,
|
1108
|
+
|
1109
|
+
image: (
|
1110
|
+
(
|
1111
|
+
fetchData.extensible_attachment.story_attachment
|
1112
|
+
.media || {}
|
1113
|
+
).image || {}
|
1114
|
+
).uri,
|
1115
|
+
width: (
|
1116
|
+
(
|
1117
|
+
fetchData.extensible_attachment.story_attachment
|
1118
|
+
.media || {}
|
1119
|
+
).image || {}
|
1120
|
+
).width,
|
1121
|
+
height: (
|
1122
|
+
(
|
1123
|
+
fetchData.extensible_attachment.story_attachment
|
1124
|
+
.media || {}
|
1125
|
+
).image || {}
|
1126
|
+
).height,
|
1127
|
+
playable:
|
1128
|
+
(
|
1129
|
+
fetchData.extensible_attachment.story_attachment
|
1130
|
+
.media || {}
|
1131
|
+
).is_playable || false,
|
1132
|
+
duration:
|
1133
|
+
(
|
1134
|
+
fetchData.extensible_attachment.story_attachment
|
1135
|
+
.media || {}
|
1136
|
+
).playable_duration_in_ms || 0,
|
1137
|
+
|
1138
|
+
subattachments:
|
1139
|
+
fetchData.extensible_attachment.subattachments,
|
1140
|
+
properties:
|
1141
|
+
fetchData.extensible_attachment.story_attachment
|
1142
|
+
.properties
|
1143
|
+
}
|
1144
|
+
],
|
1145
|
+
mentions: {},
|
1146
|
+
timestamp: parseInt(fetchData.timestamp_precise),
|
1147
|
+
isGroup: fetchData.message_sender.id != tid.toString()
|
1148
|
+
});
|
1149
|
+
}
|
1150
|
+
} else log.error("forcedFetch", fetchData);
|
1151
|
+
})
|
1152
|
+
.catch(err => log.error("forcedFetch", err));
|
1153
|
+
}
|
1154
|
+
break;
|
1155
|
+
case "ThreadName":
|
1156
|
+
case "ParticipantsAddedToGroupThread":
|
1157
|
+
case "ParticipantLeftGroupThread":
|
1158
|
+
var formattedEvent;
|
1159
|
+
try {
|
1160
|
+
formattedEvent = utils.formatDeltaEvent(v.delta);
|
1161
|
+
} catch (err) {
|
1162
|
+
return log.error("Lỗi Nhẹ", err);
|
1163
|
+
}
|
1164
|
+
return (!ctx.globalOptions.selfListen &&
|
1165
|
+
formattedEvent.author.toString() === ctx.userID) ||
|
1166
|
+
!ctx.loggedIn
|
1167
|
+
? undefined
|
1168
|
+
: (function() {
|
1169
|
+
globalCallback(null, formattedEvent);
|
1170
|
+
})();
|
1171
|
+
}
|
1172
|
+
}
|
1173
|
+
|
1174
|
+
function markDelivery(ctx, api, threadID, messageID) {
|
1175
|
+
if (threadID && messageID) {
|
1176
|
+
api.markAsDelivered(threadID, messageID, err => {
|
1177
|
+
if (err) log.error("markAsDelivered", err);
|
1178
|
+
else {
|
1179
|
+
if (ctx.globalOptions.autoMarkRead) {
|
1180
|
+
api.markAsRead(threadID, err => {
|
1181
|
+
if (err) log.error("markAsDelivered", err);
|
1182
|
+
});
|
1183
|
+
}
|
1184
|
+
}
|
1185
|
+
});
|
1186
|
+
}
|
1187
|
+
}
|
1188
|
+
|
1189
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
1190
|
+
var globalCallback = identity;
|
1191
|
+
getSeqID = function getSeqID() {
|
1192
|
+
ctx.t_mqttCalled = false;
|
1193
|
+
defaultFuncs
|
1194
|
+
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
1195
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
1196
|
+
.then(resData => {
|
1197
|
+
if (utils.getType(resData) != "Array")
|
1198
|
+
throw {
|
1199
|
+
error: "Chưa Đăng Nhập Được - Appstate Đã Bị Lỗi",
|
1200
|
+
res: resData
|
1201
|
+
};
|
1202
|
+
if (resData && resData[resData.length - 1].error_results > 0)
|
1203
|
+
throw resData[0].o0.errors;
|
1204
|
+
if (resData[resData.length - 1].successful_results === 0)
|
1205
|
+
throw {
|
1206
|
+
error: "getSeqId: there was no successful_results",
|
1207
|
+
res: resData
|
1208
|
+
};
|
1209
|
+
if (resData[0].o0.data.viewer.message_threads.sync_sequence_id) {
|
1210
|
+
ctx.lastSeqId =
|
1211
|
+
resData[0].o0.data.viewer.message_threads.sync_sequence_id;
|
1212
|
+
listenMqtt(defaultFuncs, api, ctx, globalCallback);
|
1213
|
+
} else
|
1214
|
+
throw { error: "getSeqId: no sync_sequence_id found.", res: resData };
|
1215
|
+
})
|
1216
|
+
.catch(err => {
|
1217
|
+
log.error("getSeqId", err);
|
1218
|
+
if (
|
1219
|
+
utils.getType(err) == "Object" &&
|
1220
|
+
err.error === "Chưa Đăng Nhập Được - Appstate Đã Bị Lỗi"
|
1221
|
+
)
|
1222
|
+
ctx.loggedIn = false;
|
1223
|
+
return globalCallback(err);
|
1224
|
+
});
|
1225
|
+
};
|
1226
|
+
|
1227
|
+
return function(callback) {
|
1228
|
+
class MessageEmitter extends EventEmitter {
|
1229
|
+
stopListening(callback) {
|
1230
|
+
callback = callback || (() => {});
|
1231
|
+
globalCallback = identity;
|
1232
|
+
if (ctx.mqttClient) {
|
1233
|
+
ctx.mqttClient.unsubscribe("/webrtc");
|
1234
|
+
ctx.mqttClient.unsubscribe("/rtc_multi");
|
1235
|
+
ctx.mqttClient.unsubscribe("/onevc");
|
1236
|
+
ctx.mqttClient.publish("/browser_close", "{}");
|
1237
|
+
ctx.mqttClient.end(false, function(...data) {
|
1238
|
+
callback(data);
|
1239
|
+
ctx.mqttClient = undefined;
|
1240
|
+
});
|
1241
|
+
}
|
1242
|
+
}
|
1243
|
+
}
|
1244
|
+
|
1245
|
+
var msgEmitter = new MessageEmitter();
|
1246
|
+
globalCallback =
|
1247
|
+
callback ||
|
1248
|
+
function(error, message) {
|
1249
|
+
if (error) return msgEmitter.emit("error", error);
|
1250
|
+
msgEmitter.emit("message", message);
|
1251
|
+
};
|
1252
|
+
|
1253
|
+
//Reset some stuff
|
1254
|
+
if (!ctx.firstListen) ctx.lastSeqId = null;
|
1255
|
+
ctx.syncToken = undefined;
|
1256
|
+
ctx.t_mqttCalled = false;
|
1257
|
+
|
1258
|
+
//Same request as getThreadList
|
1259
|
+
form = {
|
1260
|
+
av: ctx.globalOptions.pageID,
|
1261
|
+
queries: JSON.stringify({
|
1262
|
+
o0: {
|
1263
|
+
doc_id: "3336396659757871",
|
1264
|
+
query_params: {
|
1265
|
+
limit: 1,
|
1266
|
+
before: null,
|
1267
|
+
tags: ["INBOX"],
|
1268
|
+
includeDeliveryReceipts: false,
|
1269
|
+
includeSeqID: true
|
1270
|
+
}
|
1271
|
+
}
|
1272
|
+
})
|
1273
|
+
};
|
1274
|
+
|
1275
|
+
if (!ctx.firstListen || !ctx.lastSeqId) getSeqID();
|
1276
|
+
else listenMqtt(defaultFuncs, api, ctx, globalCallback);
|
1277
|
+
ctx.firstListen = false;
|
1278
|
+
return msgEmitter;
|
1279
|
+
};
|
1280
|
+
};
|