node-ainzfb-new 1.6.2902-test → 1.6.2909-test

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. package/package.json +7 -7
  2. package/src/addExternalModule.js +13 -6
  3. package/src/addUserToGroup.js +35 -12
  4. package/src/changeAdminStatus.js +32 -16
  5. package/src/changeArchivedStatus.js +15 -9
  6. package/src/changeAvt.js +75 -69
  7. package/src/changeBio.js +12 -8
  8. package/src/changeBlockedStatus.js +14 -8
  9. package/src/changeGroupImage.js +27 -13
  10. package/src/changeNickname.js +19 -10
  11. package/src/changeThreadColor.js +15 -10
  12. package/src/changeThreadEmoji.js +17 -9
  13. package/src/createNewGroup.js +18 -10
  14. package/src/createPoll.js +16 -11
  15. package/src/deleteMessage.js +16 -10
  16. package/src/deleteThread.js +16 -10
  17. package/src/forwardAttachment.js +14 -9
  18. package/src/getAccessToken.js +21 -21
  19. package/src/getCurrentUserID.js +1 -1
  20. package/src/getEmojiUrl.js +3 -2
  21. package/src/getFriendsList.js +18 -10
  22. package/src/getMessage.js +52 -48
  23. package/src/getThreadHistory.js +156 -59
  24. package/src/getThreadHistoryDeprecated.js +26 -15
  25. package/src/getThreadInfo.js +3423 -18
  26. package/src/getThreadInfoDeprecated.js +25 -13
  27. package/src/getThreadList.js +112 -53
  28. package/src/getThreadListDeprecated.js +30 -12
  29. package/src/getThreadPictures.js +25 -13
  30. package/src/getUserID.js +7 -7
  31. package/src/getUserInfo.js +12 -9
  32. package/src/getUserInfoV2.js +19 -22
  33. package/src/handleFriendRequest.js +10 -9
  34. package/src/handleMessageRequest.js +16 -10
  35. package/src/httpGet.js +18 -13
  36. package/src/httpPost.js +18 -13
  37. package/src/httpPostFormData.js +14 -9
  38. package/src/listenMqtt.js +1218 -571
  39. package/src/logout.js +18 -13
  40. package/src/markAsDelivered.js +16 -10
  41. package/src/markAsRead.js +36 -24
  42. package/src/markAsReadAll.js +14 -10
  43. package/src/markAsSeen.js +18 -11
  44. package/src/muteThread.js +12 -8
  45. package/src/removeUserFromGroup.js +33 -10
  46. package/src/resolvePhotoUrl.js +8 -6
  47. package/src/searchForThread.js +13 -8
  48. package/src/sendMessage.js +172 -78
  49. package/src/sendTypingIndicator.js +29 -14
  50. package/src/setMessageReaction.js +13 -8
  51. package/src/setPostReaction.js +97 -95
  52. package/src/setTitle.js +18 -12
  53. package/src/threadColors.js +17 -17
  54. package/src/unfriend.js +14 -9
  55. package/src/unsendMessage.js +7 -7
  56. package/utils.js +2273 -1066
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * Được Fix Hay Làm Màu Bởi: @KanzuWakazaki
5
5
  * 19/2/2022
6
- */
6
+ */
7
7
 
8
8
  var utils = require("../utils");
9
9
  var log = require("npmlog");
@@ -17,16 +17,22 @@ var allowedProperties = {
17
17
  emojiSize: true,
18
18
  body: true,
19
19
  mentions: true,
20
- location: true,
20
+ location: true
21
21
  };
22
22
 
