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