fca-smart-shankar 10.9.1 → 13.0.0

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.
Files changed (169) hide show
  1. package/.replit +12 -3
  2. package/.upm/store.json +1 -1
  3. package/CHANGELOG.md +2 -0
  4. package/LICENSE-MIT +21 -0
  5. package/README.md +175 -30
  6. package/generated-icon.png +0 -0
  7. package/index.js +511 -414
  8. package/package.json +370 -85
  9. package/replit.nix +5 -0
  10. package/shankar-fca.json +4 -0
  11. package/src/addExternalModule.js +14 -5
  12. package/src/addUserToGroup.js +56 -20
  13. package/src/changeAdminStatus.js +44 -20
  14. package/src/changeArchivedStatus.js +25 -11
  15. package/src/changeAvatar.js +136 -0
  16. package/src/{changeAvt.js → changeAvatarV2.js} +3 -2
  17. package/src/changeBio.js +26 -15
  18. package/src/changeBlockedStatus.js +21 -8
  19. package/src/changeBlockedStatusMqtt.js +80 -0
  20. package/src/changeCover.js +73 -0
  21. package/src/changeGroupImage.js +53 -24
  22. package/src/changeName.js +79 -0
  23. package/src/changeNickname.js +27 -13
  24. package/src/changeThreadColor.js +22 -19
  25. package/src/changeThreadEmoji.js +24 -11
  26. package/src/changeUsername.js +59 -0
  27. package/src/createCommentPost.js +230 -0
  28. package/src/createNewGroup.js +38 -20
  29. package/src/createPoll.js +27 -16
  30. package/src/createPost.js +277 -0
  31. package/src/data/getThreadInfo.json +1 -0
  32. package/src/deleteMessage.js +24 -13
  33. package/src/deleteThread.js +25 -12
  34. package/src/editMessage.js +71 -53
  35. package/src/editMessageOld.js +67 -0
  36. package/src/follow.js +74 -0
  37. package/src/forwardAttachment.js +27 -15
  38. package/src/getAccess.js +112 -0
  39. package/src/getAvatarUser.js +78 -0
  40. package/src/getCurrentUserID.js +1 -1
  41. package/src/getEmojiUrl.js +10 -8
  42. package/src/getFriendsList.js +25 -15
  43. package/src/getMessage.js +813 -81
  44. package/src/getRegion.js +7 -0
  45. package/src/getThreadHistory.js +241 -98
  46. package/src/getThreadHistoryDeprecated.js +93 -0
  47. package/src/getThreadInfo.js +90 -287
  48. package/src/getThreadInfoDeprecated.js +80 -0
  49. package/src/getThreadList.js +214 -157
  50. package/src/getThreadListDeprecated.js +75 -0
  51. package/src/getThreadPictures.js +39 -19
  52. package/src/getUID.js +113 -50
  53. package/src/getUserID.js +18 -14
  54. package/src/getUserInfo.js +65 -71
  55. package/src/handleFriendRequest.js +24 -13
  56. package/src/handleMessageRequest.js +36 -20
  57. package/src/httpGet.js +34 -18
  58. package/src/httpPost.js +35 -18
  59. package/src/httpPostFormData.js +53 -24
  60. package/src/listenMqtt.js +680 -944
  61. package/src/listenNotification.js +85 -0
  62. package/src/logout.js +22 -15
  63. package/src/markAsDelivered.js +25 -15
  64. package/src/markAsRead.js +45 -27
  65. package/src/markAsReadAll.js +21 -14
  66. package/src/markAsSeen.js +28 -18
  67. package/src/muteThread.js +17 -12
  68. package/src/pinMessage.js +59 -0
  69. package/src/refreshFb_dtsg.js +89 -0
  70. package/src/removeUserFromGroup.js +47 -17
  71. package/src/resolvePhotoUrl.js +21 -13
  72. package/src/searchForThread.js +23 -13
  73. package/src/searchStickers.js +53 -0
  74. package/src/sendMessage.js +178 -117
  75. package/src/sendMessageMqtt.js +322 -0
  76. package/src/sendTypingIndicator.js +46 -16
  77. package/src/sendTypingIndicatorV2.js +28 -0
  78. package/src/setMessageReaction.js +33 -20
  79. package/src/setMessageReactionMqtt.js +62 -0
  80. package/src/setPostReaction.js +105 -95
  81. package/src/setProfileGuard.js +45 -0
  82. package/src/setStoryReaction.js +64 -0
  83. package/src/setTitle.js +34 -18
  84. package/src/shareContact.js +92 -37
  85. package/src/shareLink.js +5 -4
  86. package/src/stopListenMqtt.js +26 -0
  87. package/src/threadColors.js +110 -18
  88. package/src/unfriend.js +18 -9
  89. package/src/unsendMessage.js +31 -34
  90. package/src/uploadAttachment.js +94 -0
  91. package/test/data/shareAttach.js +1 -1
  92. package/test/test.js +1 -1
  93. package/utils.js +1393 -2918
  94. package/.cache/replit/env/latest +0 -56
  95. package/.cache/replit/env/latest.json +0 -1
  96. package/.cache/replit/modules/nodejs-14.res +0 -1
  97. package/.cache/replit/modules/replit.res +0 -1
  98. package/.cache/replit/modules/web.res +0 -1
  99. package/.cache/replit/modules.stamp +0 -0
  100. package/.cache/typescript/5.5/package.json +0 -1
  101. package/.config/configstore/update-notifier-npm.json +0 -4
  102. package/.gitattributes +0 -2
  103. package/Extra/Balancer.js +0 -49
  104. package/Extra/Bypass/956/index.js +0 -234
  105. package/Extra/Bypass/test/aaaa.json +0 -170
  106. package/Extra/Bypass/test/index.js +0 -188
  107. package/Extra/Database/index.js +0 -469
  108. package/Extra/ExtraAddons.js +0 -82
  109. package/Extra/ExtraFindUID.js +0 -62
  110. package/Extra/ExtraGetThread.js +0 -365
  111. package/Extra/ExtraScreenShot.js +0 -430
  112. package/Extra/ExtraUptimeRobot.js +0 -38
  113. package/Extra/Html/Classic/script.js +0 -119
  114. package/Extra/Html/Classic/style.css +0 -8
  115. package/Extra/Security/AES_256_GCM/index.js +0 -0
  116. package/Extra/Security/Base/Step_1.js +0 -6
  117. package/Extra/Security/Base/Step_2.js +0 -22
  118. package/Extra/Security/Base/Step_3.js +0 -22
  119. package/Extra/Security/Base/index.js +0 -191
  120. package/Extra/Security/Index.js +0 -5
  121. package/Extra/Security/Step_1.js +0 -6
  122. package/Extra/Security/Step_2.js +0 -22
  123. package/Extra/Security/Step_3.js +0 -22
  124. package/Extra/Src/Change_Environment.js +0 -24
  125. package/Extra/Src/Check_Update.js +0 -67
  126. package/Extra/Src/History.js +0 -115
  127. package/Extra/Src/Instant_Update.js +0 -65
  128. package/Extra/Src/Last-Run.js +0 -65
  129. package/Extra/Src/Premium.js +0 -81
  130. package/Extra/Src/Release_Memory.js +0 -160
  131. package/Extra/Src/Websocket.js +0 -213
  132. package/Extra/Src/image/checkmate.jpg +0 -0
  133. package/Extra/Src/test.js +0 -28
  134. package/Extra/Src/uuid.js +0 -137
  135. package/Func/AcceptAgreement.js +0 -31
  136. package/Func/ClearCache.js +0 -64
  137. package/Func/ReportV1.js +0 -54
  138. package/LICENSE +0 -678
  139. package/Language/index.json +0 -228
  140. package/Main.js +0 -1444
  141. package/SECURITY.md +0 -18
  142. package/broadcast.js +0 -44
  143. package/logger.js +0 -66
  144. package/src/Dev_Horizon_Data.js +0 -125
  145. package/src/Dev_getThreadInfoOLD.js +0 -422
  146. package/src/Dev_shareTest2.js +0 -68
  147. package/src/Dev_shareTest3.js +0 -71
  148. package/src/Premium.js +0 -25
  149. package/src/Screenshot.js +0 -83
  150. package/src/getAccessToken.js +0 -28
  151. package/src/getThreadInfoOLD.js +0 -422
  152. package/src/getThreadMain.js +0 -220
  153. package/src/getUserInfoMain.js +0 -65
  154. package/src/getUserInfoV2.js +0 -32
  155. package/src/getUserInfoV3.js +0 -63
  156. package/src/getUserInfoV4.js +0 -55
  157. package/src/getUserInfoV5.js +0 -61
  158. package/src/listenMqttV1.js +0 -846
  159. package/src/sendMqttMessage.js +0 -71
  160. package/src/unsendMqttMessage.js +0 -66
  161. package/test/Database_Test.js +0 -4
  162. package/test/Db2.js +0 -530
  163. package/test/Shankar_Database/A_README.md +0 -1
  164. package/test/Shankar_Database/Database.db +0 -0
  165. package/test/env/.env +0 -0
  166. package/test/example-db.db +0 -0
  167. package/test/memoryleak.js +0 -18
  168. package/test/testname.js +0 -1342
  169. package/test/testv2.js +0 -3
