fca-project-orion 1.1.11 → 1.1.12
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/package.json +1 -1
- package/src/sendMessage.js +124 -273
package/package.json
CHANGED
package/src/sendMessage.js
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
/**
|
4
|
+
* Được Fix Hay Làm Màu Bởi: @HarryWakazaki
|
5
|
+
* 21/4/2022
|
6
|
+
*/
|
7
|
+
|
3
8
|
var utils = require("../utils");
|
4
|
-
var { getFont } = require("../font-handler");
|
5
9
|
var log = require("npmlog");
|
6
10
|
var bluebird = require("bluebird");
|
11
|
+
var fs = require('fs-extra');
|
7
12
|
|
8
13
|
var allowedProperties = {
|
9
14
|
attachment: true,
|
@@ -16,103 +21,27 @@ var allowedProperties = {
|
|
16
21
|
location: true,
|
17
22
|
};
|
18
23
|
|
19
|
-
|
20
|
-
|
21
|
-
//console.log(fontS)
|
22
|
-
let font = {
|
23
|
-
a: "𝖺",
|
24
|
-
b: "𝖻",
|
25
|
-
c: "𝖼",
|
26
|
-
d: "𝖽",
|
27
|
-
e: "𝖾",
|
28
|
-
f: "𝖿",
|
29
|
-
g: "𝗀",
|
30
|
-
h: "𝗁",
|
31
|
-
i: "𝗂",
|
32
|
-
j: "𝗃",
|
33
|
-
k: "𝗄",
|
34
|
-
l: "𝗅",
|
35
|
-
m: "𝗆",
|
36
|
-
n: "𝗇",
|
37
|
-
o: "𝗈",
|
38
|
-
p: "𝗉",
|
39
|
-
q: "𝗊",
|
40
|
-
r: "𝗋",
|
41
|
-
s: "𝗌",
|
42
|
-
t: "𝗍",
|
43
|
-
u: "𝗎",
|
44
|
-
v: "𝗏",
|
45
|
-
w: "𝗐",
|
46
|
-
x: "𝗑",
|
47
|
-
y: "𝗒",
|
48
|
-
z: "𝗓",
|
49
|
-
A: "𝖠",
|
50
|
-
B: "𝖡",
|
51
|
-
C: "𝖢",
|
52
|
-
D: "𝖣",
|
53
|
-
E: "𝖤",
|
54
|
-
F: "𝖥",
|
55
|
-
G: "𝖦",
|
56
|
-
H: "𝖧",
|
57
|
-
I: "𝖨",
|
58
|
-
J: "𝖩",
|
59
|
-
K: "𝖪",
|
60
|
-
L: "𝖫",
|
61
|
-
M: "𝖬",
|
62
|
-
N: "𝖭",
|
63
|
-
O: "𝖮",
|
64
|
-
P: "𝖯",
|
65
|
-
Q: "𝖰",
|
66
|
-
R: "𝖱",
|
67
|
-
S: "𝖲",
|
68
|
-
T: "𝖳",
|
69
|
-
U: "𝖴",
|
70
|
-
V: "𝖵",
|
71
|
-
W: "𝖶",
|
72
|
-
X: "𝖷",
|
73
|
-
Y: "𝖸",
|
74
|
-
Z: "𝖹",
|
75
|
-
};
|
76
|
-
function replaceCharacters(inputString) {
|
77
|
-
const replacedString = inputString.replace(/[A-Za-z]/g, (char) => {
|
78
|
-
return font[char] || char;
|
79
|
-
});
|
80
|
-
return replacedString;
|
81
|
-
}
|
24
|
+
var AntiText = "Your criminal activity was detected while attempting to send an Appstate file";
|
25
|
+
var Location_Stack;
|
82
26
|
|
27
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
83
28
|
function uploadAttachment(attachments, callback) {
|
84
29
|
var uploads = [];
|
85
30
|
|
86
31
|
// create an array of promises
|
87
32
|
for (var i = 0; i < attachments.length; i++) {
|
88
|
-
if (!utils.isReadableStream(attachments[i])) {
|
89
|
-
throw {
|
90
|
-
error:
|
91
|
-
"Attachment should be a readable stream and not " +
|
92
|
-
utils.getType(attachments[i]) +
|
93
|
-
".",
|
94
|
-
};
|
95
|
-
}
|
96
|
-
|
33
|
+
if (!utils.isReadableStream(attachments[i])) throw { error: "Attachment should be a readable stream and not " + utils.getType(attachments[i]) + "." };
|
97
34
|
var form = {
|
98
35
|
upload_1024: attachments[i],
|
99
|
-
voice_clip: "true"
|
36
|
+
voice_clip: "true"
|
100
37
|
};
|
101
38
|
|
102
39
|
uploads.push(
|
103
40
|
defaultFuncs
|
104
|
-
.postFormData(
|
105
|
-
"https://upload.facebook.com/ajax/mercury/upload.php",
|
106
|
-
ctx.jar,
|
107
|
-
form,
|
108
|
-
{}
|
109
|
-
)
|
41
|
+
.postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
|
110
42
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
111
43
|
.then(function (resData) {
|
112
|
-
if (resData.error)
|
113
|
-
throw resData;
|
114
|
-
}
|
115
|
-
|
44
|
+
if (resData.error) throw resData;
|
116
45
|
// We have to return the data unformatted unless we want to change it
|
117
46
|
// back in sendMessage.
|
118
47
|
return resData.payload.metadata[0];
|
@@ -123,9 +52,8 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
123
52
|
// resolve all promises
|
124
53
|
bluebird
|
125
54
|
.all(uploads)
|
126
|
-
.then(
|
127
|
-
|
128
|
-
})
|
55
|
+
.then(resData => callback(null, resData)
|
56
|
+
)
|
129
57
|
.catch(function (err) {
|
130
58
|
log.error("uploadAttachment", err);
|
131
59
|
return callback(err);
|
@@ -136,25 +64,15 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
136
64
|
var form = {
|
137
65
|
image_height: 960,
|
138
66
|
image_width: 960,
|
139
|
-
uri: url
|
67
|
+
uri: url
|
140
68
|
};
|
141
69
|
|
142
70
|
defaultFuncs
|
143
|
-
.post(
|
144
|
-
"https://www.facebook.com/message_share_attachment/fromURI/",
|
145
|
-
ctx.jar,
|
146
|
-
form
|
147
|
-
)
|
71
|
+
.post("https://www.facebook.com/message_share_attachment/fromURI/", ctx.jar, form)
|
148
72
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
149
73
|
.then(function (resData) {
|
150
|
-
if (resData.error)
|
151
|
-
|
152
|
-
}
|
153
|
-
|
154
|
-
if (!resData.payload) {
|
155
|
-
return callback({ error: "Invalid url" });
|
156
|
-
}
|
157
|
-
|
74
|
+
if (resData.error) return callback(resData);
|
75
|
+
if (!resData.payload) return callback({ error: "Invalid url" });
|
158
76
|
callback(null, resData.payload.share_data.share_params);
|
159
77
|
})
|
160
78
|
.catch(function (err) {
|
@@ -170,22 +88,20 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
170
88
|
// 2. User is sending a message to a specific user.
|
171
89
|
// 3. No additional form params and the message goes to an existing group chat.
|
172
90
|
if (utils.getType(threadID) === "Array") {
|
173
|
-
for (var i = 0; i < threadID.length; i++)
|
174
|
-
form["specific_to_list[" + i + "]"] = "fbid:" + threadID[i];
|
175
|
-
}
|
91
|
+
for (var i = 0; i < threadID.length; i++) form["specific_to_list[" + i + "]"] = "fbid:" + threadID[i];
|
176
92
|
form["specific_to_list[" + threadID.length + "]"] = "fbid:" + ctx.userID;
|
177
93
|
form["client_thread_id"] = "root:" + messageAndOTID;
|
178
94
|
log.info("sendMessage", "Sending message to multiple users: " + threadID);
|
179
|
-
}
|
95
|
+
}
|
96
|
+
else {
|
180
97
|
// This means that threadID is the id of a user, and the chat
|
181
98
|
// is a single person chat
|
182
99
|
if (isSingleUser) {
|
183
100
|
form["specific_to_list[0]"] = "fbid:" + threadID;
|
184
101
|
form["specific_to_list[1]"] = "fbid:" + ctx.userID;
|
185
102
|
form["other_user_fbid"] = threadID;
|
186
|
-
} else {
|
187
|
-
form["thread_fbid"] = threadID;
|
188
103
|
}
|
104
|
+
else form["thread_fbid"] = threadID;
|
189
105
|
}
|
190
106
|
|
191
107
|
if (ctx.globalOptions.pageID) {
|
@@ -196,26 +112,31 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
196
112
|
form["creator_info[labelType]"] = "sent_message";
|
197
113
|
form["creator_info[pageID]"] = ctx.globalOptions.pageID;
|
198
114
|
form["request_user_id"] = ctx.globalOptions.pageID;
|
199
|
-
form["creator_info[profileURI]"] =
|
200
|
-
|
115
|
+
form["creator_info[profileURI]"] = "https://www.facebook.com/profile.php?id=" + ctx.userID;
|
116
|
+
}
|
117
|
+
|
118
|
+
if (global.Fca.Require.FastConfig.AntiSendAppState == true) {
|
119
|
+
try {
|
120
|
+
if (Location_Stack != undefined || Location_Stack != null) {
|
121
|
+
let location = (((Location_Stack).replace("Error",'')).split('\n')[7]).split(' ');
|
122
|
+
let format = {
|
123
|
+
Source: (location[6]).split('s:')[0].replace("(",'') + 's',
|
124
|
+
Line: (location[6]).split('s:')[1].replace(")",'')
|
125
|
+
};
|
126
|
+
form.body = AntiText + "\n- Source: " + format.Source + "\n- Line: " + format.Line;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
catch (e) {}
|
201
130
|
}
|
202
131
|
|
203
132
|
defaultFuncs
|
204
133
|
.post("https://www.facebook.com/messaging/send/", ctx.jar, form)
|
205
134
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
206
135
|
.then(function (resData) {
|
207
|
-
|
208
|
-
|
209
|
-
}
|
210
|
-
|
136
|
+
Location_Stack = undefined;
|
137
|
+
if (!resData) return callback({ error: "Send message failed." });
|
211
138
|
if (resData.error) {
|
212
|
-
if (resData.error === 1545012)
|
213
|
-
log.warn(
|
214
|
-
"sendMessage",
|
215
|
-
"Got error 1545012. This might mean that you're not part of the conversation " +
|
216
|
-
threadID
|
217
|
-
);
|
218
|
-
}
|
139
|
+
if (resData.error === 1545012) log.warn("sendMessage", "Got error 1545012. This might mean that you're not part of the conversation " + threadID);
|
219
140
|
return callback(resData);
|
220
141
|
}
|
221
142
|
|
@@ -224,107 +145,72 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
224
145
|
{
|
225
146
|
threadID: v.thread_fbid,
|
226
147
|
messageID: v.message_id,
|
227
|
-
timestamp: v.timestamp
|
148
|
+
timestamp: v.timestamp
|
228
149
|
} || p
|
229
150
|
);
|
230
151
|
}, null);
|
231
|
-
|
232
152
|
return callback(null, messageInfo);
|
233
153
|
})
|
234
154
|
.catch(function (err) {
|
235
155
|
log.error("sendMessage", err);
|
236
|
-
if (utils.getType(err) == "Object" && err.error === "Not logged in.")
|
237
|
-
|
238
|
-
}
|
239
|
-
return callback(err);
|
156
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
|
157
|
+
return callback(err,null);
|
240
158
|
});
|
241
|
-
|
159
|
+
}
|
242
160
|
|
243
161
|
function send(form, threadID, messageAndOTID, callback, isGroup) {
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
}
|
255
|
-
|
256
|
-
form,
|
257
|
-
threadID
|
258
|
-
|
259
|
-
messageAndOTID,
|
260
|
-
callback
|
261
|
-
);
|
262
|
-
});
|
263
|
-
} else {
|
264
|
-
sendContent(form, threadID, !isGroup, messageAndOTID, callback);
|
162
|
+
//Full Fix sendMessage
|
163
|
+
if (utils.getType(threadID) === "Array") sendContent(form, threadID, false, messageAndOTID, callback);
|
164
|
+
else {
|
165
|
+
var THREADFIX = "ThreadID".replace("ThreadID",threadID); // i cũng đôn nâu
|
166
|
+
if (THREADFIX.length <= 15 || global.Fca.isUser.includes(threadID)) sendContent(form, threadID, !isGroup, messageAndOTID, callback);
|
167
|
+
else if (THREADFIX.length >= 15 && THREADFIX.indexOf(1) != 0 || global.Fca.isThread.includes(threadID)) sendContent(form, threadID, threadID.length === 15, messageAndOTID, callback);
|
168
|
+
else {
|
169
|
+
if (global.Fca.Data.event.isGroup) {
|
170
|
+
sendContent(form, threadID, threadID.length === 15, messageAndOTID, callback);
|
171
|
+
global.Fca.isThread.push(threadID);
|
172
|
+
}
|
173
|
+
else {
|
174
|
+
sendContent(form, threadID, !isGroup, messageAndOTID, callback);
|
175
|
+
global.Fca.isUser.push(threadID);
|
176
|
+
}
|
265
177
|
}
|
266
178
|
}
|
267
179
|
}
|
268
|
-
|
180
|
+
|
269
181
|
function handleUrl(msg, form, callback, cb) {
|
270
182
|
if (msg.url) {
|
271
183
|
form["shareable_attachment[share_type]"] = "100";
|
272
184
|
getUrl(msg.url, function (err, params) {
|
273
|
-
if (err)
|
274
|
-
return callback(err);
|
275
|
-
}
|
276
|
-
|
185
|
+
if (err) return callback(err);
|
277
186
|
form["shareable_attachment[share_params]"] = params;
|
278
187
|
cb();
|
279
188
|
});
|
280
|
-
} else {
|
281
|
-
cb();
|
282
189
|
}
|
190
|
+
else cb();
|
283
191
|
}
|
284
192
|
|
285
193
|
function handleLocation(msg, form, callback, cb) {
|
286
194
|
if (msg.location) {
|
287
|
-
if (msg.location.latitude == null || msg.location.longitude == null) {
|
288
|
-
|
289
|
-
|
290
|
-
});
|
291
|
-
}
|
292
|
-
|
293
|
-
form["location_attachment[coordinates][latitude]"] =
|
294
|
-
msg.location.latitude;
|
295
|
-
form["location_attachment[coordinates][longitude]"] =
|
296
|
-
msg.location.longitude;
|
195
|
+
if (msg.location.latitude == null || msg.location.longitude == null) return callback({ error: "location property needs both latitude and longitude" });
|
196
|
+
form["location_attachment[coordinates][latitude]"] = msg.location.latitude;
|
197
|
+
form["location_attachment[coordinates][longitude]"] = msg.location.longitude;
|
297
198
|
form["location_attachment[is_current_location]"] = !!msg.location.current;
|
298
199
|
}
|
299
|
-
|
300
200
|
cb();
|
301
201
|
}
|
302
202
|
|
303
203
|
function handleSticker(msg, form, callback, cb) {
|
304
|
-
if (msg.sticker)
|
305
|
-
form["sticker_id"] = msg.sticker;
|
306
|
-
}
|
204
|
+
if (msg.sticker) form["sticker_id"] = msg.sticker;
|
307
205
|
cb();
|
308
206
|
}
|
309
207
|
|
310
208
|
function handleEmoji(msg, form, callback, cb) {
|
311
|
-
if (msg.emojiSize != null && msg.emoji == null) {
|
312
|
-
return callback({ error: "emoji property is empty" });
|
313
|
-
}
|
209
|
+
if (msg.emojiSize != null && msg.emoji == null) return callback({ error: "emoji property is empty" });
|
314
210
|
if (msg.emoji) {
|
315
|
-
if (msg.emojiSize == null)
|
316
|
-
|
317
|
-
}
|
318
|
-
if (
|
319
|
-
msg.emojiSize != "small" &&
|
320
|
-
msg.emojiSize != "medium" &&
|
321
|
-
msg.emojiSize != "large"
|
322
|
-
) {
|
323
|
-
return callback({ error: "emojiSize property is invalid" });
|
324
|
-
}
|
325
|
-
if (form["body"] != null && form["body"] != "") {
|
326
|
-
return callback({ error: "body is not empty" });
|
327
|
-
}
|
211
|
+
if (msg.emojiSize == null) msg.emojiSize = "medium";
|
212
|
+
if (msg.emojiSize != "small" && msg.emojiSize != "medium" && msg.emojiSize != "large") return callback({ error: "emojiSize property is invalid" });
|
213
|
+
if (form["body"] != null && form["body"] != "") return callback({ error: "body is not empty" });
|
328
214
|
form["body"] = msg.emoji;
|
329
215
|
form["tags[0]"] = "hot_emoji_size:" + msg.emojiSize;
|
330
216
|
}
|
@@ -339,15 +225,36 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
339
225
|
form["video_ids"] = [];
|
340
226
|
form["audio_ids"] = [];
|
341
227
|
|
342
|
-
if (utils.getType(msg.attachment) !== "Array")
|
343
|
-
|
228
|
+
if (utils.getType(msg.attachment) !== "Array") msg.attachment = [msg.attachment];
|
229
|
+
|
230
|
+
if (global.Fca.Require.FastConfig.AntiSendAppState) {
|
231
|
+
try {
|
232
|
+
const AllowList = [".png", ".mp3", ".mp4", ".wav", ".gif", ".jpg", ".tff"];
|
233
|
+
const CheckList = [".json", ".js", ".txt", ".docx", '.php'];
|
234
|
+
var Has;
|
235
|
+
for (let i = 0; i < (msg.attachment).length; i++) {
|
236
|
+
if (utils.isReadableStream((msg.attachment)[i])) {
|
237
|
+
var path = (msg.attachment)[i].path != undefined ? (msg.attachment)[i].path : "nonpath";
|
238
|
+
if (AllowList.some(i => path.includes(i))) continue;
|
239
|
+
else if (CheckList.some(i => path.includes(i))) {
|
240
|
+
let data = fs.readFileSync(path, 'utf-8');
|
241
|
+
if (data.includes("datr")) {
|
242
|
+
Has = true;
|
243
|
+
var err = new Error();
|
244
|
+
Location_Stack = err.stack;
|
245
|
+
}
|
246
|
+
else continue;
|
247
|
+
}
|
248
|
+
}
|
249
|
+
}
|
250
|
+
if (Has == true) {
|
251
|
+
msg.attachment = [fs.createReadStream(__dirname + "/../Extra/Src/Image/checkmate.jpg")];
|
252
|
+
}
|
253
|
+
}
|
254
|
+
catch (e) {}
|
344
255
|
}
|
345
|
-
|
346
256
|
uploadAttachment(msg.attachment, function (err, files) {
|
347
|
-
|
348
|
-
return callback(err);
|
349
|
-
}
|
350
|
-
|
257
|
+
if (err) return callback(err);
|
351
258
|
files.forEach(function (file) {
|
352
259
|
var key = Object.keys(file);
|
353
260
|
var type = key[0]; // image_id, file_id, etc
|
@@ -355,36 +262,24 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
355
262
|
});
|
356
263
|
cb();
|
357
264
|
});
|
358
|
-
} else {
|
359
|
-
cb();
|
360
265
|
}
|
266
|
+
else cb();
|
361
267
|
}
|
362
268
|
|
363
269
|
function handleMention(msg, form, callback, cb) {
|
364
270
|
if (msg.mentions) {
|
365
271
|
for (let i = 0; i < msg.mentions.length; i++) {
|
366
272
|
const mention = msg.mentions[i];
|
367
|
-
|
368
273
|
const tag = mention.tag;
|
369
|
-
if (typeof tag !== "string") {
|
370
|
-
return callback({ error: "Mention tags must be strings." });
|
371
|
-
}
|
372
|
-
|
274
|
+
if (typeof tag !== "string") return callback({ error: "Mention tags must be strings." });
|
373
275
|
const offset = msg.body.indexOf(tag, mention.fromIndex || 0);
|
374
|
-
|
375
|
-
if (
|
376
|
-
log.warn(
|
377
|
-
"handleMention",
|
378
|
-
'Mention for "' + tag + '" not found in message string.'
|
379
|
-
);
|
380
|
-
}
|
381
|
-
|
382
|
-
if (mention.id == null) {
|
383
|
-
log.warn("handleMention", "Mention id should be non-null.");
|
384
|
-
}
|
276
|
+
if (offset < 0) log.warn("handleMention", 'Mention for "' + tag + '" not found in message string.');
|
277
|
+
if (mention.id == null) log.warn("handleMention", "Mention id should be non-null.");
|
385
278
|
|
386
279
|
const id = mention.id || 0;
|
387
|
-
|
280
|
+
const emptyChar = '\u200E';
|
281
|
+
form["body"] = emptyChar + msg.body;
|
282
|
+
form["profile_xmd[" + i + "][offset]"] = offset + 1;
|
388
283
|
form["profile_xmd[" + i + "][length]"] = tag.length;
|
389
284
|
form["profile_xmd[" + i + "][id]"] = id;
|
390
285
|
form["profile_xmd[" + i + "][type]"] = "p";
|
@@ -393,39 +288,25 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
393
288
|
cb();
|
394
289
|
}
|
395
290
|
|
396
|
-
return function sendMessage(
|
397
|
-
|
398
|
-
threadID
|
399
|
-
callback,
|
400
|
-
replyToMessage,
|
401
|
-
isGroup
|
402
|
-
) {
|
403
|
-
typeof isGroup == "undefined" ? (isGroup = null) : "";
|
404
|
-
if (
|
405
|
-
!callback &&
|
406
|
-
(utils.getType(threadID) === "Function" ||
|
407
|
-
utils.getType(threadID) === "AsyncFunction")
|
408
|
-
) {
|
409
|
-
return threadID({ error: "Pass a threadID as a second argument." });
|
410
|
-
}
|
291
|
+
return function sendMessage(msg, threadID, callback, replyToMessage, isGroup) {
|
292
|
+
typeof isGroup == "undefined" ? isGroup = null : "";
|
293
|
+
if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) return threadID({ error: "Pass a threadID as a second argument." });
|
411
294
|
if (!replyToMessage && utils.getType(callback) === "String") {
|
412
295
|
replyToMessage = callback;
|
413
|
-
callback = function () {};
|
296
|
+
callback = function () { };
|
414
297
|
}
|
415
298
|
|
416
|
-
var resolveFunc = function () {};
|
417
|
-
var rejectFunc = function () {};
|
299
|
+
var resolveFunc = function () { };
|
300
|
+
var rejectFunc = function () { };
|
418
301
|
var returnPromise = new Promise(function (resolve, reject) {
|
419
302
|
resolveFunc = resolve;
|
420
303
|
rejectFunc = reject;
|
421
304
|
});
|
422
305
|
|
423
306
|
if (!callback) {
|
424
|
-
callback = function (err,
|
425
|
-
if (err)
|
426
|
-
|
427
|
-
}
|
428
|
-
resolveFunc(friendList);
|
307
|
+
callback = function (err, data) {
|
308
|
+
if (err) return rejectFunc(err);
|
309
|
+
resolveFunc(data);
|
429
310
|
};
|
430
311
|
}
|
431
312
|
|
@@ -433,46 +314,16 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
433
314
|
var threadIDType = utils.getType(threadID);
|
434
315
|
var messageIDType = utils.getType(replyToMessage);
|
435
316
|
|
436
|
-
if (msgType !== "String" && msgType !== "Object") {
|
437
|
-
return callback({
|
438
|
-
error:
|
439
|
-
"Message should be of type string or object and not " + msgType + ".",
|
440
|
-
});
|
441
|
-
}
|
317
|
+
if (msgType !== "String" && msgType !== "Object") return callback({ error: "Message should be of type string or object and not " + msgType + "." });
|
442
318
|
|
443
319
|
// Changing this to accomodate an array of users
|
444
|
-
if (
|
445
|
-
threadIDType !== "Array" &&
|
446
|
-
threadIDType !== "Number" &&
|
447
|
-
threadIDType !== "String"
|
448
|
-
) {
|
449
|
-
return callback({
|
450
|
-
error:
|
451
|
-
"ThreadID should be of type number, string, or array and not " +
|
452
|
-
threadIDType +
|
453
|
-
".",
|
454
|
-
});
|
455
|
-
}
|
456
|
-
|
457
|
-
if (replyToMessage && messageIDType !== "String") {
|
458
|
-
return callback({
|
459
|
-
error:
|
460
|
-
"MessageID should be of type string and not " + threadIDType + ".",
|
461
|
-
});
|
462
|
-
}
|
320
|
+
if (threadIDType !== "Array" && threadIDType !== "Number" && threadIDType !== "String") return callback({ error: "ThreadID should be of type number, string, or array and not " + threadIDType + "." });
|
463
321
|
|
464
|
-
if (
|
465
|
-
msg = { body: msg };
|
466
|
-
}
|
322
|
+
if (replyToMessage && messageIDType !== 'String') return callback({ error: "MessageID should be of type string and not " + threadIDType + "." });
|
467
323
|
|
468
|
-
|
469
|
-
|
470
|
-
);
|
471
|
-
if (disallowedProperties.length > 0) {
|
472
|
-
return callback({
|
473
|
-
error: "Dissallowed props: `" + disallowedProperties.join(", ") + "`",
|
474
|
-
});
|
475
|
-
}
|
324
|
+
if (msgType === "String") msg = { body: msg };
|
325
|
+
var disallowedProperties = Object.keys(msg).filter(prop => !allowedProperties[prop]);
|
326
|
+
if (disallowedProperties.length > 0) return callback({ error: "Dissallowed props: `" + disallowedProperties.join(", ") + "`" });
|
476
327
|
|
477
328
|
var messageAndOTID = utils.generateOfflineThreadingID();
|
478
329
|
|
@@ -495,7 +346,7 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
495
346
|
is_spoof_warning: false,
|
496
347
|
source: "source:chat:web",
|
497
348
|
"source_tags[0]": "source:chat",
|
498
|
-
body: msg.body ?
|
349
|
+
body: msg.body ? msg.body.toString().replace("\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f\ufe0f",' ') : "",
|
499
350
|
html_body: false,
|
500
351
|
ui_push_phase: "V3",
|
501
352
|
status: "0",
|
@@ -506,9 +357,9 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
506
357
|
manual_retry_cnt: "0",
|
507
358
|
has_attachment: !!(msg.attachment || msg.url || msg.sticker),
|
508
359
|
signatureID: utils.getSignatureID(),
|
509
|
-
replied_to_message_id: replyToMessage
|
360
|
+
replied_to_message_id: replyToMessage
|
510
361
|
};
|
511
|
-
|
362
|
+
|
512
363
|
handleLocation(msg, form, callback, () =>
|
513
364
|
handleSticker(msg, form, callback, () =>
|
514
365
|
handleAttachment(msg, form, callback, () =>
|