node-ainzfb-new 1.6.32-stable → 1.6.2210-test

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