meta-horizonn 1.3.0 → 1.3.2

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/Main.js CHANGED
@@ -645,7 +645,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
645
645
  .then(function(res) {
646
646
  var headers = res.headers;
647
647
  if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) throw { error: "wtf ??:D" };
648
- var appState = utils.getAppState(jar,false);
648
+ var appState = utils.getAppState(jar, false);
649
649
  Database().set('Through2Fa', appState);
650
650
  return loginHelper(appState, email, password, loginOptions, callback);
651
651
  })
@@ -731,8 +731,9 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
731
731
  }
732
732
  })
733
733
  .then(function() {
734
- delete form.no_fido;delete form.approvals_code;
735
- form.name_action_selected = 'dont_save'; //'save_device' || 'dont_save;
734
+ delete form.no_fido;
735
+ delete form.approvals_code;
736
+ form.name_action_selected = 'dont_save'; // 'save_device' || 'dont_save;
736
737
  return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
737
738
  })
738
739
  .then(function(res) {
@@ -862,6 +863,7 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
862
863
 
863
864
  try {
864
865
  if (appState) {
866
+ if (Array.isArray(appState) && appState.length > 0 && appState[0].hasOwnProperty('key')) {
865
867
  // console.log(gradient('purple', 'orange').multiline(["H", "O", "R", "I", "Z", "O", "N"].join('\n')));
866
868
  logger.Normal(Language.OnProcess);
867
869
  switch (Database().has("FBKEY")) {
@@ -881,6 +883,7 @@ try {
881
883
  Database().set('FBKEY', SecurityKey);
882
884
  }
883
885
  }
886
+ }
884
887
  try {
885
888
  switch (global.Fca.Require.FastConfig.EncryptFeature) {
886
889
  case true: {
@@ -969,6 +972,7 @@ try {
969
972
  Database().set('Backup', appState);
970
973
  mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
971
974
  }
975
+ // }
972
976
  catch (e) {
973
977
  try {
974
978
  if (Database().has('Backup')) {
@@ -999,32 +1003,73 @@ try {
999
1003
  console.log(e);
1000
1004
  }
1001
1005
 
1006
+ function CheckAndFixErr(res) {
1007
+ let reg_antierr = /This browser is not supported/gs; // =))))))
1008
+ if (reg_antierr.test(res.body)) {
1009
+ const Data = JSON.stringify(res.body);
1010
+ const Dt_Check = Data.split('2Fhome.php&gfid=')[1];
1011
+ if (Dt_Check == undefined) return res
1012
+ const fid = Dt_Check.split("\\\\")[0];//fix sau
1013
+ if (Dt_Check == undefined || Dt_Check == "") return res
1014
+ const final_fid = fid.split(`\\`)[0];
1015
+ if (final_fid == undefined || final_fid == '') return res;
1016
+ const redirectlink = redirect[1] + "a/preferences.php?basic_site_devices=m_basic&uri=" + encodeURIComponent("https://m.facebook.com/home.php") + "&gfid=" + final_fid;
1017
+ bypass_region_err = true;
1018
+ return utils.get(redirectlink, jar, null, globalOptions).then(utils.saveCookies(jar));
1019
+ }
1020
+ else return res
1021
+ };
1022
+
1023
+ function Redirect(res) {
1024
+ var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
1025
+ redirect = reg.exec(res.body);
1026
+ if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
1027
+ return res;
1028
+ };
1029
+
1002
1030
  let redirect = [1, "https://m.facebook.com/"];
1003
1031
  let bypass_region_err = false;
1004
1032
  var ctx, api;
1005
1033
  mainPromise = mainPromise
1034
+ .then(res => Redirect(res))
1035
+ .then(res => CheckAndFixErr(res))
1036
+
1037
+ //fix via login with defaut UA return WWW.facebook.com not m.facebook.com
1038
+
1006
1039
  .then(function(res) {
1007
- var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
1008
- redirect = reg.exec(res.body);
1009
- if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
1010
- return res;
1011
- })
1012
- .then(function(res) {
1013
- let reg_antierr = /This browser is not supported/gs; // =))))))
1014
- if (reg_antierr.test(res.body)) {
1015
- const Data = JSON.stringify(res.body);
1016
- const Dt_Check = Data.split('2Fhome.php&amp;gfid=')[1];
1017
- if (Dt_Check == undefined) return res
1018
- const fid = Dt_Check.split("\\\\")[0];//fix sau
1019
- if (Dt_Check == undefined || Dt_Check == "") return res
1020
- const final_fid = fid.split(`\\`)[0];
1021
- if (final_fid == undefined || final_fid == '') return res;
1022
- const redirectlink = redirect[1] + "a/preferences.php?basic_site_devices=m_basic&uri=" + encodeURIComponent("https://m.facebook.com/home.php") + "&gfid=" + final_fid;
1023
- bypass_region_err = true;
1024
- return utils.get(redirectlink, jar, null, globalOptions).then(utils.saveCookies(jar));
1040
+ let Regex_Via = /MPageLoadClientMetrics/gs; //default for normal account, can easily get region, without this u can't get region in some case but u can run normal
1041
+ if (!Regex_Via.test(res.body)) {
1042
+ //www.facebook.com
1043
+ globalOptions.userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1";
1044
+ return utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
1025
1045
  }
1026
1046
  else return res
1027
1047
  })
1048
+ .then(res => Redirect(res))
1049
+ .then(res => CheckAndFixErr(res))
1050
+
1051
+ // .then(function(res) {
1052
+ // var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
1053
+ // redirect = reg.exec(res.body);
1054
+ // if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
1055
+ // return res;
1056
+ // })
1057
+ // .then(function(res) {
1058
+ // let reg_antierr = /This browser is not supported/gs; // =))))))
1059
+ // if (reg_antierr.test(res.body)) {
1060
+ // const Data = JSON.stringify(res.body);
1061
+ // const Dt_Check = Data.split('2Fhome.php&amp;gfid=')[1];
1062
+ // if (Dt_Check == undefined) return res
1063
+ // const fid = Dt_Check.split("\\\\")[0];//fix sau
1064
+ // if (Dt_Check == undefined || Dt_Check == "") return res
1065
+ // const final_fid = fid.split(`\\`)[0];
1066
+ // if (final_fid == undefined || final_fid == '') return res;
1067
+ // const redirectlink = redirect[1] + "a/preferences.php?basic_site_devices=m_basic&uri=" + encodeURIComponent("https://m.facebook.com/home.php") + "&gfid=" + final_fid;
1068
+ // bypass_region_err = true;
1069
+ // return utils.get(redirectlink, jar, null, globalOptions).then(utils.saveCookies(jar));
1070
+ // }
1071
+ // else return res
1072
+ // })
1028
1073
  // .then(function(res) {
1029
1074
  // let reg_old_web = /Switch Default Site/gs;
1030
1075
  // if (reg_old_web.test(res.body)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meta-horizonn",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
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": {
package/src/listenMqtt.js CHANGED
@@ -799,16 +799,22 @@ function parseDelta(defaultFuncs, api, ctx, globalCallback, {
799
799
  break;
800
800
  }
801
801
  case 'NewMessage': {
802
- if (delta.attachments !== undefined && delta.attachments.length === 1 && delta.attachments[0].mercury.extensible_attachment !== undefined && delta.attachments[0].mercury.extensible_attachment.story_attachment.style_list != null && delta.attachments[0].mercury.extensible_attachment.story_attachment.style_list.includes('message_live_location')) {
802
+ const hasLiveLocation = (delta) => {
803
+ const attachment = delta.attachments?.[0]?.mercury?.extensible_attachment;
804
+ const storyAttachment = attachment?.story_attachment;
805
+ return storyAttachment?.style_list?.includes('message_live_location');
806
+ };
807
+
808
+ if (delta.attachments?.length === 1 && hasLiveLocation(delta)) {
803
809
  delta.class = 'UserLocation';
804
- let fmtMsg;
810
+
805
811
  try {
806
- fmtMsg = utils.formatDeltaEvent(delta);
812
+ const fmtMsg = utils.formatDeltaEvent(delta);
813
+ globalCallback(null, fmtMsg);
807
814
  } catch (err) {
808
815
  console.log(delta);
809
- return log.error('Lỗi Nhẹ', err);
816
+ log.error('Lỗi Nhẹ', err);
810
817
  }
811
- globalCallback(null, fmtMsg);
812
818
  }
813
819
  break;
814
820
  }