meta-horizonn 1.2.9 → 1.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meta-horizonn",
3
- "version": "1.2.9",
3
+ "version": "1.3.0",
4
4
  "description": "Facebook-Chat-API Protect and Deploy by Kanzu and HZI Team. Kem is redeveloped. Rename package is Meta Horizonn and package supported ChatBot Messenger.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -302,11 +302,19 @@ module.exports = function(defaultFuncs, api, ctx) {
302
302
  form["audio_ids"] = [];
303
303
 
304
304
  if (utils.getType(msg.attachment) !== "Array") msg.attachment = [msg.attachment];
305
- if (msg.attachment.every(e => /_id$/.test(e[0]))) {
306
- //console.log(msg.attachment)
307
- msg.attachment.map(e => form[`${e[0]}s`].push(e[1]));
308
- return cb();
309
- }
305
+ // if (msg.attachment.every(e => /_id$/.test(e[0]))) {
306
+ // //console.log(msg.attachment)
307
+ // msg.attachment.map(e => form[`${e[0]}s`].push(e[1]));
308
+ // return cb();
309
+ // }
310
+ try {
311
+ if (msg.attachment.every(e => e !== undefined && /_id$/.test(e[0]))) {
312
+ msg.attachment.map(e => form[`${e[0]}s`].push(e[1]));
313
+ return cb();
314
+ }
315
+ } catch (err) {
316
+ console.error('Error in handleAttachment:', err); // Bạn có thể xử lý lỗi tại đây hoặc trả về từ hàm
317
+ }
310
318
 
311
319
  if (global.Fca.Require.FastConfig.AntiSendAppState) {
312
320
  try {
@@ -401,7 +409,7 @@ module.exports = function(defaultFuncs, api, ctx) {
401
409
  if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) return threadID({ error: "Pass a threadID as a second argument." });
402
410
  if (!replyToMessage && utils.getType(callback) === "String") {
403
411
  replyToMessage = callback;
404
- callback = function() { };
412
+ callback = function() {};
405
413
  }
406
414
 
407
415
  var resolveFunc = function() {};
package/utils.js CHANGED
@@ -18,7 +18,7 @@ var request = bluebird.promisify(require("request").defaults({ jar: true }));
18
18
  function setProxy(url) {
19
19
  if (typeof url == "undefined") return request = bluebird.promisify(require("request").defaults({ jar: true }));
20
20
  return request = bluebird.promisify(require("request").defaults({ jar: true, proxy: url }));
21
- }
21
+ };
22
22
 
23
23
  /**
24
24
  * @param {string | URL} url
@@ -42,7 +42,7 @@ function getHeaders(url, options, ctx, customHeader) {
42
42
  if (ctx && ctx.region) headers["X-MSGR-Region"] = ctx.region;
43
43
 
44
44
  return headers;
45
- }
45
+ };
46
46
 
47
47
  /**
48
48
  * @param {{ _read: any; _readableState: any; }} obj
@@ -55,7 +55,7 @@ function isReadableStream(obj) {
55
55
  getType(obj._read) === "AsyncFunction") &&
56
56
  getType(obj._readableState) === "Object"
57
57
  );
58
- }
58
+ };
59
59
 
60
60
  /**
61
61
  * @param {any} url
@@ -83,7 +83,7 @@ function get(url, jar, qs, options, ctx) {
83
83
  return request(op).then(function(res) {
84
84
  return res;
85
85
  });
86
- }
86
+ };
87
87
 
88
88
  function post(url, jar, form, options, ctx, customHeader) {
89
89
  var op = {
@@ -98,7 +98,7 @@ function post(url, jar, form, options, ctx, customHeader) {
98
98
  return request(op).then(function(res) {
99
99
  return res;
100
100
  });
101
- }
101
+ };
102
102
 
103
103
  /**
104
104
  * @param {any} url
@@ -130,7 +130,7 @@ function postFormData(url, jar, form, qs, options, ctx) {
130
130
  return request(op).then(function(res) {
131
131
  return res;
132
132
  });
133
- }
133
+ };
134
134
 
135
135
  /**
136
136
  * @param {string | number | any[]} val
@@ -142,7 +142,7 @@ function padZeros(val, len) {
142
142
  len = len || 2;
143
143
  while (val.length < len) val = "0" + val;
144
144
  return val;
145
- }
145
+ };
146
146
 
147
147
  /**
148
148
  * @param {any} clientID
@@ -153,7 +153,7 @@ function generateThreadingID(clientID) {
153
153
  var l = Math.floor(Math.random() * 4294967295);
154
154
  var m = clientID;
155
155
  return "<" + k + ":" + l + "-" + m + "@mail.projektitan.com>";
156
- }
156
+ };
157
157
 
158
158
  /**
159
159
  * @param {string | any[]} data
@@ -176,7 +176,7 @@ function binaryToDecimal(data) {
176
176
  data = fullName.slice(fullName.indexOf("1"));
177
177
  }
178
178
  return ret;
179
- }
179
+ };
180
180
 
181
181
  function generateOfflineThreadingID() {
182
182
  var ret = Date.now();
@@ -184,7 +184,7 @@ function generateOfflineThreadingID() {
184
184
  var str = ("0000000000000000000000" + value.toString(2)).slice(-22);
185
185
  var msgs = ret.toString(2) + str;
186
186
  return binaryToDecimal(msgs);
187
- }
187
+ };
188
188
 
189
189
  var h;
190
190
  var i = {};
@@ -240,7 +240,7 @@ function presenceEncode(str) {
240
240
  .replace(h, function(m) {
241
241
  return i[m];
242
242
  });
243
- }
243
+ };
244
244
 
245
245
  // eslint-disable-next-line no-unused-vars
246
246
  /**
@@ -253,7 +253,7 @@ function presenceDecode(str) {
253
253
  return j[m];
254
254
  })
255
255
  );
256
- }
256
+ };
257
257
 
258
258
  /**
259
259
  * @param {string} userID
@@ -283,7 +283,7 @@ function generatePresence(userID) {
283
283
  })
284
284
  )
285
285
  );
286
- }
286
+ };
287
287
 
288
288
  function generateAccessiblityCookie() {
289
289
  var time = Date.now();
@@ -299,7 +299,7 @@ function generateAccessiblityCookie() {
299
299
  "hcm-ts": time
300
300
  })
301
301
  );
302
- }
302
+ };
303
303
 
304
304
  function getGUID() {
305
305
  /** @type {number} */
@@ -320,7 +320,7 @@ function getGUID() {
320
320
  return _guid;
321
321
  });