@@ -1,14 +1,8 @@
1
1
  "use strict";
2
2
 
3
- /**
4
- * Được Fix Hay Làm Màu Bởi: @HarryWakazaki
5
- * 21/4/2022
6
- */
7
-
8
3
  var utils = require("../utils");
9
4
  var log = require("npmlog");
10
5
  var bluebird = require("bluebird");
11
- var fs = require('fs-extra');
12
6
 
13
7
  var allowedProperties = {
14
8
  attachment: true,
@@ -21,16 +15,21 @@ var allowedProperties = {
21
15
  location: true,
22
16
  };
23
17
 
24
- var AntiText = "Your criminal activity was detected while attempting to send an Appstate file";
25
- var Location_Stack;
26
-
27
18
  module.exports = function (defaultFuncs, api, ctx) {
28
19
  function uploadAttachment(attachments, callback) {
29
20
  var uploads = [];
30
21
 
31
22
  // create an array of promises
32
23
  for (var i = 0; i < attachments.length; i++) {
33
- if (!utils.isReadableStream(attachments[i])) throw { error: "Attachment should be a readable stream and not " + utils.getType(attachments[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
+
34
33
  var form = {
35
34
  upload_1024: attachments[i],
36
35
  voice_clip: "true"
@@ -38,10 +37,18 @@ module.exports = function (defaultFuncs, api, ctx) {
38
37
 
39
38
  uploads.push(
40
39
  defaultFuncs
41
- .postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
40
+ .postFormData(
41
+ "https://upload.facebook.com/ajax/mercury/upload.php",
42
+ ctx.jar,
43
+ form,
44
+ {}
45
+ )
42
46
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
43
47
  .then(function (resData) {
44
- if (resData.error) throw resData;
48
+ if (resData.error) {
49
+ throw resData;
50
+ }
51
+
45
52
  // We have to return the data unformatted unless we want to change it
46
53
  // back in sendMessage.
47
54
  return resData.payload.metadata[0];
@@ -52,8 +59,9 @@ module.exports = function (defaultFuncs, api, ctx) {
52
59
  // resolve all promises
53
60
  bluebird
54
61
  .all(uploads)
55
- .then(resData => callback(null, resData)
56
- )
62
+ .then(function (resData) {
63
+ callback(null, resData);
64
+ })
57
65
  .catch(function (err) {
58
66
  log.error("uploadAttachment", err);
59
67
  return callback(err);
@@ -68,11 +76,21 @@ module.exports = function (defaultFuncs, api, ctx) {
68
76
  };
69
77
 
70
78
  defaultFuncs
71
- .post("https://www.facebook.com/message_share_attachment/fromURI/", ctx.jar, form)
79
+ .post(
80
+ "https://www.facebook.com/message_share_attachment/fromURI/",
81
+ ctx.jar,
82
+ form
83
+ )
72
84
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
73
85
  .then(function (resData) {
74
- if (resData.error) return callback(resData);
75
- if (!resData.payload) return callback({ error: "Invalid url" });
86
+ if (resData.error) {
87
+ return callback(resData);
88
+ }
89
+
90
+ if (!resData.payload) {
91
+ return callback({ error: "Invalid url" });
92
+ }
93
+
76
94
  callback(null, resData.payload.share_data.share_params);
77
95
  })
78
96
  .catch(function (err) {
@@ -88,20 +106,22 @@ module.exports = function (defaultFuncs, api, ctx) {
88
106
  // 2. User is sending a message to a specific user.
89
107
  // 3. No additional form params and the message goes to an existing group chat.
90
108
  if (utils.getType(threadID) === "Array") {
91
- for (var i = 0; i < threadID.length; i++) form["specific_to_list[" + i + "]"] = "fbid:" + threadID[i];
109
+ for (var i = 0; i < threadID.length; i++) {
110
+ form["specific_to_list[" + i + "]"] = "fbid:" + threadID[i];
111
+ }
92
112
  form["specific_to_list[" + threadID.length + "]"] = "fbid:" + ctx.userID;
93
113
  form["client_thread_id"] = "root:" + messageAndOTID;
94
114
  log.info("sendMessage", "Sending message to multiple users: " + threadID);
95
- }
96
- else {
115
+ } else {
97
116
  // This means that threadID is the id of a user, and the chat
98
117
  // is a single person chat
99
118
  if (isSingleUser) {
100
119
  form["specific_to_list[0]"] = "fbid:" + threadID;
101
120
  form["specific_to_list[1]"] = "fbid:" + ctx.userID;
102
121
  form["other_user_fbid"] = threadID;
122
+ } else {
123
+ form["thread_fbid"] = threadID;
103
124
  }
104
- else form["thread_fbid"] = threadID;
105
125
  }
106
126
 
107
127
  if (ctx.globalOptions.pageID) {
@@ -112,31 +132,26 @@ module.exports = function (defaultFuncs, api, ctx) {
112
132
  form["creator_info[labelType]"] = "sent_message";
113
133
  form["creator_info[pageID]"] = ctx.globalOptions.pageID;
114
134
  form["request_user_id"] = ctx.globalOptions.pageID;
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) {}
135
+ form["creator_info[profileURI]"] =
136
+ "https://www.facebook.com/profile.php?id=" + ctx.userID;
130
137
  }
131
138
 
132
139
  defaultFuncs
133
140
  .post("https://www.facebook.com/messaging/send/", ctx.jar, form)
134
141
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
135
142
  .then(function (resData) {
136
- Location_Stack = undefined;
137
- if (!resData) return callback({ error: "Send message failed." });
143
+ if (!resData) {
144
+ return callback({ error: "Send message failed." });
145
+ }
146
+
138
147
  if (resData.error) {
139
- if (resData.error === 1545012) log.warn("sendMessage", "Got error 1545012. This might mean that you're not part of the conversation " + threadID);
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
+ }
140
155
  return callback(resData);
141
156
  }
142
157
 
@@ -149,68 +164,87 @@ module.exports = function (defaultFuncs, api, ctx) {
149
164
  } || p
150
165
  );
151
166
  }, null);
167
+
152
168
  return callback(null, messageInfo);
153
169
  })
154
170
  .catch(function (err) {
155
171
  log.error("sendMessage", err);
156
- if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
157
- return callback(err,null);
172
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.") {
173
+ ctx.loggedIn = false;
174
+ }
175
+ return callback(err);
158
176
  });
159
- }
177
+ }
160
178
 
161
179
  function send(form, threadID, messageAndOTID, callback, isGroup) {
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
- }
177
- }
180
+ // We're doing a query to this to check if the given id is the id of
181
+ // a user or of a group chat. The form will be different depending
182
+ // on that.
183
+ if (utils.getType(threadID) === "Array") {
184
+ sendContent(form, threadID, false, messageAndOTID, callback);
185
+ } else {
186
+ if (utils.getType(isGroup) != "Boolean")
187
+ sendContent(form, threadID, threadID.length <= 15, messageAndOTID, callback);
188
+ else
189
+ sendContent(form, threadID, !isGroup, messageAndOTID, callback);
178
190
  }
179
191
  }
180
-
192
+
181
193
  function handleUrl(msg, form, callback, cb) {
182
194
  if (msg.url) {
183
195
  form["shareable_attachment[share_type]"] = "100";
184
196
  getUrl(msg.url, function (err, params) {
185
- if (err) return callback(err);
197
+ if (err) {
198
+ return callback(err);
199
+ }
200
+
186
201
  form["shareable_attachment[share_params]"] = params;
187
202
  cb();
188
203
  });
204
+ } else {
205
+ cb();
189
206
  }
190
- else cb();
191
207
  }
192
208
 
193
209
  function handleLocation(msg, form, callback, cb) {
194
210
  if (msg.location) {
195
- if (msg.location.latitude == null || msg.location.longitude == null) return callback({ error: "location property needs both latitude and longitude" });
211
+ if (msg.location.latitude == null || msg.location.longitude == null) {
212
+ return callback({ error: "location property needs both latitude and longitude" });
213
+ }
214
+
196
215
  form["location_attachment[coordinates][latitude]"] = msg.location.latitude;
197
216
  form["location_attachment[coordinates][longitude]"] = msg.location.longitude;
198
217
  form["location_attachment[is_current_location]"] = !!msg.location.current;
199
218
  }
219
+
200
220
  cb();
201
221
  }
202
222
 
203
223
  function handleSticker(msg, form, callback, cb) {
204
- if (msg.sticker) form["sticker_id"] = msg.sticker;
224
+ if (msg.sticker) {
225
+ form["sticker_id"] = msg.sticker;
226
+ }
205
227
  cb();
206
228
  }
207
229
 
208
230
  function handleEmoji(msg, form, callback, cb) {
209
- if (msg.emojiSize != null && msg.emoji == null) return callback({ error: "emoji property is empty" });
231
+ if (msg.emojiSize != null && msg.emoji == null) {
232
+ return callback({ error: "emoji property is empty" });
233
+ }
210
234
  if (msg.emoji) {
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" });
235
+ if (msg.emojiSize == null) {
236
+ msg.emojiSize = "medium";
237
+ }
238
+ if (
239
+ msg.emojiSize != "small" &&
240
+ msg.emojiSize != "medium" &&
241
+ msg.emojiSize != "large"
242
+ ) {
243
+ return callback({ error: "emojiSize property is invalid" });
244
+ }
245
+ if (form["body"] != null && form["body"] != "") {
246
+ return callback({ error: "body is not empty" });
247
+ }
214
248
  form["body"] = msg.emoji;
215
249
  form["tags[0]"] = "hot_emoji_size:" + msg.emojiSize;
216
250
  }
@@ -225,43 +259,15 @@ module.exports = function (defaultFuncs, api, ctx) {
225
259
  form["video_ids"] = [];
226
260
  form["audio_ids"] = [];
227
261
 
228
- if (utils.getType(msg.attachment) !== "Array") msg.attachment = [msg.attachment];
229
-
230
- const isValidAttachment = attachment => /_id$/.test(attachment[0]);
231
-
232
- if (msg.attachment.every(isValidAttachment)) {
233
- msg.attachment.forEach(attachment => form[`${attachment[0]}s`].push(attachment[1]));
234
- return cb();
262
+ if (utils.getType(msg.attachment) !== "Array") {
263
+ msg.attachment = [msg.attachment];
235
264
  }
236
265
 
237
- if (global.Fca.Require.FastConfig.AntiSendAppState) {
238
- try {
239
- const AllowList = [".png", ".mp3", ".mp4", ".wav", ".gif", ".jpg", ".tff"];
240
- const CheckList = [".json", ".js", ".txt", ".docx", '.php'];
241
- var Has;
242
- for (let i = 0; i < (msg.attachment).length; i++) {
243
- if (utils.isReadableStream((msg.attachment)[i])) {
244
- var path = (msg.attachment)[i].path != undefined ? (msg.attachment)[i].path : "nonpath";
245
- if (AllowList.some(i => path.includes(i))) continue;
246
- else if (CheckList.some(i => path.includes(i))) {
247
- let data = fs.readFileSync(path, 'utf-8');
248
- if (data.includes("datr")) {
249
- Has = true;
250
- var err = new Error();
251
- Location_Stack = err.stack;
252
- }
253
- else continue;
254
- }
255
- }
256
- }
257
- if (Has == true) {
258
- msg.attachment = [fs.createReadStream(__dirname + "/../Extra/Src/Image/checkmate.jpg")];
259
- }
260
- }
261
- catch (e) {}
262
- }
263
266
  uploadAttachment(msg.attachment, function (err, files) {
264
- if (err) return callback(err);
267
+ if (err) {
268
+ return callback(err);
269
+ }
270
+
265
271
  files.forEach(function (file) {
266
272
  var key = Object.keys(file);
267
273
  var type = key[0]; // image_id, file_id, etc
@@ -269,19 +275,33 @@ module.exports = function (defaultFuncs, api, ctx) {
269
275
  });
270
276
  cb();
271
277
  });
278
+ } else {
279
+ cb();
272
280
  }
273
- else cb();
274
281
  }
275
282
 
276
283
  function handleMention(msg, form, callback, cb) {
277
284
  if (msg.mentions) {
278
285
  for (let i = 0; i < msg.mentions.length; i++) {
279
286
  const mention = msg.mentions[i];
287
+
280
288
  const tag = mention.tag;
281
- if (typeof tag !== "string") return callback({ error: "Mention tags must be strings." });
289
+ if (typeof tag !== "string") {
290
+ return callback({ error: "Mention tags must be strings." });
291
+ }
292
+
282
293
  const offset = msg.body.indexOf(tag, mention.fromIndex || 0);
283
- if (offset < 0) log.warn("handleMention", 'Mention for "' + tag + '" not found in message string.');
284
- if (mention.id == null) log.warn("handleMention", "Mention id should be non-null.");
294
+
295
+ if (offset < 0) {
296
+ log.warn(
297
+ "handleMention",
298
+ 'Mention for "' + tag + '" not found in message string.'
299
+ );
300
+ }
301
+
302
+ if (mention.id == null) {
303
+ log.warn("handleMention", "Mention id should be non-null.");
304
+ }
285
305
 
286
306
  const id = mention.id || 0;
287
307
  const emptyChar = '\u200E';
@@ -297,10 +317,19 @@ module.exports = function (defaultFuncs, api, ctx) {
297
317
 
298
318
  return function sendMessage(msg, threadID, callback, replyToMessage, isGroup) {
299
319
  typeof isGroup == "undefined" ? isGroup = null : "";
300
- if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) return threadID({ error: "Pass a threadID as a second argument." });
301
- if (!replyToMessage && utils.getType(callback) === "String") {
320
+ if (
321
+ !callback &&
322
+ (utils.getType(threadID) === "Function" ||
323
+ utils.getType(threadID) === "AsyncFunction")
324
+ ) {
325
+ return threadID({ error: "Pass a threadID as a second argument." });
326
+ }
327
+ if (
328
+ !replyToMessage &&
329
+ utils.getType(callback) === "String"
330
+ ) {
302
331
  replyToMessage = callback;
303
- callback = function () { };
332
+ callback = undefined;
304
333
  }
305
334
 
306
335
  var resolveFunc = function () { };
@@ -321,16 +350,48 @@ module.exports = function (defaultFuncs, api, ctx) {
321
350
  var threadIDType = utils.getType(threadID);
322
351
  var messageIDType = utils.getType(replyToMessage);
323
352
 
324
- if (msgType !== "String" && msgType !== "Object") return callback({ error: "Message should be of type string or object and not " + msgType + "." });
353
+ if (msgType !== "String" && msgType !== "Object") {
354
+ return callback({
355
+ error:
356
+ "Message should be of type string or object and not " + msgType + "."
357
+ });
358
+ }
325
359
 
326
360
  // Changing this to accomodate an array of users
327
- if (threadIDType !== "Array" && threadIDType !== "Number" && threadIDType !== "String") return callback({ error: "ThreadID should be of type number, string, or array and not " + threadIDType + "." });
361
+ if (
362
+ threadIDType !== "Array" &&
363
+ threadIDType !== "Number" &&
364
+ threadIDType !== "String"
365
+ ) {
366
+ return callback({
367
+ error:
368
+ "ThreadID should be of type number, string, or array and not " +
369
+ threadIDType +
370
+ "."
371
+ });
372
+ }
328
373
 
329
- if (replyToMessage && messageIDType !== 'String') return callback({ error: "MessageID should be of type string and not " + threadIDType + "." });
374
+ if (replyToMessage && messageIDType !== 'String') {
375
+ return callback({
376
+ error:
377
+ "MessageID should be of type string and not " +
378
+ threadIDType +
379
+ "."
380
+ });
381
+ }
330
382
 
331
- if (msgType === "String") msg = { body: msg };
332
- var disallowedProperties = Object.keys(msg).filter(prop => !allowedProperties[prop]);
333
- if (disallowedProperties.length > 0) return callback({ error: "Dissallowed props: `" + disallowedProperties.join(", ") + "`" });
383
+ if (msgType === "String") {
384
+ msg = { body: msg };
385
+ }
386
+
387
+ var disallowedProperties = Object.keys(msg).filter(
388
+ prop => !allowedProperties[prop]
389
+ );
390
+ if (disallowedProperties.length > 0) {
391
+ return callback({
392
+ error: "Dissallowed props: `" + disallowedProperties.join(", ") + "`"
393
+ });
394
+ }
334
395
 
335
396
  var messageAndOTID = utils.generateOfflineThreadingID();
336
397
 
@@ -353,7 +414,7 @@ module.exports = function (defaultFuncs, api, ctx) {
353
414
  is_spoof_warning: false,
354
415
  source: "source:chat:web",
355
416
  "source_tags[0]": "source:chat",
356
- 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",' ') : "",
417
+ body: msg.body ? msg.body.toString() : "",
357
418
  html_body: false,
358
419
  ui_push_phase: "V3",
359
420
  status: "0",
@@ -366,7 +427,7 @@ module.exports = function (defaultFuncs, api, ctx) {
366
427
  signatureID: utils.getSignatureID(),
367
428
  replied_to_message_id: replyToMessage
368
429
  };
369
-
430
+
370
431
  handleLocation(msg, form, callback, () =>
371
432
  handleSticker(msg, form, callback, () =>
372
433
  handleAttachment(msg, form, callback, () =>
@@ -383,4 +444,4 @@ module.exports = function (defaultFuncs, api, ctx) {
383
444
 
384
445
  return returnPromise;
385
446
  };
386
- };
447
+ };