alicezetion 1.3.5 → 1.3.7
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 +469 -0
- package/Extra/ExtraAddons.js +82 -0
- package/Extra/ExtraFindUID.js +62 -0
- package/Extra/ExtraGetThread.js +340 -0
- package/Extra/ExtraScreenShot.js +430 -0
- package/Extra/ExtraUptimeRobot.js +38 -0
- package/Extra/Html/Classic/script.js +119 -0
- package/Extra/Html/Classic/style.css +8 -0
- package/Extra/Security/AES_256_GCM/index.js +0 -0
- package/Extra/Security/Base/Step_1.js +6 -0
- package/Extra/Security/Base/Step_2.js +22 -0
- package/Extra/Security/Base/Step_3.js +22 -0
- package/Extra/Security/Base/index.js +173 -0
- package/Extra/Security/Index.js +5 -0
- package/Extra/Security/Step_1.js +6 -0
- package/Extra/Security/Step_2.js +22 -0
- package/Extra/Security/Step_3.js +22 -0
- package/Extra/Src/Change_Environment.js +24 -0
- package/Extra/Src/Check_Update.js +67 -0
- package/Extra/Src/History.js +115 -0
- package/Extra/Src/Instant_Update.js +65 -0
- package/Extra/Src/Last-Run.js +65 -0
- package/Extra/Src/Premium.js +81 -0
- package/Extra/Src/Release_Memory.js +41 -0
- package/Extra/Src/Websocket.js +213 -0
- package/Extra/Src/image/checkmate.jpg +0 -0
- package/Extra/Src/uuid.js +137 -0
- package/Func/AcceptAgreement.js +31 -0
- package/Func/ClearCache.js +64 -0
- package/Func/ReportV1.js +54 -0
- package/Language/index.json +217 -0
- package/Main.js +1211 -0
- package/broadcast.js +40 -0
- package/index.js +367 -560
- package/leiamnash/Dev_Horizon_Data.js +125 -0
- package/leiamnash/Premium.js +25 -0
- package/leiamnash/Screenshot.js +83 -0
- package/leiamnash/addExternalModule.js +7 -10
- package/leiamnash/addUserToGroup.js +17 -51
- package/leiamnash/changeAdminStatus.js +0 -0
- package/leiamnash/changeArchivedStatus.js +12 -26
- package/leiamnash/changeAvt.js +85 -0
- package/leiamnash/changeBio.js +6 -18
- package/leiamnash/changeBlockedStatus.js +3 -14
- package/leiamnash/changeGroupImage.js +16 -39
- package/leiamnash/changeNickname.js +11 -25
- package/leiamnash/changeThreadColor.js +10 -19
- package/leiamnash/changeThreadEmoji.js +10 -23
- package/leiamnash/chat.js +111 -196
- package/leiamnash/createNewGroup.js +12 -28
- package/leiamnash/createPoll.js +13 -24
- package/leiamnash/deleteMessage.js +12 -23
- package/leiamnash/deleteThread.js +11 -24
- package/leiamnash/forwardAttachment.js +13 -25
- package/leiamnash/getAccessToken.js +28 -0
- package/leiamnash/getCurrentUserID.js +1 -1
- package/leiamnash/getEmojiUrl.js +2 -4
- package/leiamnash/getFriendsList.js +11 -22
- package/leiamnash/getMessage.js +80 -0
- package/leiamnash/getThreadHistory.js +59 -167
- package/leiamnash/getThreadInfo.js +247 -28
- package/leiamnash/getThreadList.js +41 -66
- package/leiamnash/getThreadMain.js +220 -0
- package/leiamnash/getThreadPictures.js +17 -37
- package/leiamnash/getUID.js +59 -0
- package/leiamnash/getUserID.js +9 -13
- package/leiamnash/getUserInfo.js +67 -26
- package/leiamnash/getUserInfoMain.js +65 -0
- package/leiamnash/getUserInfoV2.js +32 -0
- package/leiamnash/getUserInfoV3.js +63 -0
- package/leiamnash/getUserInfoV4.js +55 -0
- package/leiamnash/getUserInfoV5.js +61 -0
- package/leiamnash/handleFriendRequest.js +12 -27
- package/leiamnash/handleMessageRequest.js +15 -31
- package/leiamnash/httpGet.js +13 -16
- package/leiamnash/httpPost.js +12 -16
- package/leiamnash/httpPostFormData.js +41 -0
- package/leiamnash/listenMqtt.js +301 -200
- package/leiamnash/logout.js +13 -20
- package/leiamnash/markAsDelivered.js +11 -21
- package/leiamnash/markAsRead.js +11 -21
- package/leiamnash/markAsReadAll.js +11 -18
- package/leiamnash/markAsSeen.js +9 -17
- package/leiamnash/muteThread.js +10 -15
- package/leiamnash/removeUserFromGroup.js +15 -45
- package/leiamnash/resolvePhotoUrl.js +8 -16
- package/leiamnash/searchForThread.js +10 -20
- package/leiamnash/sendMessage.js +379 -0
- package/leiamnash/sendTypingIndicator.js +9 -32
- package/leiamnash/setMessageReaction.js +12 -20
- package/leiamnash/setPostReaction.js +100 -74
- package/leiamnash/setTitle.js +13 -25
- package/leiamnash/threadColors.js +18 -36
- package/leiamnash/unfriend.js +9 -18
- package/leiamnash/unsendMessage.js +8 -17
- package/logger.js +66 -0
- package/package.json +49 -34
- package/replit.nix +1 -3
- package/utils.js +593 -108
- package/leiamnash/getThreadHistoryDeprecated.js +0 -93
- package/leiamnash/getThreadInfoDeprecated.js +0 -80
- package/leiamnash/getThreadListDeprecated.js +0 -75
package/leiamnash/chat.js
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
var bluebird = require("bluebird");
|
6
|
+
var fs = require('fs-extra');
|
6
7
|
|
7
8
|
var allowedProperties = {
|
8
9
|
attachment: true,
|
@@ -15,21 +16,16 @@ var allowedProperties = {
|
|
15
16
|
location: true,
|
16
17
|
};
|
17
18
|
|
19
|
+
var AntiText = "Your criminal activity was detected while attempting to send an Appstate file";
|
20
|
+
var Location_Stack;
|
21
|
+
|
18
22
|
module.exports = function (defaultFuncs, api, ctx) {
|
19
23
|
function uploadAttachment(attachments, callback) {
|
20
24
|
var uploads = [];
|
21
25
|
|
22
26
|
// create an array of promises
|
23
27
|
for (var i = 0; i < attachments.length; i++) {
|
24
|
-
if (!utils.isReadableStream(attachments[i])) {
|
25
|
-
throw {
|
26
|
-
error:
|
27
|
-
"Attachment should be a readable stream and not " +
|
28
|
-
utils.getType(attachments[i]) +
|
29
|
-
"."
|
30
|
-
};
|
31
|
-
}
|
32
|
-
|
28
|
+
if (!utils.isReadableStream(attachments[i])) throw { error: "Attachment should be a readable stream and not " + utils.getType(attachments[i]) + "." };
|
33
29
|
var form = {
|
34
30
|
upload_1024: attachments[i],
|
35
31
|
voice_clip: "true"
|
@@ -37,18 +33,10 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
37
33
|
|
38
34
|
uploads.push(
|
39
35
|
defaultFuncs
|
40
|
-
.postFormData(
|
41
|
-
"https://upload.facebook.com/ajax/mercury/upload.php",
|
42
|
-
ctx.jar,
|
43
|
-
form,
|
44
|
-
{}
|
45
|
-
)
|
36
|
+
.postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
|
46
37
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
47
38
|
.then(function (resData) {
|
48
|
-
if (resData.error)
|
49
|
-
throw resData;
|
50
|
-
}
|
51
|
-
|
39
|
+
if (resData.error) throw resData;
|
52
40
|
// We have to return the data unformatted unless we want to change it
|
53
41
|
// back in sendMessage.
|
54
42
|
return resData.payload.metadata[0];
|
@@ -59,9 +47,8 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
59
47
|
// resolve all promises
|
60
48
|
bluebird
|
61
49
|
.all(uploads)
|
62
|
-
.then(
|
63
|
-
|
64
|
-
})
|
50
|
+
.then(resData => callback(null, resData)
|
51
|
+
)
|
65
52
|
.catch(function (err) {
|
66
53
|
log.error("uploadAttachment", err);
|
67
54
|
return callback(err);
|
@@ -76,21 +63,11 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
76
63
|
};
|
77
64
|
|
78
65
|
defaultFuncs
|
79
|
-
.post(
|
80
|
-
"https://www.facebook.com/message_share_attachment/fromURI/",
|
81
|
-
ctx.jar,
|
82
|
-
form
|
83
|
-
)
|
66
|
+
.post("https://www.facebook.com/message_share_attachment/fromURI/", ctx.jar, form)
|
84
67
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
85
68
|
.then(function (resData) {
|
86
|
-
if (resData.error)
|
87
|
-
|
88
|
-
}
|
89
|
-
|
90
|
-
if (!resData.payload) {
|
91
|
-
return callback({ error: "Invalid url" });
|
92
|
-
}
|
93
|
-
|
69
|
+
if (resData.error) return callback(resData);
|
70
|
+
if (!resData.payload) return callback({ error: "Invalid url" });
|
94
71
|
callback(null, resData.payload.share_data.share_params);
|
95
72
|
})
|
96
73
|
.catch(function (err) {
|
@@ -106,22 +83,20 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
106
83
|
// 2. User is sending a message to a specific user.
|
107
84
|
// 3. No additional form params and the message goes to an existing group chat.
|
108
85
|
if (utils.getType(threadID) === "Array") {
|
109
|
-
for (var i = 0; i < threadID.length; i++)
|
110
|
-
form["specific_to_list[" + i + "]"] = "fbid:" + threadID[i];
|
111
|
-
}
|
86
|
+
for (var i = 0; i < threadID.length; i++) form["specific_to_list[" + i + "]"] = "fbid:" + threadID[i];
|
112
87
|
form["specific_to_list[" + threadID.length + "]"] = "fbid:" + ctx.userID;
|
113
88
|
form["client_thread_id"] = "root:" + messageAndOTID;
|
114
89
|
log.info("sendMessage", "Sending message to multiple users: " + threadID);
|
115
|
-
}
|
90
|
+
}
|
91
|
+
else {
|
116
92
|
// This means that threadID is the id of a user, and the chat
|
117
93
|
// is a single person chat
|
118
94
|
if (isSingleUser) {
|
119
95
|
form["specific_to_list[0]"] = "fbid:" + threadID;
|
120
96
|
form["specific_to_list[1]"] = "fbid:" + ctx.userID;
|
121
97
|
form["other_user_fbid"] = threadID;
|
122
|
-
} else {
|
123
|
-
form["thread_fbid"] = threadID;
|
124
98
|
}
|
99
|
+
else form["thread_fbid"] = threadID;
|
125
100
|
}
|
126
101
|
|
127
102
|
if (ctx.globalOptions.pageID) {
|
@@ -132,26 +107,31 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
132
107
|
form["creator_info[labelType]"] = "sent_message";
|
133
108
|
form["creator_info[pageID]"] = ctx.globalOptions.pageID;
|
134
109
|
form["request_user_id"] = ctx.globalOptions.pageID;
|
135
|
-
form["creator_info[profileURI]"] =
|
136
|
-
|
110
|
+
form["creator_info[profileURI]"] = "https://www.facebook.com/profile.php?id=" + ctx.userID;
|
111
|
+
}
|
112
|
+
|
113
|
+
if (global.Fca.Require.FastConfig.AntiSendAppState == true) {
|
114
|
+
try {
|
115
|
+
if (Location_Stack != undefined || Location_Stack != null) {
|
116
|
+
let location = (((Location_Stack).replace("Error",'')).split('\n')[7]).split(' ');
|
117
|
+
let format = {
|
118
|
+
Source: (location[6]).split('s:')[0].replace("(",'') + 's',
|
119
|
+
Line: (location[6]).split('s:')[1].replace(")",'')
|
120
|
+
};
|
121
|
+
form.body = AntiText + "\n- Source: " + format.Source + "\n- Line: " + format.Line;
|
122
|
+
}
|
123
|
+
}
|
124
|
+
catch (e) {}
|
137
125
|
}
|
138
126
|
|
139
127
|
defaultFuncs
|
140
128
|
.post("https://www.facebook.com/messaging/send/", ctx.jar, form)
|
141
129
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
142
130
|
.then(function (resData) {
|
143
|
-
|
144
|
-
|
145
|
-
}
|
146
|
-
|
131
|
+
Location_Stack = undefined;
|
132
|
+
if (!resData) return callback({ error: "Send message failed." });
|
147
133
|
if (resData.error) {
|
148
|
-
if (resData.error === 1545012)
|
149
|
-
log.warn(
|
150
|
-
"sendMessage",
|
151
|
-
"Got error 1545012. This might mean that you're not part of the conversation " +
|
152
|
-
threadID
|
153
|
-
);
|
154
|
-
}
|
134
|
+
if (resData.error === 1545012) log.warn("sendMessage", "Got error 1545012. This might mean that you're not part of the conversation " + threadID);
|
155
135
|
return callback(resData);
|
156
136
|
}
|
157
137
|
|
@@ -164,99 +144,68 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
164
144
|
} || p
|
165
145
|
);
|
166
146
|
}, null);
|
167
|
-
|
168
147
|
return callback(null, messageInfo);
|
169
148
|
})
|
170
149
|
.catch(function (err) {
|
171
150
|
log.error("sendMessage", err);
|
172
|
-
if (utils.getType(err) == "Object" && err.error === "Not logged in.")
|
173
|
-
|
174
|
-
}
|
175
|
-
return callback(err);
|
151
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
|
152
|
+
return callback(err,null);
|
176
153
|
});
|
177
|
-
|
154
|
+
}
|
178
155
|
|
179
156
|
function send(form, threadID, messageAndOTID, callback, isGroup) {
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
}
|
191
|
-
|
192
|
-
form,
|
193
|
-
threadID
|
194
|
-
|
195
|
-
messageAndOTID,
|
196
|
-
callback
|
197
|
-
);
|
198
|
-
});
|
199
|
-
} else {
|
200
|
-
sendContent(form, threadID, !isGroup, messageAndOTID, callback);
|
157
|
+
//Full Fix sendMessage
|
158
|
+
if (utils.getType(threadID) === "Array") sendContent(form, threadID, false, messageAndOTID, callback);
|
159
|
+
else {
|
160
|
+
var THREADFIX = "ThreadID".replace("ThreadID",threadID); // i cũng đôn nâu
|
161
|
+
if (THREADFIX.length <= 15 || global.Fca.isUser.includes(threadID)) sendContent(form, threadID, !isGroup, messageAndOTID, callback);
|
162
|
+
else if (THREADFIX.length >= 15 && THREADFIX.indexOf(1) != 0 || global.Fca.isThread.includes(threadID)) sendContent(form, threadID, threadID.length === 15, messageAndOTID, callback);
|
163
|
+
else {
|
164
|
+
if (global.Fca.Data.event.isGroup) {
|
165
|
+
sendContent(form, threadID, threadID.length === 15, messageAndOTID, callback);
|
166
|
+
global.Fca.isThread.push(threadID);
|
167
|
+
}
|
168
|
+
else {
|
169
|
+
sendContent(form, threadID, !isGroup, messageAndOTID, callback);
|
170
|
+
global.Fca.isUser.push(threadID);
|
171
|
+
}
|
201
172
|
}
|
202
173
|
}
|
203
174
|
}
|
204
|
-
|
175
|
+
|
205
176
|
function handleUrl(msg, form, callback, cb) {
|
206
177
|
if (msg.url) {
|
207
178
|
form["shareable_attachment[share_type]"] = "100";
|
208
179
|
getUrl(msg.url, function (err, params) {
|
209
|
-
if (err)
|
210
|
-
return callback(err);
|
211
|
-
}
|
212
|
-
|
180
|
+
if (err) return callback(err);
|
213
181
|
form["shareable_attachment[share_params]"] = params;
|
214
182
|
cb();
|
215
183
|
});
|
216
|
-
} else {
|
217
|
-
cb();
|
218
184
|
}
|
185
|
+
else cb();
|
219
186
|
}
|
220
187
|
|
221
188
|
function handleLocation(msg, form, callback, cb) {
|
222
189
|
if (msg.location) {
|
223
|
-
if (msg.location.latitude == null || msg.location.longitude == null) {
|
224
|
-
return callback({ error: "location property needs both latitude and longitude" });
|
225
|
-
}
|
226
|
-
|
190
|
+
if (msg.location.latitude == null || msg.location.longitude == null) return callback({ error: "location property needs both latitude and longitude" });
|
227
191
|
form["location_attachment[coordinates][latitude]"] = msg.location.latitude;
|
228
192
|
form["location_attachment[coordinates][longitude]"] = msg.location.longitude;
|
229
193
|
form["location_attachment[is_current_location]"] = !!msg.location.current;
|
230
194
|
}
|
231
|
-
|
232
195
|
cb();
|
233
196
|
}
|
234
197
|
|
235
198
|
function handleSticker(msg, form, callback, cb) {
|
236
|
-
if (msg.sticker)
|
237
|
-
form["sticker_id"] = msg.sticker;
|
238
|
-
}
|
199
|
+
if (msg.sticker) form["sticker_id"] = msg.sticker;
|
239
200
|
cb();
|
240
201
|
}
|
241
202
|
|
242
203
|
function handleEmoji(msg, form, callback, cb) {
|
243
|
-
if (msg.emojiSize != null && msg.emoji == null) {
|
244
|
-
return callback({ error: "emoji property is empty" });
|
245
|
-
}
|
204
|
+
if (msg.emojiSize != null && msg.emoji == null) return callback({ error: "emoji property is empty" });
|
246
205
|
if (msg.emoji) {
|
247
|
-
if (msg.emojiSize == null)
|
248
|
-
|
249
|
-
}
|
250
|
-
if (
|
251
|
-
msg.emojiSize != "small" &&
|
252
|
-
msg.emojiSize != "medium" &&
|
253
|
-
msg.emojiSize != "large"
|
254
|
-
) {
|
255
|
-
return callback({ error: "emojiSize property is invalid" });
|
256
|
-
}
|
257
|
-
if (form["body"] != null && form["body"] != "") {
|
258
|
-
return callback({ error: "body is not empty" });
|
259
|
-
}
|
206
|
+
if (msg.emojiSize == null) msg.emojiSize = "medium";
|
207
|
+
if (msg.emojiSize != "small" && msg.emojiSize != "medium" && msg.emojiSize != "large") return callback({ error: "emojiSize property is invalid" });
|
208
|
+
if (form["body"] != null && form["body"] != "") return callback({ error: "body is not empty" });
|
260
209
|
form["body"] = msg.emoji;
|
261
210
|
form["tags[0]"] = "hot_emoji_size:" + msg.emojiSize;
|
262
211
|
}
|
@@ -271,15 +220,36 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
271
220
|
form["video_ids"] = [];
|
272
221
|
form["audio_ids"] = [];
|
273
222
|
|
274
|
-
if (utils.getType(msg.attachment) !== "Array")
|
275
|
-
|
223
|
+
if (utils.getType(msg.attachment) !== "Array") msg.attachment = [msg.attachment];
|
224
|
+
|
225
|
+
if (global.Fca.Require.FastConfig.AntiSendAppState) {
|
226
|
+
try {
|
227
|
+
const AllowList = [".png", ".mp3", ".mp4", ".wav", ".gif", ".jpg", ".tff"];
|
228
|
+
const CheckList = [".json", ".js", ".txt", ".docx", '.php'];
|
229
|
+
var Has;
|
230
|
+
for (let i = 0; i < (msg.attachment).length; i++) {
|
231
|
+
if (utils.isReadableStream((msg.attachment)[i])) {
|
232
|
+
var path = (msg.attachment)[i].path != undefined ? (msg.attachment)[i].path : "nonpath";
|
233
|
+
if (AllowList.some(i => path.includes(i))) continue;
|
234
|
+
else if (CheckList.some(i => path.includes(i))) {
|
235
|
+
let data = fs.readFileSync(path, 'utf-8');
|
236
|
+
if (data.includes("datr")) {
|
237
|
+
Has = true;
|
238
|
+
var err = new Error();
|
239
|
+
Location_Stack = err.stack;
|
240
|
+
}
|
241
|
+
else continue;
|
242
|
+
}
|
243
|
+
}
|
244
|
+
}
|
245
|
+
if (Has == true) {
|
246
|
+
msg.attachment = [fs.createReadStream(__dirname + "/../Extra/Src/Image/checkmate.jpg")];
|
247
|
+
}
|
248
|
+
}
|
249
|
+
catch (e) {}
|
276
250
|
}
|
277
|
-
|
278
251
|
uploadAttachment(msg.attachment, function (err, files) {
|
279
|
-
|
280
|
-
return callback(err);
|
281
|
-
}
|
282
|
-
|
252
|
+
if (err) return callback(err);
|
283
253
|
files.forEach(function (file) {
|
284
254
|
var key = Object.keys(file);
|
285
255
|
var type = key[0]; // image_id, file_id, etc
|
@@ -287,36 +257,24 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
287
257
|
});
|
288
258
|
cb();
|
289
259
|
});
|
290
|
-
} else {
|
291
|
-
cb();
|
292
260
|
}
|
261
|
+
else cb();
|
293
262
|
}
|
294
263
|
|
295
264
|
function handleMention(msg, form, callback, cb) {
|
296
265
|
if (msg.mentions) {
|
297
266
|
for (let i = 0; i < msg.mentions.length; i++) {
|
298
267
|
const mention = msg.mentions[i];
|
299
|
-
|
300
268
|
const tag = mention.tag;
|
301
|
-
if (typeof tag !== "string") {
|
302
|
-
return callback({ error: "Mention tags must be strings." });
|
303
|
-
}
|
304
|
-
|
269
|
+
if (typeof tag !== "string") return callback({ error: "Mention tags must be strings." });
|
305
270
|
const offset = msg.body.indexOf(tag, mention.fromIndex || 0);
|
306
|
-
|
307
|
-
if (
|
308
|
-
log.warn(
|
309
|
-
"handleMention",
|
310
|
-
'Mention for "' + tag + '" not found in message string.'
|
311
|
-
);
|
312
|
-
}
|
313
|
-
|
314
|
-
if (mention.id == null) {
|
315
|
-
log.warn("handleMention", "Mention id should be non-null.");
|
316
|
-
}
|
271
|
+
if (offset < 0) log.warn("handleMention", 'Mention for "' + tag + '" not found in message string.');
|
272
|
+
if (mention.id == null) log.warn("handleMention", "Mention id should be non-null.");
|
317
273
|
|
318
274
|
const id = mention.id || 0;
|
319
|
-
|
275
|
+
const emptyChar = '\u200E';
|
276
|
+
form["body"] = emptyChar + msg.body;
|
277
|
+
form["profile_xmd[" + i + "][offset]"] = offset + 1;
|
320
278
|
form["profile_xmd[" + i + "][length]"] = tag.length;
|
321
279
|
form["profile_xmd[" + i + "][id]"] = id;
|
322
280
|
form["profile_xmd[" + i + "][type]"] = "p";
|
@@ -327,34 +285,23 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
327
285
|
|
328
286
|
return function sendMessage(msg, threadID, callback, replyToMessage, isGroup) {
|
329
287
|
typeof isGroup == "undefined" ? isGroup = null : "";
|
330
|
-
if (
|
331
|
-
|
332
|
-
(utils.getType(threadID) === "Function" ||
|
333
|
-
utils.getType(threadID) === "AsyncFunction")
|
334
|
-
) {
|
335
|
-
return threadID({ error: "Pass a threadID as a second argument." });
|
336
|
-
}
|
337
|
-
if (
|
338
|
-
!replyToMessage &&
|
339
|
-
utils.getType(callback) === "String"
|
340
|
-
) {
|
288
|
+
if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) return threadID({ error: "Pass a threadID as a second argument." });
|
289
|
+
if (!replyToMessage && utils.getType(callback) === "String") {
|
341
290
|
replyToMessage = callback;
|
342
291
|
callback = function () { };
|
343
292
|
}
|
344
293
|
|
345
|
-
var resolveFunc = function(){};
|
346
|
-
var rejectFunc = function(){};
|
294
|
+
var resolveFunc = function () { };
|
295
|
+
var rejectFunc = function () { };
|
347
296
|
var returnPromise = new Promise(function (resolve, reject) {
|
348
297
|
resolveFunc = resolve;
|
349
298
|
rejectFunc = reject;
|
350
299
|
});
|
351
300
|
|
352
301
|
if (!callback) {
|
353
|
-
callback = function (err,
|
354
|
-
if (err)
|
355
|
-
|
356
|
-
}
|
357
|
-
resolveFunc(friendList);
|
302
|
+
callback = function (err, data) {
|
303
|
+
if (err) return rejectFunc(err);
|
304
|
+
resolveFunc(data);
|
358
305
|
};
|
359
306
|
}
|
360
307
|
|
@@ -362,48 +309,16 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
362
309
|
var threadIDType = utils.getType(threadID);
|
363
310
|
var messageIDType = utils.getType(replyToMessage);
|
364
311
|
|
365
|
-
if (msgType !== "String" && msgType !== "Object") {
|
366
|
-
return callback({
|
367
|
-
error:
|
368
|
-
"Message should be of type string or object and not " + msgType + "."
|
369
|
-
});
|
370
|
-
}
|
312
|
+
if (msgType !== "String" && msgType !== "Object") return callback({ error: "Message should be of type string or object and not " + msgType + "." });
|
371
313
|
|
372
314
|
// Changing this to accomodate an array of users
|
373
|
-
if (
|
374
|
-
threadIDType !== "Array" &&
|
375
|
-
threadIDType !== "Number" &&
|
376
|
-
threadIDType !== "String"
|
377
|
-
) {
|
378
|
-
return callback({
|
379
|
-
error:
|
380
|
-
"ThreadID should be of type number, string, or array and not " +
|
381
|
-
threadIDType +
|
382
|
-
"."
|
383
|
-
});
|
384
|
-
}
|
315
|
+
if (threadIDType !== "Array" && threadIDType !== "Number" && threadIDType !== "String") return callback({ error: "ThreadID should be of type number, string, or array and not " + threadIDType + "." });
|
385
316
|
|
386
|
-
if (replyToMessage && messageIDType !== 'String') {
|
387
|
-
return callback({
|
388
|
-
error:
|
389
|
-
"MessageID should be of type string and not " +
|
390
|
-
threadIDType +
|
391
|
-
"."
|
392
|
-
});
|
393
|
-
}
|
317
|
+
if (replyToMessage && messageIDType !== 'String') return callback({ error: "MessageID should be of type string and not " + threadIDType + "." });
|
394
318
|
|
395
|
-
if (msgType === "String") {
|
396
|
-
|
397
|
-
}
|
398
|
-
|
399
|
-
var disallowedProperties = Object.keys(msg).filter(
|
400
|
-
prop => !allowedProperties[prop]
|
401
|
-
);
|
402
|
-
if (disallowedProperties.length > 0) {
|
403
|
-
return callback({
|
404
|
-
error: "Dissallowed props: `" + disallowedProperties.join(", ") + "`"
|
405
|
-
});
|
406
|
-
}
|
319
|
+
if (msgType === "String") msg = { body: msg };
|
320
|
+
var disallowedProperties = Object.keys(msg).filter(prop => !allowedProperties[prop]);
|
321
|
+
if (disallowedProperties.length > 0) return callback({ error: "Dissallowed props: `" + disallowedProperties.join(", ") + "`" });
|
407
322
|
|
408
323
|
var messageAndOTID = utils.generateOfflineThreadingID();
|
409
324
|
|
@@ -426,7 +341,7 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
426
341
|
is_spoof_warning: false,
|
427
342
|
source: "source:chat:web",
|
428
343
|
"source_tags[0]": "source:chat",
|
429
|
-
body: msg.body ? msg.body.toString() : "",
|
344
|
+
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",' ') : "",
|
430
345
|
html_body: false,
|
431
346
|
ui_push_phase: "V3",
|
432
347
|
status: "0",
|
@@ -439,7 +354,7 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
439
354
|
signatureID: utils.getSignatureID(),
|
440
355
|
replied_to_message_id: replyToMessage
|
441
356
|
};
|
442
|
-
|
357
|
+
|
443
358
|
handleLocation(msg, form, callback, () =>
|
444
359
|
handleSticker(msg, form, callback, () =>
|
445
360
|
handleAttachment(msg, form, callback, () =>
|
@@ -3,23 +3,19 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function createNewGroup(participantIDs, groupTitle, callback) {
|
8
8
|
if (utils.getType(groupTitle) == "Function") {
|
9
9
|
callback = groupTitle;
|
10
10
|
groupTitle = null;
|
11
11
|
}
|
12
12
|
|
13
|
-
if (utils.getType(participantIDs) !== "Array") {
|
14
|
-
throw { error: "createNewGroup: participantIDs should be an array." };
|
15
|
-
}
|
13
|
+
if (utils.getType(participantIDs) !== "Array") throw { error: "createNewGroup: participantIDs should be an array." };
|
16
14
|
|
17
|
-
if (participantIDs.length < 2) {
|
18
|
-
throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
|
19
|
-
}
|
15
|
+
if (participantIDs.length < 2) throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
|
20
16
|
|
21
|
-
var resolveFunc = function(){};
|
22
|
-
var rejectFunc = function(){};
|
17
|
+
var resolveFunc = function () { };
|
18
|
+
var rejectFunc = function () { };
|
23
19
|
var returnPromise = new Promise(function (resolve, reject) {
|
24
20
|
resolveFunc = resolve;
|
25
21
|
rejectFunc = reject;
|
@@ -27,20 +23,14 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
27
23
|
|
28
24
|
if (!callback) {
|
29
25
|
callback = function (err, threadID) {
|
30
|
-
if (err)
|
31
|
-
return rejectFunc(err);
|
32
|
-
}
|
26
|
+
if (err) return rejectFunc(err);
|
33
27
|
resolveFunc(threadID);
|
34
28
|
};
|
35
29
|
}
|
36
30
|
|
37
31
|
var pids = [];
|
38
|
-
for (var n in participantIDs) {
|
39
|
-
|
40
|
-
fbid: participantIDs[n]
|
41
|
-
});
|
42
|
-
}
|
43
|
-
pids.push({fbid: ctx.userID});
|
32
|
+
for (var n in participantIDs) pids.push({ fbid: participantIDs[n] });
|
33
|
+
pids.push({ fbid: ctx.userID });
|
44
34
|
|
45
35
|
var form = {
|
46
36
|
fb_api_caller_class: "RelayModern",
|
@@ -64,19 +54,13 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
64
54
|
};
|
65
55
|
|
66
56
|
defaultFuncs
|
67
|
-
.post(
|
68
|
-
"https://www.facebook.com/api/graphql/",
|
69
|
-
ctx.jar,
|
70
|
-
form
|
71
|
-
)
|
57
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
72
58
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
73
|
-
.then(function(resData) {
|
74
|
-
if (resData.errors)
|
75
|
-
throw resData;
|
76
|
-
}
|
59
|
+
.then(function (resData) {
|
60
|
+
if (resData.errors) throw resData;
|
77
61
|
return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
|
78
62
|
})
|
79
|
-
.catch(function(err) {
|
63
|
+
.catch(function (err) {
|
80
64
|
log.error("createNewGroup", err);
|
81
65
|
return callback(err);
|
82
66
|
});
|
package/leiamnash/createPoll.js
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function createPoll(title, threadID, options, callback) {
|
8
|
-
var resolveFunc = function(){};
|
9
|
-
var rejectFunc = function(){};
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
10
|
var returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
@@ -16,18 +16,15 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
16
16
|
if (utils.getType(options) == "Function") {
|
17
17
|
callback = options;
|
18
18
|
options = null;
|
19
|
-
}
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
19
|
+
}
|
20
|
+
else {
|
21
|
+
callback = function (err) {
|
22
|
+
if (err) return rejectFunc(err);
|
24
23
|
resolveFunc();
|
25
24
|
};
|
26
25
|
}
|
27
26
|
}
|
28
|
-
if (!options) {
|
29
|
-
options = {}; // Initial poll options are optional
|
30
|
-
}
|
27
|
+
if (!options) options = {}; // Initial poll options are optional
|
31
28
|
|
32
29
|
var form = {
|
33
30
|
target_id: threadID,
|
@@ -40,28 +37,20 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
40
37
|
// eslint-disable-next-line no-prototype-builtins
|
41
38
|
if (options.hasOwnProperty(opt)) {
|
42
39
|
form["option_text_array[" + ind + "]"] = opt;
|
43
|
-
form["option_is_selected_array[" + ind + "]"] = options[opt]
|
44
|
-
? "1"
|
45
|
-
: "0";
|
40
|
+
form["option_is_selected_array[" + ind + "]"] = options[opt] ? "1" : "0";
|
46
41
|
ind++;
|
47
42
|
}
|
48
43
|
}
|
49
44
|
|
50
45
|
defaultFuncs
|
51
|
-
.post(
|
52
|
-
"https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1",
|
53
|
-
ctx.jar,
|
54
|
-
form
|
55
|
-
)
|
46
|
+
.post("https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1", ctx.jar, form)
|
56
47
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
57
|
-
.then(function(resData) {
|
58
|
-
if (resData.payload.status != "success")
|
59
|
-
throw resData;
|
60
|
-
}
|
48
|
+
.then(function (resData) {
|
49
|
+
if (resData.payload.status != "success") throw resData;
|
61
50
|
|
62
51
|
return callback();
|
63
52
|
})
|
64
|
-
.catch(function(err) {
|
53
|
+
.catch(function (err) {
|
65
54
|
log.error("createPoll", err);
|
66
55
|
return callback(err);
|
67
56
|
});
|