23
- module.exports = function (defaultFuncs, api, ctx) {
23
+ module.exports = function(defaultFuncs, api, ctx) {
24
24
  function uploadAttachment(attachments, callback) {
25
25
  var uploads = [];
26
26
 
27
27
  // create an array of promises
28
28
  for (var i = 0; i < attachments.length; i++) {
29
- if (!utils.isReadableStream(attachments[i])) throw { error: "Attachment should be a readable stream and not " + utils.getType(attachments[i]) + "." };
29
+ if (!utils.isReadableStream(attachments[i]))
30
+ throw {
31
+ error:
32
+ "Attachment should be a readable stream and not " +
33
+ utils.getType(attachments[i]) +
34
+ "."
35
+ };
30
36
  var form = {
31
37
  upload_1024: attachments[i],
32
38
  voice_clip: "true"
@@ -34,9 +40,14 @@ module.exports = function (defaultFuncs, api, ctx) {
34
40
 
35
41
  uploads.push(
36
42
  defaultFuncs
37
- .postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
43
+ .postFormData(
44
+ "https://upload.facebook.com/ajax/mercury/upload.php",
45
+ ctx.jar,
46
+ form,
47
+ {}
48
+ )
38
49
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
39
- .then(function (resData) {
50
+ .then(function(resData) {
40
51
  if (resData.error) throw resData;
41
52
  // We have to return the data unformatted unless we want to change it
42
53
  // back in sendMessage.
@@ -48,9 +59,8 @@ module.exports = function (defaultFuncs, api, ctx) {
48
59
  // resolve all promises
49
60
  bluebird
50
61
  .all(uploads)
51
- .then(resData => callback(null, resData)
52
- )
53
- .catch(function (err) {
62
+ .then(resData => callback(null, resData))
63
+ .catch(function(err) {
54
64
  log.error("uploadAttachment", err);
55
65
  return callback(err);
56
66
  });
@@ -64,14 +74,18 @@ module.exports = function (defaultFuncs, api, ctx) {
64
74
  };
65
75
 
66
76
  defaultFuncs
67
- .post("https://www.facebook.com/message_share_attachment/fromURI/", ctx.jar, form)
77
+ .post(
78
+ "https://www.facebook.com/message_share_attachment/fromURI/",
79
+ ctx.jar,
80
+ form
81
+ )
68
82
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
69
- .then(function (resData) {
83
+ .then(function(resData) {
70
84
  if (resData.error) return callback(resData);
71
85
  if (!resData.payload) return callback({ error: "Invalid url" });
72
86
  callback(null, resData.payload.share_data.share_params);
73
87
  })
74
- .catch(function (err) {
88
+ .catch(function(err) {
75
89
  log.error("getUrl", err);
76
90
  return callback(err);
77
91
  });
@@ -84,20 +98,19 @@ module.exports = function (defaultFuncs, api, ctx) {
84
98
  // 2. User is sending a message to a specific user.
85
99
  // 3. No additional form params and the message goes to an existing group chat.
86
100
  if (utils.getType(threadID) === "Array") {
87
- for (var i = 0; i < threadID.length; i++) form["specific_to_list[" + i + "]"] = "fbid:" + threadID[i];
101
+ for (var i = 0; i < threadID.length; i++)
102
+ form["specific_to_list[" + i + "]"] = "fbid:" + threadID[i];
88
103
  form["specific_to_list[" + threadID.length + "]"] = "fbid:" + ctx.userID;
89
104
  form["client_thread_id"] = "root:" + messageAndOTID;
90
105
  log.info("sendMessage", "Sending message to multiple users: " + threadID);
91
- }
92
- else {
106
+ } else {
93
107
  // This means that threadID is the id of a user, and the chat
94
108
  // is a single person chat
95
109
  if (isSingleUser) {
96
110
  form["specific_to_list[0]"] = "fbid:" + threadID;
97
111
  form["specific_to_list[1]"] = "fbid:" + ctx.userID;
98
112
  form["other_user_fbid"] = threadID;
99
- }
100
- else form["thread_fbid"] = threadID;
113
+ } else form["thread_fbid"] = threadID;
101
114
  }
102
115
 
103
116
  if (ctx.globalOptions.pageID) {
@@ -108,20 +121,26 @@ module.exports = function (defaultFuncs, api, ctx) {
108
121
  form["creator_info[labelType]"] = "sent_message";
109
122
  form["creator_info[pageID]"] = ctx.globalOptions.pageID;
110
123
  form["request_user_id"] = ctx.globalOptions.pageID;
111
- form["creator_info[profileURI]"] = "https://www.facebook.com/profile.php?id=" + ctx.userID;
124
+ form["creator_info[profileURI]"] =
125
+ "https://www.facebook.com/profile.php?id=" + ctx.userID;
112
126
  }
113
127
 
114
128
  defaultFuncs
115
129
  .post("https://www.facebook.com/messaging/send/", ctx.jar, form)
116
130
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
117
- .then(function (resData) {
131
+ .then(function(resData) {
118
132
  if (!resData) return callback({ error: "Send message failed." });
119
133
  if (resData.error) {
120
- if (resData.error === 1545012) log.warn("sendMessage", "Got error 1545012. This might mean that you're not part of the conversation " + threadID);
134
+ if (resData.error === 1545012)
135
+ log.warn(
136
+ "sendMessage",
137
+ "Got error 1545012. This might mean that you're not part of the conversation " +
138
+ threadID
139
+ );
121
140
  return callback(resData);
122
141
  }
123
142
 
124
- var messageInfo = resData.payload.actions.reduce(function (p, v) {
143
+ var messageInfo = resData.payload.actions.reduce(function(p, v) {
125
144
  return (
126
145
  {
127
146
  threadID: v.thread_fbid,
@@ -132,58 +151,86 @@ module.exports = function (defaultFuncs, api, ctx) {
132
151
  }, null);
133
152
  return callback(null, messageInfo);
134
153
  })
135
- .catch(function (err) {
154
+ .catch(function(err) {
136
155
  log.error("sendMessage", err);
137
- if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
156
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.")
157
+ ctx.loggedIn = false;
138
158
  return callback(err);
139
159
  });
140
- }
160
+ }
141
161
 
142
162
  function send(form, threadID, messageAndOTID, callback, isGroup) {
143
- // đôi lời từ ai đó :v
144
- // cái này chỉ fix send ko được tin nhắn thôi chứ i cũng đôn nâu cách fix lắm nên là có gì ae fix giùm nha kkk
145
- if (utils.getType(threadID) === "Array") sendContent(form, threadID, false, messageAndOTID, callback);
163
+ // đôi lời từ ai đó :v
164
+ // cái này chỉ fix send ko được tin nhắn thôi chứ i cũng đôn nâu cách fix lắm nên là có gì ae fix giùm nha kkk
165
+ if (utils.getType(threadID) === "Array")
166
+ sendContent(form, threadID, false, messageAndOTID, callback);
146
167
  else {
147
- var THREADFIX = "ThreadID".replace("ThreadID",threadID); // i cũng đôn nâu
148
- if (THREADFIX.length <= 15 || global.isUser.includes(threadID)) sendContent(form, threadID, !isGroup, messageAndOTID, callback);
149
- else if (THREADFIX.length >= 15 && THREADFIX.indexOf(1) != 0 || global.isThread.includes(threadID)) sendContent(form, threadID, threadID.length === 15, messageAndOTID, callback);
150
- else {
151
- try {
152
- var { getInfo } = require('../Extra/ExtraAddons');
153
- getInfo(threadID)
154
- .then(_ => {
155
- global.isUser.push(threadID);
156
- sendContent(form, threadID, !isGroup, messageAndOTID, callback)
157
- })
158
- .catch(function(_) {
159
- global.isThread.push(threadID)
160
- sendContent(form, threadID, threadID.length === 15, messageAndOTID, callback);
161
- })
162
- }
163
- catch (e) {
164
- sendContent(form, threadID, threadID.length === 15, messageAndOTID, callback)
168
+ var THREADFIX = "ThreadID".replace("ThreadID", threadID); // i cũng đôn nâu
169
+ if (THREADFIX.length <= 15 || global.isUser.includes(threadID))
170
+ sendContent(form, threadID, !isGroup, messageAndOTID, callback);
171
+ else if (
172
+ (THREADFIX.length >= 15 && THREADFIX.indexOf(1) != 0) ||
173
+ global.isThread.includes(threadID)
174
+ )
175
+ sendContent(
176
+ form,
177
+ threadID,
178
+ threadID.length === 15,
179
+ messageAndOTID,
180
+ callback
181
+ );
182
+ else {
183
+ try {
184
+ var { getInfo } = require("../Extra/ExtraAddons");
185
+ getInfo(threadID)
186
+ .then(_ => {
187
+ global.isUser.push(threadID);
188
+ sendContent(form, threadID, !isGroup, messageAndOTID, callback);
189
+ })
190
+ .catch(function(_) {
191
+ global.isThread.push(threadID);
192
+ sendContent(
193
+ form,
194
+ threadID,
195
+ threadID.length === 15,
196
+ messageAndOTID,
197
+ callback
198
+ );
199
+ });
200
+ } catch (e) {
201
+ sendContent(
202
+ form,
203
+ threadID,
204
+ threadID.length === 15,
205
+ messageAndOTID,
206
+ callback
207
+ );
165
208
  }
166
209
  }
167
210
  }
168
211
  }
169
-
212
+
170
213
  function handleUrl(msg, form, callback, cb) {
171
214
  if (msg.url) {
172
215
  form["shareable_attachment[share_type]"] = "100";
173
- getUrl(msg.url, function (err, params) {
216
+ getUrl(msg.url, function(err, params) {
174
217
  if (err) return callback(err);
175
218
  form["shareable_attachment[share_params]"] = params;
176
219
  cb();
177
220
  });
178
- }
179
- else cb();
221
+ } else cb();
180
222
  }
181
223
 
182
224
  function handleLocation(msg, form, callback, cb) {
183
225
  if (msg.location) {
184
- if (msg.location.latitude == null || msg.location.longitude == null) return callback({ error: "location property needs both latitude and longitude" });
185
- form["location_attachment[coordinates][latitude]"] = msg.location.latitude;
186
- form["location_attachment[coordinates][longitude]"] = msg.location.longitude;
226
+ if (msg.location.latitude == null || msg.location.longitude == null)
227
+ return callback({
228
+ error: "location property needs both latitude and longitude"
229
+ });
230
+ form["location_attachment[coordinates][latitude]"] =
231
+ msg.location.latitude;
232
+ form["location_attachment[coordinates][longitude]"] =
233
+ msg.location.longitude;
187
234
  form["location_attachment[is_current_location]"] = !!msg.location.current;
188
235
  }
189
236
  cb();
@@ -195,11 +242,18 @@ module.exports = function (defaultFuncs, api, ctx) {
195
242
  }
196
243
 
197
244
  function handleEmoji(msg, form, callback, cb) {
198
- if (msg.emojiSize != null && msg.emoji == null) return callback({ error: "emoji property is empty" });
245
+ if (msg.emojiSize != null && msg.emoji == null)
246
+ return callback({ error: "emoji property is empty" });
199
247
  if (msg.emoji) {
200
248
  if (msg.emojiSize == null) msg.emojiSize = "medium";
201
- if (msg.emojiSize != "small" && msg.emojiSize != "medium" && msg.emojiSize != "large") return callback({ error: "emojiSize property is invalid" });
202
- if (form["body"] != null && form["body"] != "") return callback({ error: "body is not empty" });
249
+ if (
250
+ msg.emojiSize != "small" &&
251
+ msg.emojiSize != "medium" &&
252
+ msg.emojiSize != "large"
253
+ )
254
+ return callback({ error: "emojiSize property is invalid" });
255
+ if (form["body"] != null && form["body"] != "")
256
+ return callback({ error: "body is not empty" });
203
257
  form["body"] = msg.emoji;
204
258
  form["tags[0]"] = "hot_emoji_size:" + msg.emojiSize;
205
259
  }
@@ -214,19 +268,19 @@ module.exports = function (defaultFuncs, api, ctx) {
214
268
  form["video_ids"] = [];
215
269
  form["audio_ids"] = [];
216
270
 
217
- if (utils.getType(msg.attachment) !== "Array") msg.attachment = [msg.attachment];
271
+ if (utils.getType(msg.attachment) !== "Array")
272
+ msg.attachment = [msg.attachment];
218
273
 
219
- uploadAttachment(msg.attachment, function (err, files) {
274
+ uploadAttachment(msg.attachment, function(err, files) {
220
275
  if (err) return callback(err);
221
- files.forEach(function (file) {
276
+ files.forEach(function(file) {
222
277
  var key = Object.keys(file);
223
278
  var type = key[0]; // image_id, file_id, etc
224
279
  form["" + type + "s"].push(file[type]); // push the id
225
280
  });
226
281
  cb();
227
282
  });
228
- }
229
- else cb();
283
+ } else cb();
230
284
  }
231
285
 
232
286
  function handleMention(msg, form, callback, cb) {
@@ -234,13 +288,19 @@ module.exports = function (defaultFuncs, api, ctx) {
234
288
  for (let i = 0; i < msg.mentions.length; i++) {
235
289
  const mention = msg.mentions[i];
236
290
  const tag = mention.tag;
237
- if (typeof tag !== "string") return callback({ error: "Mention tags must be strings." });
291
+ if (typeof tag !== "string")
292
+ return callback({ error: "Mention tags must be strings." });
238
293
  const offset = msg.body.indexOf(tag, mention.fromIndex || 0);
239
- if (offset < 0) log.warn("handleMention", 'Mention for "' + tag + '" not found in message string.');
240
- if (mention.id == null) log.warn("handleMention", "Mention id should be non-null.");
294
+ if (offset < 0)
295
+ log.warn(
296
+ "handleMention",
297
+ 'Mention for "' + tag + '" not found in message string.'
298
+ );
299
+ if (mention.id == null)
300
+ log.warn("handleMention", "Mention id should be non-null.");
241
301
 
242
302
  const id = mention.id || 0;
243
- const emptyChar = '\u200E';
303
+ const emptyChar = "\u200E";
244
304
  form["body"] = emptyChar + msg.body;
245
305
  form["profile_xmd[" + i + "][offset]"] = offset + 1;
246
306
  form["profile_xmd[" + i + "][length]"] = tag.length;
@@ -251,23 +311,34 @@ module.exports = function (defaultFuncs, api, ctx) {
251
311
  cb();
252
312
  }
253
313
 
254
- return function sendMessage(msg, threadID, callback, replyToMessage, isGroup) {
255
- typeof isGroup == "undefined" ? isGroup = null : "";
256
- if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) return threadID({ error: "Pass a threadID as a second argument." });
314
+ return function sendMessage(
315
+ msg,
316
+ threadID,
317
+ callback,
318
+ replyToMessage,
319
+ isGroup
320
+ ) {
321
+ typeof isGroup == "undefined" ? (isGroup = null) : "";
322
+ if (
323
+ !callback &&
324
+ (utils.getType(threadID) === "Function" ||
325
+ utils.getType(threadID) === "AsyncFunction")
326
+ )
327
+ return threadID({ error: "Pass a threadID as a second argument." });
257
328
  if (!replyToMessage && utils.getType(callback) === "String") {
258
329
  replyToMessage = callback;
259
- callback = function () { };
330
+ callback = function() {};
260
331
  }
261
332
 
262
- var resolveFunc = function () { };
263
- var rejectFunc = function () { };
264
- var returnPromise = new Promise(function (resolve, reject) {
333
+ var resolveFunc = function() {};
334
+ var rejectFunc = function() {};
335
+ var returnPromise = new Promise(function(resolve, reject) {
265
336
  resolveFunc = resolve;
266
337
  rejectFunc = reject;
267
338
  });
268
339
 
269
340
  if (!callback) {
270
- callback = function (err, data) {
341
+ callback = function(err, data) {
271
342
  if (err) return rejectFunc(err);
272
343
  resolveFunc(data);
273
344
  };
@@ -277,16 +348,39 @@ module.exports = function (defaultFuncs, api, ctx) {
277
348
  var threadIDType = utils.getType(threadID);
278
349
  var messageIDType = utils.getType(replyToMessage);
279
350
 
280
- if (msgType !== "String" && msgType !== "Object") return callback({ error: "Message should be of type string or object and not " + msgType + "." });
351
+ if (msgType !== "String" && msgType !== "Object")
352
+ return callback({
353
+ error:
354
+ "Message should be of type string or object and not " + msgType + "."
355
+ });
281
356
 
282
357
  // Changing this to accomodate an array of users
283
- if (threadIDType !== "Array" && threadIDType !== "Number" && threadIDType !== "String") return callback({ error: "ThreadID should be of type number, string, or array and not " + threadIDType + "." });
358
+ if (
359
+ threadIDType !== "Array" &&
360
+ threadIDType !== "Number" &&
361
+ threadIDType !== "String"
362
+ )
363
+ return callback({
364
+ error:
365
+ "ThreadID should be of type number, string, or array and not " +
366
+ threadIDType +
367
+ "."
368
+ });
284
369
 
285
- if (replyToMessage && messageIDType !== 'String') return callback({ error: "MessageID should be of type string and not " + threadIDType + "." });
370
+ if (replyToMessage && messageIDType !== "String")
371
+ return callback({
372
+ error:
373
+ "MessageID should be of type string and not " + threadIDType + "."
374
+ });
286
375
 
287
376
  if (msgType === "String") msg = { body: msg };
288
- var disallowedProperties = Object.keys(msg).filter(prop => !allowedProperties[prop]);
289
- if (disallowedProperties.length > 0) return callback({ error: "Dissallowed props: `" + disallowedProperties.join(", ") + "`" });
377
+ var disallowedProperties = Object.keys(msg).filter(
378
+ prop => !allowedProperties[prop]
379
+ );
380
+ if (disallowedProperties.length > 0)
381
+ return callback({
382
+ error: "Dissallowed props: `" + disallowedProperties.join(", ") + "`"
383
+ });
290
384
 
291
385
  var messageAndOTID = utils.generateOfflineThreadingID();
292
386
 
@@ -322,7 +416,7 @@ module.exports = function (defaultFuncs, api, ctx) {
322
416
  signatureID: utils.getSignatureID(),
323
417
  replied_to_message_id: replyToMessage
324
418
  };
325
-
419
+
326
420
  handleLocation(msg, form, callback, () =>
327
421
  handleSticker(msg, form, callback, () =>
328
422
  handleAttachment(msg, form, callback, () =>
@@ -3,7 +3,7 @@
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
  function makeTypingIndicator(typ, threadID, callback, isGroup) {
8
8
  var form = {
9
9
  typ: +typ,
@@ -21,33 +21,40 @@ module.exports = function (defaultFuncs, api, ctx) {
21
21
  defaultFuncs
22
22
  .post("https://www.facebook.com/ajax/messaging/typ.php", ctx.jar, form)
23
23
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
24
- .then(function (resData) {
24
+ .then(function(resData) {
25
25
  if (resData.error) throw resData;
26
26
  return callback();
27
27
  })
28
- .catch(function (err) {
28
+ .catch(function(err) {
29
29
  log.error("sendTypingIndicator", err);
30
30
  if (utils.getType(err) == "Object" && err.error === "Not logged in") {
31
31
  ctx.loggedIn = false;
32
32
  }
33
33
  return callback(err);
34
34
  });
35
- }
36
- else {
37
- api.getUserInfo(threadID, function (err, res) {
35
+ } else {
36
+ api.getUserInfo(threadID, function(err, res) {
38
37
  if (err) return callback(err);
39
38
  // If id is single person chat
40
39
  if (Object.keys(res).length > 0) form.to = threadID;
41
40
  defaultFuncs
42
- .post("https://www.facebook.com/ajax/messaging/typ.php", ctx.jar, form)
41
+ .post(
42
+ "https://www.facebook.com/ajax/messaging/typ.php",
43
+ ctx.jar,
44
+ form
45
+ )
43
46
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
44
- .then(function (resData) {
47
+ .then(function(resData) {
45
48
  if (resData.error) throw resData;
46
49
  return callback();
47
50
  })
48
- .catch(function (err) {
51
+ .catch(function(err) {
49
52
  log.error("sendTypingIndicator", err);
50
- if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
53
+ if (
54
+ utils.getType(err) == "Object" &&
55
+ err.error === "Not logged in."
56
+ )
57
+ ctx.loggedIn = false;
51
58
  return callback(err);
52
59
  });
53
60
  });
@@ -59,8 +66,12 @@ module.exports = function (defaultFuncs, api, ctx) {
59
66
  utils.getType(callback) !== "Function" &&
60
67
  utils.getType(callback) !== "AsyncFunction"
61
68
  ) {
62
- if (callback) log.warn("sendTypingIndicator", "callback is not a function - ignoring.");
63
- callback = () => { };
69
+ if (callback)
70
+ log.warn(
71
+ "sendTypingIndicator",
72
+ "callback is not a function - ignoring."
73
+ );
74
+ callback = () => {};
64
75
  }
65
76
 
66
77
  makeTypingIndicator(true, threadID, callback, isGroup);
@@ -70,8 +81,12 @@ module.exports = function (defaultFuncs, api, ctx) {
70
81
  utils.getType(cb) !== "Function" &&
71
82
  utils.getType(cb) !== "AsyncFunction"
72
83
  ) {
73
- if (cb) log.warn("sendTypingIndicator", "callback is not a function - ignoring.");
74
- cb = () => { };
84
+ if (cb)
85
+ log.warn(
86
+ "sendTypingIndicator",
87
+ "callback is not a function - ignoring."
88
+ );
89
+ cb = () => {};
75
90
  }
76
91
 
77
92
  makeTypingIndicator(false, threadID, cb, isGroup);
@@ -3,17 +3,22 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function setMessageReaction(reaction, messageID, callback, forceCustomReaction) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
+ return function setMessageReaction(
8
+ reaction,
9
+ messageID,
10
+ callback,
11
+ forceCustomReaction
12
+ ) {
13
+ var resolveFunc = function() {};
14
+ var rejectFunc = function() {};
15
+ var returnPromise = new Promise(function(resolve, reject) {
11
16
  resolveFunc = resolve;
12
17
  rejectFunc = reject;
13
18
  });
14
19
 
15
20
  if (!callback) {
16
- callback = function (err, data) {
21
+ callback = function(err, data) {
17
22
  if (err) return rejectFunc(err);
18
23
  resolveFunc(data);
19
24
  };
@@ -94,12 +99,12 @@ module.exports = function (defaultFuncs, api, ctx) {
94
99
  qs
95
100
  )
96
101
  .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
97
- .then(function (resData) {
102
+ .then(function(resData) {
98
103
  if (!resData) throw { error: "setReaction returned empty object." };
99
104
  if (resData.error) throw resData;
100
105
  callback(null);
101
106
  })
102
- .catch(function (err) {
107
+ .catch(function(err) {
103
108
  log.error("setReaction", err);
104
109
  return callback(err);
105
110
  });