322
322
  return id;
323
- }
323
+ };
324
324
 
325
325
  /**
326
326
  * @param {{ mercury: any; blob_attachment: any; attach_type: any; sticker_attachment: any; extensible_attachment: { story_attachment: { target: { __typename: string; }; }; }; metadata: { stickerID: { toString: () => any; }; packID: { toString: () => any; }; spriteURI: any; spriteURI2x: any; width: any; height: any; frameCount: any; frameRate: any; framesPerRow: any; framesPerCol: any; fbid: { toString: () => any; }; url: any; dimensions: { split: (arg0: string) => any[]; width: any; height: any; }; duration: any; }; url: any; name: any; fileName: any; thumbnail_url: any; preview_url: any; preview_width: any; preview_height: any; large_preview_url: any; large_preview_width: any; large_preview_height: any; share: { share_id: { toString: () => any; }; title: any; description: any; source: any; media: { image: any; image_size: { width: any; height: any; }; playable: any; duration: any; animated_image_size: any; }; subattachments: any; uri: any; target: any; style_list: any; }; }} attachment1
@@ -695,7 +695,7 @@ function _formatAttachment(attachment1, attachment2) {
695
695
  "`"
696
696
  );
697
697
  }
698
- }
698
+ };
699
699
 
700
700
  /**
701
701
  * @param {any[]} attachments
@@ -716,7 +716,7 @@ function formatAttachment(attachments, attachmentIds, attachmentMap, shareMap) {
716
716
  }
717
717
  return _formatAttachment(val, attachmentMap[attachmentIds[i]]);
718
718
  }) : [];
719
- }
719
+ };
720
720
 
721
721
  /**
722
722
  * @param {{ delta: { messageMetadata: any; data: { prng: string; }; body: string; attachments: any; participants: any; }; }} m
@@ -750,7 +750,7 @@ function formatDeltaMessage(m) {
750
750
  isGroup: !!md.threadKey.threadFbId,
751
751
  participantIDs: m.participants || []
752
752
  };
753
- }
753
+ };
754
754
 
755
755
  /**
756
756
  * @param {string} id
@@ -759,7 +759,7 @@ function formatDeltaMessage(m) {
759
759
  function formatID(id) {
760
760
  if (id != undefined && id != null) return id.replace(/(fb)?id[:.]/, "");
761
761
  else return id;
762
- }
762
+ };
763
763
 
764
764
  /**
765
765
  * @param {{ message: any; type: string; realtime_viewer_fbid: { toString: () => any; }; }} m
@@ -800,7 +800,7 @@ function formatMessage(m) {
800
800
  obj.isGroup = obj.participantIDs.length > 2;
801
801
 
802
802
  return obj;
803
- }
803
+ };
804
804
 
805
805
  /**
806
806
  * @param {{ message: any; }} m
@@ -821,7 +821,7 @@ function formatEvent(m) {
821
821
  logMessageData: logMessageData,
822
822
  logMessageBody: originalMessage.log_message_body
823
823
  });
824
- }
824
+ };
825
825
 
826
826
  /**
827
827
  * @param {{ action_type: any; }} m
@@ -834,7 +834,7 @@ function formatHistoryMessage(m) {
834
834
  default:
835
835
  return formatMessage(m);
836
836
  }
837
- }
837
+ };
838
838
 
839
839
  // Get a more readable message type for AdminTextMessages
840
840
  /**
@@ -865,7 +865,7 @@ function getAdminTextMessageType(m) {
865
865
  case "pin_messages_v2":
866
866
  return "log:thread-pinned";
867
867
  }
868
- }
868
+ };
869
869
 
870
870
  /**
871
871
  * @param {string} name
@@ -2219,7 +2219,7 @@ function getGenderByPhysicalMethod(name) {
2219
2219
  return "UNKNOWN";
2220
2220
  }
2221
2221
  return Name || "UNKNOWN";
2222
- }
2222
+ };
2223
2223
 
2224
2224
  /**
2225
2225
  * @param {{ [x: string]: { [x: string]: { [x: string]: any; }; }; class: any; untypedData: any; name: any; addedParticipants: any; leftParticipantFbId: any; messageMetadata: { threadKey: { threadFbId: any; otherUserFbId: any; }; adminText: any; actorFbId: any; }; participants: any; }} m
@@ -2350,7 +2350,7 @@ return {
2350
2350
  author: m.messageMetadata.actorFbId,
2351
2351
  participantIDs: m.participants || []
2352
2352
  };
2353
- }
2353
+ };
2354
2354
 
2355
2355
  /**
2356
2356
  * @param {{ st: any; from: { toString: () => any; }; to: any; thread_fbid: any; hasOwnProperty: (arg0: string) => any; from_mobile: any; realtime_viewer_fbid: any; }} event
@@ -2367,7 +2367,7 @@ return {
2367
2367
  userID: (event.realtime_viewer_fbid || event.from).toString(),
2368
2368
  type: "typ"
2369
2369
  };
2370
- }
2370
+ };
2371
2371
 
2372
2372
  /**
2373
2373
  * @param {{ threadKey: { otherUserFbId: any; threadFbId: any; }; actorFbId: any; actionTimestampMs: any; }} delta
@@ -2382,7 +2382,7 @@ function formatDeltaReadReceipt(delta) {
2382
2382
  threadID: formatID((threadKey.otherUserFbId || threadKey.threadFbId).toString()),
2383
2383
  type: "read_receipt"
2384
2384
  };
2385
- }
2385
+ };
2386
2386
 
2387
2387
  /**
2388
2388
  * @param {{ reader: { toString: () => any; }; time: any; thread_fbid: any; }} event
@@ -2395,7 +2395,7 @@ function formatReadReceipt(event) {
2395
2395
  threadID: formatID((event.thread_fbid || event.reader).toString()),
2396
2396
  type: "read_receipt"
2397
2397
  };
2398
- }
2398
+ };
2399
2399
 
2400
2400
  /**
2401
2401
  * @param {{ chat_ids: any[]; thread_fbids: any[]; timestamp: any; }} event
@@ -2407,7 +2407,7 @@ function formatRead(event) {
2407
2407
  time: event.timestamp,
2408
2408
  type: "read"
2409
2409
  };
2410
- }
2410
+ };
2411
2411
 
2412
2412
  /**
2413
2413
  * @param {string} str
@@ -2423,7 +2423,7 @@ function getFrom(str, startToken, endToken) {
2423
2423
  var end = lastHalf.indexOf(endToken);
2424
2424
  if (end === -1) throw Error("Could not find endTime `" + endToken + "` in the given string.");
2425
2425
  return lastHalf.substring(0, end);
2426
- }
2426
+ };
2427
2427
 
2428
2428
  /**
2429
2429
  * @param {string} html
@@ -2446,7 +2446,7 @@ function makeParsable(html) {
2446
2446
  if (maybeMultipleObjects.length === 1) return maybeMultipleObjects;
2447
2447
 
2448
2448
  return "[" + maybeMultipleObjects.join("},{") + "]";
2449
- }
2449
+ };
2450
2450
 
2451
2451
  /**
2452
2452
  * @param {any} form
@@ -2461,7 +2461,7 @@ function arrToForm(form) {
2461
2461
  return v.val;
2462
2462
  }
2463
2463
  );
2464
- }
2464
+ };
2465
2465
 
2466
2466
  /**
2467
2467
  * @param {any[]} arr
@@ -2475,16 +2475,16 @@ function arrayToObject(arr, getKey, getValue) {
2475
2475
  acc[getKey(val)] = getValue(val);
2476
2476
  return acc;
2477
2477
  }, {});
2478
- }
2478
+ };
2479
2479
 
2480
2480
  function getSignatureID() {
2481
2481
  return Math.floor(Math.random() * 2147483648).toString(16);
2482
- }
2482
+ };
2483
2483
 
2484
2484
  function generateTimestampRelative() {
2485
2485
  var d = new Date();
2486
2486
  return d.getHours() + ":" + padZeros(d.getMinutes());
2487
- }
2487
+ };
2488
2488
 
2489
2489
  /**
2490
2490
  * @param {any} html
@@ -2557,7 +2557,7 @@ function makeDefaults(html, userID, ctx) {
2557
2557
  if (obj.hasOwnProperty(prop))
2558
2558
  if (!newObj[prop]) newObj[prop] = obj[prop];
2559
2559
  return newObj;
2560
- }
2560
+ };
2561
2561
 
2562
2562
  /**
2563
2563
  * @param {any} url
@@ -2568,7 +2568,7 @@ function makeDefaults(html, userID, ctx) {
2568
2568
 
2569
2569
  function postWithDefaults(url, jar, form, ctxx) {
2570
2570
  return post(url, jar, mergeWithDefaults(form), ctx.globalOptions, ctxx || ctx);
2571
- }
2571
+ };
2572
2572
 
2573
2573
  /**
2574
2574
  * @param {any} url
@@ -2579,7 +2579,7 @@ function makeDefaults(html, userID, ctx) {
2579
2579
 
2580
2580
  function getWithDefaults(url, jar, qs, ctxx) {
2581
2581
  return get(url, jar, mergeWithDefaults(qs), ctx.globalOptions, ctxx || ctx);
2582
- }
2582
+ };
2583
2583
 
2584
2584
  /**
2585
2585
  * @param {any} url
@@ -2591,14 +2591,14 @@ function makeDefaults(html, userID, ctx) {
2591
2591
 
2592
2592
  function postFormDataWithDefault(url, jar, form, qs, ctxx) {
2593
2593
  return postFormData(url, jar, mergeWithDefaults(form), mergeWithDefaults(qs), ctx.globalOptions, ctxx || ctx);
2594
- }
2594
+ };
2595
2595
 
2596
2596
  return {
2597
2597
  get: getWithDefaults,
2598
2598
  post: postWithDefaults,
2599
2599
  postFormData: postFormDataWithDefault
2600
2600
  };
2601
- }
2601
+ };
2602
2602
 
2603
2603
  /**
2604
2604
  * @param {{ jar: { setCookie: (arg0: string, arg1: string) => void; }; fb_dtsg: string; ttstamp: string; }} ctx
@@ -2718,7 +2718,7 @@ function saveCookies(jar) {
2718
2718
  });
2719
2719
  return res;
2720
2720
  };
2721
- }
2721
+ };
2722
2722
 
2723
2723
  var NUM_TO_MONTH = [
2724
2724
  "Jan",
@@ -2750,7 +2750,7 @@ function formatDate(date) {
2750
2750
  var s = date.getUTCSeconds();
2751
2751
  s = s >= 10 ? s : "0" + s;
2752
2752
  return (NUM_TO_DAY[date.getUTCDay()] + ", " + d + " " + NUM_TO_MONTH[date.getUTCMonth()] + " " + date.getUTCFullYear() + " " + h + ":" + m + ":" + s + " GMT");
2753
- }
2753
+ };
2754
2754
 
2755
2755
  /**
2756
2756
  * @param {string[]} arr
@@ -2759,7 +2759,7 @@ function formatDate(date) {
2759
2759
 
2760
2760
  function formatCookie(arr, url) {
2761
2761
  return arr[0] + "=" + arr[1] + "; Path=" + arr[3] + "; Domain=" + url + ".com";
2762
- }
2762
+ };
2763
2763
 
2764
2764
  /**
2765
2765
  * @param {{ thread_fbid: { toString: () => any; }; participants: any[]; name: any; custom_nickname: any; snippet: any; snippet_attachments: any; snippet_sender: any; unread_count: any; message_count: any; image_src: any; timestamp: any; mute_until: any; is_canonical_user: any; is_canonical: any; is_subscribed: any; folder: any; is_archived: any; recipients_loadable: any; has_email_participant: any; read_only: any; can_reply: any; cannot_reply_reason: any; last_message_timestamp: any; last_read_timestamp: any; last_message_type: any; custom_like_icon: any; custom_color: any; admin_ids: any; thread_type: any; }} data
@@ -2798,7 +2798,7 @@ function formatThread(data) {
2798
2798
  adminIDs: data.admin_ids,
2799
2799
  threadType: data.thread_type
2800
2800
  };
2801
- }
2801
+ };
2802
2802
 
2803
2803
  /**
2804
2804
  * @param {any} obj
@@ -2806,7 +2806,7 @@ function formatThread(data) {
2806
2806
 
2807
2807
  function getType(obj) {
2808
2808
  return Object.prototype.toString.call(obj).slice(8, -1);
2809
- }
2809
+ };
2810
2810
 
2811
2811
  /**
2812
2812
  * @param {{ lat: number; p: any; }} presence
@@ -2821,7 +2821,7 @@ function formatProxyPresence(presence, userID) {
2821
2821
  userID: userID || '',
2822
2822
  statuses: presence.p
2823
2823
  };
2824
- }
2824
+ };
2825
2825
 
2826
2826
  /**
2827
2827
  * @param {{ la: number; a: any; }} presence
@@ -2835,7 +2835,7 @@ function formatPresence(presence, userID) {
2835
2835
  userID: userID || '',
2836
2836
  statuses: presence.a
2837
2837
  };
2838
- }
2838
+ };
2839
2839
 
2840
2840
  /**
2841
2841
  * @param {any} payload
@@ -2882,9 +2882,9 @@ function decodeClientPayload(payload) {
2882
2882
  }
2883
2883
  }
2884
2884
  return out;
2885
- }
2885
+ };
2886
2886
  return JSON.parse(Utf8ArrayToStr(payload));
2887
- }
2887
+ };
2888
2888
 
2889
2889
  /**
2890
2890
  * @param {{ getCookies: (arg0: string) => string | any[]; }} jar
@@ -2921,9 +2921,9 @@ function getAppState(jar, Encode) {
2921
2921
  logger.Normal(getText(Language.ProcessDone,`${prettyMilliseconds(Date.now() - globalThis.Fca.startTime)}`),function() { globalThis.Fca.Setting.set('getAppState',true); });
2922
2922
  }
2923
2923
  return data;
2924
- }
2924
+ };
2925
2925
 
2926
- function getData_Path(Obj , Arr, Stt) {
2926
+ function getData_Path(Obj, Arr, Stt) {
2927
2927
  //default stt = 0
2928
2928
  if (Arr.length === 0 && Obj != undefined) {
2929
2929
  return Obj; //object
@@ -2937,7 +2937,7 @@ function getData_Path(Obj , Arr, Stt) {
2937
2937
  }
2938
2938
  const tail = Arr.slice(1);
2939
2939
  return getData_Path(Obj[head], tail, Stt++);
2940
- }
2940
+ };
2941
2941
 
2942
2942
 
2943
2943
  function setData_Path(obj, path, value) {
@@ -2959,7 +2959,7 @@ function setData_Path(obj, path, value) {
2959
2959
  }
2960
2960
 
2961
2961
  return obj;
2962
- }
2962
+ };
2963
2963
 
2964
2964
  function getPaths(obj, parentPath = []) {
2965
2965
  let paths = [];
@@ -2971,7 +2971,7 @@ function getPaths(obj, parentPath = []) {
2971
2971
  }
2972
2972
  }
2973
2973
  return paths;
2974
- }
2974
+ };
2975
2975
 
2976
2976
  function cleanHTML (text) {
2977
2977
  text = text.replace(/(<br>)|(<\/?i>)|(<\/?em>)|(<\/?b>)|(!?~)|(&amp;)|(&#039;)|(&lt;)|(&gt;)|(&quot;)/g, (match) => {
@@ -3002,7 +3002,7 @@ function cleanHTML (text) {
3002
3002
  }
3003
3003
  });
3004
3004
  return text;
3005
- }
3005
+ };
3006
3006
 
3007
3007
  module.exports = {
3008
3008
  cleanHTML,