king-boy 3.3.0 → 9.4.3

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/logger.js CHANGED
@@ -1,3 +1,4 @@
1
+ 'use strict';
1
2
  /* eslint-disable linebreak-style */
2
3
 
3
4
  const chalk = require('chalk');
@@ -21,7 +22,7 @@ module.exports = {
21
22
  }
22
23
  else console.log(chalk.hex(global.Fca.Require.FastConfig.MainColor).bold(`${global.Fca.Require.FastConfig.MainName || '[ FCA-HZI ]'} > `) + Str);
23
24
  if (getType(Data) == 'Function' || getType(Data) == 'AsyncFunction') {
24
- return Data()
25
+ return Data();
25
26
  }
26
27
  if (Data) {
27
28
  return Data;
@@ -62,4 +63,4 @@ module.exports = {
62
63
  }
63
64
  else return callback;
64
65
  }
65
- }
66
+ };
package/package.json CHANGED
@@ -1,37 +1,37 @@
1
1
  {
2
2
  "name": "king-boy",
3
- "version": "3.3.0",
4
- "description": "Facebook-chat-api Chand tricker YouTuber",
5
- "main": "index.js",
3
+ "version": "9.4.3",
4
+ "description": "Facebook-chat-api protect and deploy by Kanzu and HZI Team",
5
+ "main": "Index.js",
6
6
  "scripts": {
7
7
  "test": "mocha",
8
- "lint": "./node_modules/.bin/eslint **.js",
8
+ "lint": "./node_modules/.bin/eslint *.js",
9
9
  "prettier": "prettier utils.js src/* --write"
10
10
  },
11
- "author": "CHAND TRICKER",
11
+ "author": "Avery, David, Maude, Benjamin, UIRI, KanzuWakazaki",
12
12
  "license": "MIT",
13
13
  "bugs": {
14
- "url": "https://github.com/corazoncary/fca/issues"
14
+ "url": "https://github.com/KanzuXHorizon/Fca-Horizon-Remastered/issues"
15
15
  },
16
- "homepage": "https://github.com/corazoncary/fca#readme",
16
+ "homepage": "https://github.com/KanzuXHorizon/Fca-Horizon-Remastered#readme",
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "https://github.com/corazoncary/fca.git"
19
+ "url": "git://github.com/KanzuXHorizon/Fca-Horizon-Remastered.git"
20
20
  },
21
21
  "dependencies": {
22
22
  "aes-js": "latest",
23
23
  "assert": "latest",
24
- "better-sqlite3": "7.4.5",
25
24
  "bluebird": "latest",
26
25
  "chalk": "4.1.2",
27
26
  "cheerio": "latest",
28
27
  "crypto-js": "latest",
28
+ "deasync": "^0.1.28",
29
+ "encode32": "latest",
29
30
  "express": "latest",
30
31
  "file-url": "^3.0.0",
31
- "got": "^11.8.3",
32
+ "got": "^11.8.6",
32
33
  "https-proxy-agent": "latest",
33
34
  "is-hexcolor": "^1.0.0",
34
- "lodash": "latest",
35
35
  "moment": "^2.29.4",
36
36
  "mqtt": "latest",
37
37
  "npmlog": "latest",
@@ -41,18 +41,19 @@
41
41
  "readline": "latest",
42
42
  "request": "latest",
43
43
  "semver": "^7.4.0",
44
- "sqlite": "4.0.21",
45
44
  "totp-generator": "latest",
46
- "uuid": "latest",
47
- "encode32": "latest",
48
45
  "tough-cookie": "^4.1.2",
46
+ "uuid": "latest",
47
+ "vm": "^0.1.0",
48
+ "lodash": "latest",
49
+ "better-sqlite3": "7.6.2",
49
50
  "websocket-stream": "latest"
50
51
  },
51
52
  "engines": {
52
- "node": ">=14.x <16.x"
53
+ "node": ">=14.x"
53
54
  },
54
55
  "devDependencies": {
55
- "eslint": "latest",
56
+ "eslint": "^8.40.0",
56
57
  "mocha": "latest",
57
58
  "prettier": "latest"
58
59
  },
@@ -83,9 +84,9 @@
83
84
  }
84
85
  },
85
86
  "keywords": [
86
- "Fca CHAND",
87
- "FCA-Ali baba",
88
- "TEAM-ATF",
89
- "FCA JORDAN"
87
+ "Fca horizon",
88
+ "fca-horizon-remastered",
89
+ "horizon fca",
90
+ "horizon"
90
91
  ]
91
92
  }
package/src/Premium.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var { join } = require('path')
4
- var fs = require('fs')
3
+ var { join } = require('path');
4
+ var fs = require('fs');
5
5
 
6
6
 
7
7
  module.exports = function (defaultFuncs, api, ctx) {
8
8
  return function(Name, args){
9
- var Method = {}
9
+ var Method = {};
10
10
  fs.readdirSync(join(__dirname, "../Func")).filter((/** @type {string} */File) => File.endsWith(".js") && !File.includes('Dev_')).map((/** @type {string} */File) => Method[File.split('.').slice(0, -1).join('.')] = require(`../Func/${File}`)(defaultFuncs, api, ctx));
11
11
  if (Method[Name] == undefined) {
12
12
  return (`Method ${Name} not found`);
@@ -16,7 +16,7 @@ module.exports = function (defaultFuncs, api, ctx) {
16
16
  if (process.env.HalzionVersion == 1973 && global.Fca.Data.PremText.includes("Premium")) {
17
17
  return Method[Name](args).then((/** @type {string} */Data) => {
18
18
  return Data;
19
- })
19
+ });
20
20
  }
21
21
  else {
22
22
  return ("Mua Premium Đi Rồi Sài Ông Cháu Ơi !!");
@@ -26,5 +26,5 @@ module.exports = function (defaultFuncs, api, ctx) {
26
26
  console.log(e);
27
27
  }
28
28
  }
29
- }
29
+ };
30
30
  };
package/src/Screenshot.js CHANGED
@@ -1,10 +1,7 @@
1
1
  /* eslint-disable linebreak-style */
2
2
  "use strict";
3
3
 
4
- var { join } = require('path');
5
- var fs = require('fs');
6
- var utils = require("../utils");
7
- var logger = require('../logger')
4
+
8
5
  module.exports = function (defaultFuncs, api, ctx) {
9
6
  var Coookie = JSON.parse(JSON.stringify(ctx.jar.getCookies("https://www.facebook.com").concat(ctx.jar.getCookies("https://facebook.com")).concat(ctx.jar.getCookies("https://www.messenger.com"))));
10
7
  for (let i of Coookie) {
@@ -13,6 +10,7 @@ module.exports = function (defaultFuncs, api, ctx) {
13
10
  delete i.key;
14
11
  }
15
12
  return function(Link, callback) {
13
+ var logger = require('../logger');
16
14
  if (process.platform != 'win32') return logger.Error('Not Supported Platform');
17
15
  else try {
18
16
  let i = require('puppeteer');
@@ -1,10 +1,6 @@
1
1
  /* eslint-disable linebreak-style */
2
2
  "use strict";
3
3
 
4
- var utils = require("../utils");
5
- var log = require("npmlog");
6
-
7
-
8
4
  module.exports = function (defaultFuncs, api, ctx) {
9
5
  return function getAccessToken(callback) {
10
6
  var resolveFunc = function () { };
@@ -195,7 +195,7 @@ function formatReactionsGraphQL(reaction) {
195
195
  }
196
196
 
197
197
  function formatEventData(event) {
198
- if (event == null) return {}
198
+ if (event == null) return {};
199
199
 
200
200
  switch (event.__typename) {
201
201
  case "ThemeColorExtensibleMessageAdminText":
@@ -147,8 +147,9 @@ function formatThreadGraphQLResponse(data) {
147
147
 
148
148
  module.exports = function(defaultFuncs, api, ctx) {
149
149
 
150
- var { createData,getData,hasData,alreadyUpdate,setLastRun,updateData, getAll } = require('../Extra/ExtraGetThread');
150
+ var { createData,getData,hasData,setLastRun,updateData, getAll } = require('../Extra/ExtraGetThread');
151
151
  var { capture } = require('../Extra/Src/Last-Run');
152
+ var Database = require('../Extra/Database');
152
153
  global.Fca.Data.Userinfo = [];
153
154
 
154
155
  return function getThreadInfoGraphQL(threadID, callback) {
@@ -173,25 +174,31 @@ module.exports = function(defaultFuncs, api, ctx) {
173
174
  // đã áp dụng vào fca mới(cloud - fca(private)) vào cuối tháng 8/2022 bởi @IteralingCode(Hidden Member( always :) )) - Synthetic 4 - @Horizon Team
174
175
  //cập nhật dự án bị bỏ rơi này vào ngày 19/11/2022 bởi @KanzuWakazaki(Owner) - Synthetic 1 - @Horizon Team nhằm đáp ứng nhu cầu của client !
175
176
 
176
- var time = new Date().toLocaleDateString('vi-VN', {minute: 'numeric' }).split(',')[0]
177
-
178
177
  if (utils.getType(threadID) !== "Array") threadID = [threadID];
179
178
 
180
179
 
181
180
  var SpecialMethod = function(TID) {
182
181
  var All = getAll();
183
- var AllofThread = []
184
- if (All.length < 1) {
185
- return DefaultMethod(TID);
186
- } else if (All.length > 1) {
187
- for (let i of All) {
188
- if (i.data.threadID != undefined) {
189
- AllofThread.push(i.data.threadID);
190
- } else continue;
191
- }
192
- var Form = {};
193
- var ThreadInfo = [];
194
-
182
+ var Real = [];
183
+ for (let i of All) {
184
+ if (i.data.threadID != undefined) {
185
+ Real.push(i.data.threadID);
186
+ } else continue;
187
+ }
188
+ var AllofThread = [];
189
+ if (Real.length == 0) return;
190
+ else if (Real.length == 1) {
191
+ return DefaultMethod(TID);
192
+ }
193
+ else if (All.length > 1) {
194
+ for (let i of All) {
195
+ if (i.data.threadID != undefined) {
196
+ AllofThread.push(i.data.threadID);
197
+ } else continue;
198
+ }
199
+ var Form = {};
200
+ var ThreadInfo = [];
201
+
195
202
  AllofThread.map(function (x,y) {
196
203
  Form["o" + y] = {
197
204
  doc_id: "3449967031715030",
@@ -215,34 +222,53 @@ module.exports = function(defaultFuncs, api, ctx) {
215
222
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
216
223
  .then(function(resData) {
217
224
  if (resData.error) {
218
- throw "Lỗi: getThreadInfoGraphQL Có Thể Do Bạn Spam Quá Nhiều"
225
+ throw "Lỗi: getThreadInfoGraphQL Có Thể Do Bạn Spam Quá Nhiều";
219
226
  }
220
227
  if (resData[resData.length - 1].error_results !== 0) {
221
- throw "Lỗi: getThreadInfoGraphQL Có Thể Do Bạn Spam Quá Nhiều"
228
+ throw "Lỗi: getThreadInfoGraphQL Có Thể Do Bạn Spam Quá Nhiều";
222
229
  }
223
230
  resData = resData.splice(0, resData.length - 1);
224
231
  resData.sort((a, b) => { return Object.keys(a)[0].localeCompare(Object.keys(b)[0]); });
225
232
  resData.map(function (x,y) {
226
233
  ThreadInfo.push(formatThreadGraphQLResponse(x["o"+y].data));
227
234
  });
228
- global.Fca.Data.Userinfo = []
229
235
  if (process.env.HalzionVersion == 1973) {
236
+ try {
230
237
  if (Object.keys(resData).length == 1) {
231
238
  updateData(threadID,ThreadInfo[0]);
232
- global.Fca.Data.Userinfo.push(ThreadInfo[0].userInfo);
239
+ if (utils.getType(ThreadInfo[0].userInfo) == "Array") {
240
+ for (let i of ThreadInfo[0].userInfo) {
241
+ if (global.Fca.Data.Userinfo.some(ii => ii.id == i.id)) {
242
+ global.Fca.Data.Userinfo.splice(global.Fca.Data.Userinfo.findIndex(ii => ii.id == i.id), 1);
243
+ }
244
+ global.Fca.Data.Userinfo.push(i);
245
+ }
246
+ }
233
247
  } else {
234
248
  for (let i of ThreadInfo) {
235
249
  updateData(i.threadID,i);
236
- global.Fca.Data.Userinfo.push(i.userInfo);
250
+ if (utils.getType(i.userInfo) == "Array") {
251
+ for (let ii of i.userInfo) {
252
+ if (global.Fca.Data.Userinfo.some(iii => iii.id == ii.id)) {
253
+ global.Fca.Data.Userinfo.splice(global.Fca.Data.Userinfo.findIndex(iii => iii.id == ii.id), 1);
254
+ }
255
+ global.Fca.Data.Userinfo.push(ii);
256
+ }
257
+ }
237
258
  }
238
259
  }
239
260
  }
261
+ catch (e) {
262
+ console.log(e);
263
+ }
264
+ }
240
265
  })
241
266
  .catch(function(err){
242
- throw "Lỗi: getThreadInfoGraphQL Có Thể Do Bạn Spam Quá Nhiều"
267
+ throw "Lỗi: getThreadInfoGraphQL Có Thể Do Bạn Spam Quá Nhiều";
243
268
  });
244
269
  }
245
- }
270
+ };
271
+
246
272
  var DefaultMethod = function(TID) {
247
273
  var ThreadInfo = [];
248
274
  for (let i of TID) {
@@ -250,16 +276,30 @@ module.exports = function(defaultFuncs, api, ctx) {
250
276
  }
251
277
  if (ThreadInfo.length == 1) {
252
278
  callback(null,ThreadInfo[0]);
253
- global.Fca.Data.Userinfo.push(ThreadInfo[0].userInfo);
279
+ if (utils.getType(ThreadInfo[0].userInfo) == "Array") {
280
+ for (let i of ThreadInfo[0].userInfo) {
281
+ if (global.Fca.Data.Userinfo.some(ii => ii.id == i.id)) {
282
+ global.Fca.Data.Userinfo.splice(global.Fca.Data.Userinfo.findIndex(ii => ii.id == i.id), 1);
283
+ }
284
+ global.Fca.Data.Userinfo.push(i);
285
+ }
254
286
  } else {
255
287
  for (let i of ThreadInfo) {
256
- global.Fca.Data.Userinfo.push(i.userInfo);
288
+ if (utils.getType(i.userInfo) == "Array") {
289
+ for (let ii of i.userInfo) {
290
+ if (global.Fca.Data.Userinfo.some(iii => iii.id == ii.id)) {
291
+ global.Fca.Data.Userinfo.splice(global.Fca.Data.Userinfo.findIndex(iii => iii.id == ii.id), 1);
292
+ }
293
+ global.Fca.Data.Userinfo.push(ii);
294
+ }
295
+ }
257
296
  }
258
297
  callback(null,ThreadInfo);
259
298
  }
260
299
  }
300
+ };
261
301
  var CreateMethod = function(TID) {
262
- var Form = {}
302
+ var Form = {};
263
303
  var ThreadInfo = [];
264
304
 
265
305
  TID.map(function (x,y) {
@@ -285,12 +325,10 @@ module.exports = function(defaultFuncs, api, ctx) {
285
325
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
286
326
  .then(function(resData) {
287
327
  if (resData.error) {
288
- callback(null,{threadID:"5011501735554963",threadName:"TempThreadInfo",participantIDs:["100042817150429","100077059530660"],userInfo:[{id:"100042817150429",name:"Nguyễn Th\xe1i Hảo",firstName:"Hảo",vanity:"Lazic.Kanzu",thumbSrc:"https://scontent.fsgn5-10.fna.fbcdn.net/v/t39.30808-1/311136459_774539707316594_357342861145224378_n.jpg?stp=cp0_dst-jpg_p60x60&_nc_cat=101&ccb=1-7&_nc_sid=f67be1&_nc_ohc=0y9pN1XSiVIAX8HS5P6&_nc_ht=scontent.fsgn5-10.fna&oh=00_AfCBYmeKDgLZLWDMRBmBZj8zRLboVA096bkbsC4a1Q0DUQ&oe=637E5939",profileUrl:"https://scontent.fsgn5-10.fna.fbcdn.net/v/t39.30808-1/311136459_774539707316594_357342861145224378_n.jpg?stp=cp0_dst-jpg_p60x60&_nc_cat=101&ccb=1-7&_nc_sid=f67be1&_nc_ohc=0y9pN1XSiVIAX8HS5P6&_nc_ht=scontent.fsgn5-10.fna&oh=00_AfCBYmeKDgLZLWDMRBmBZj8zRLboVA096bkbsC4a1Q0DUQ&oe=637E5939",gender:"MALE",type:"User",isFriend:!0,isBirthday:!1},{id:"100077059530660",name:"Lucius Hori",firstName:"Lucius",vanity:"Horizon.Lucius.Synthesis.III",thumbSrc:"https://scontent.fsgn5-3.fna.fbcdn.net/v/t39.30808-1/309709623_179304871314830_1479186956574752444_n.jpg?stp=cp0_dst-jpg_p60x60&_nc_cat=104&ccb=1-7&_nc_sid=7206a8&_nc_ohc=rXiLw0_ID7MAX-q4wYv&_nc_ht=scontent.fsgn5-3.fna&oh=00_AfD8Wl_EQLLBCZOWxmBdcIP9Nc1iyLQY9qsMTIN4Sf5H8w&oe=637D35E0",profileUrl:"https://scontent.fsgn5-3.fna.fbcdn.net/v/t39.30808-1/309709623_179304871314830_1479186956574752444_n.jpg?stp=cp0_dst-jpg_p60x60&_nc_cat=104&ccb=1-7&_nc_sid=7206a8&_nc_ohc=rXiLw0_ID7MAX-q4wYv&_nc_ht=scontent.fsgn5-3.fna&oh=00_AfD8Wl_EQLLBCZOWxmBdcIP9Nc1iyLQY9qsMTIN4Sf5H8w&oe=637D35E0",gender:"MALE",type:"User",isFriend:!1,isBirthday:!1}],unreadCount:38357,messageCount:39288,timestamp:"1668862170994",muteUntil:null,isGroup:!0,isSubscribed:!0,isArchived:!1,folder:"INBOX",cannotReplyReason:null,eventReminders:[],emoji:"\uD83D\uDE0F",color:"DD8800",nicknames:{"100042817150429":"Bla bla"},adminIDs:[{id:"100042817150429"}],approvalMode:!0,approvalQueue:[],reactionsMuteMode:"reactions_not_muted",mentionsMuteMode:"mentions_not_muted",isPinProtected:!1,relatedPageThread:null,name:"Temp ThreadInfo GraphQL",snippet:"/getthreadtest",snippetSender:"100042817150429",snippetAttachments:[],serverTimestamp:"1668862170994",imageSrc:"https://scontent.fsgn5-10.fna.fbcdn.net/v/t1.15752-9/278020824_345766417524223_6790288127531819759_n.jpg?_nc_cat=101&ccb=1-7&_nc_sid=02e273&_nc_ohc=kOr9K5TWwDMAX-4qPH1&_nc_ht=scontent.fsgn5-10.fna&oh=03_AdRQSwLyIGJ-zrgyQj1IIQAFO3IC-4_Qq_qMd58ZtMCI0A&oe=63A02D7A",isCanonicalUser:!1,isCanonical:!1,recipientsLoadable:!0,hasEmailParticipant:!1,readOnly:!1,canReply:!0,lastMessageType:"message",lastReadTimestamp:"1649756873571",threadType:2,TimeCreate:1668862173440,TimeUpdate:1668862173440});
289
- throw resData.error
328
+ throw resData.error;
290
329
  }
291
330
  if (resData[resData.length - 1].error_results !== 0) {
292
- callback(null,{threadID:"5011501735554963",threadName:"TempThreadInfo",participantIDs:["100042817150429","100077059530660"],userInfo:[{id:"100042817150429",name:"Nguyễn Th\xe1i Hảo",firstName:"Hảo",vanity:"Lazic.Kanzu",thumbSrc:"https://scontent.fsgn5-10.fna.fbcdn.net/v/t39.30808-1/311136459_774539707316594_357342861145224378_n.jpg?stp=cp0_dst-jpg_p60x60&_nc_cat=101&ccb=1-7&_nc_sid=f67be1&_nc_ohc=0y9pN1XSiVIAX8HS5P6&_nc_ht=scontent.fsgn5-10.fna&oh=00_AfCBYmeKDgLZLWDMRBmBZj8zRLboVA096bkbsC4a1Q0DUQ&oe=637E5939",profileUrl:"https://scontent.fsgn5-10.fna.fbcdn.net/v/t39.30808-1/311136459_774539707316594_357342861145224378_n.jpg?stp=cp0_dst-jpg_p60x60&_nc_cat=101&ccb=1-7&_nc_sid=f67be1&_nc_ohc=0y9pN1XSiVIAX8HS5P6&_nc_ht=scontent.fsgn5-10.fna&oh=00_AfCBYmeKDgLZLWDMRBmBZj8zRLboVA096bkbsC4a1Q0DUQ&oe=637E5939",gender:"MALE",type:"User",isFriend:!0,isBirthday:!1},{id:"100077059530660",name:"Lucius Hori",firstName:"Lucius",vanity:"Horizon.Lucius.Synthesis.III",thumbSrc:"https://scontent.fsgn5-3.fna.fbcdn.net/v/t39.30808-1/309709623_179304871314830_1479186956574752444_n.jpg?stp=cp0_dst-jpg_p60x60&_nc_cat=104&ccb=1-7&_nc_sid=7206a8&_nc_ohc=rXiLw0_ID7MAX-q4wYv&_nc_ht=scontent.fsgn5-3.fna&oh=00_AfD8Wl_EQLLBCZOWxmBdcIP9Nc1iyLQY9qsMTIN4Sf5H8w&oe=637D35E0",profileUrl:"https://scontent.fsgn5-3.fna.fbcdn.net/v/t39.30808-1/309709623_179304871314830_1479186956574752444_n.jpg?stp=cp0_dst-jpg_p60x60&_nc_cat=104&ccb=1-7&_nc_sid=7206a8&_nc_ohc=rXiLw0_ID7MAX-q4wYv&_nc_ht=scontent.fsgn5-3.fna&oh=00_AfD8Wl_EQLLBCZOWxmBdcIP9Nc1iyLQY9qsMTIN4Sf5H8w&oe=637D35E0",gender:"MALE",type:"User",isFriend:!1,isBirthday:!1}],unreadCount:38357,messageCount:39288,timestamp:"1668862170994",muteUntil:null,isGroup:!0,isSubscribed:!0,isArchived:!1,folder:"INBOX",cannotReplyReason:null,eventReminders:[],emoji:"\uD83D\uDE0F",color:"DD8800",nicknames:{"100042817150429":"Bla bla"},adminIDs:[{id:"100042817150429"}],approvalMode:!0,approvalQueue:[],reactionsMuteMode:"reactions_not_muted",mentionsMuteMode:"mentions_not_muted",isPinProtected:!1,relatedPageThread:null,name:"Temp ThreadInfo GraphQL",snippet:"/getthreadtest",snippetSender:"100042817150429",snippetAttachments:[],serverTimestamp:"1668862170994",imageSrc:"https://scontent.fsgn5-10.fna.fbcdn.net/v/t1.15752-9/278020824_345766417524223_6790288127531819759_n.jpg?_nc_cat=101&ccb=1-7&_nc_sid=02e273&_nc_ohc=kOr9K5TWwDMAX-4qPH1&_nc_ht=scontent.fsgn5-10.fna&oh=03_AdRQSwLyIGJ-zrgyQj1IIQAFO3IC-4_Qq_qMd58ZtMCI0A&oe=63A02D7A",isCanonicalUser:!1,isCanonical:!1,recipientsLoadable:!0,hasEmailParticipant:!1,readOnly:!1,canReply:!0,lastMessageType:"message",lastReadTimestamp:"1649756873571",threadType:2,TimeCreate:1668862173440,TimeUpdate:1668862173440});
293
- throw resData.error
331
+ throw resData.error;
294
332
  }
295
333
  resData = resData.splice(0, resData.length - 1);
296
334
  resData.sort((a, b) => { return Object.keys(a)[0].localeCompare(Object.keys(b)[0]); });
@@ -299,50 +337,76 @@ module.exports = function(defaultFuncs, api, ctx) {
299
337
  });
300
338
  if (process.env.HalzionVersion == 1973) {
301
339
  if (Object.keys(resData).length == 1) {
302
- // api.Horizon_Data([ThreadInfo], "Threads", "Post");
303
340
  createData(threadID,ThreadInfo[0]);
304
341
  callback(null, ThreadInfo[0]);
305
342
  capture(callback);
306
343
  setLastRun('LastUpdate', callback);
344
+ if (utils.getType(ThreadInfo[0].userInfo) == "Array") {
345
+ for (let i of ThreadInfo[0].userInfo) {
346
+ if (global.Fca.Data.Userinfo.some(ii => ii.id == i.id)) {
347
+ global.Fca.Data.Userinfo.splice(global.Fca.Data.Userinfo.findIndex(ii => ii.id == i.id), 1);
348
+ }
349
+ global.Fca.Data.Userinfo.push(i);
350
+ }
351
+ }
307
352
  } else {
308
353
  // api.Horizon_Data([ThreadInfo], "Threads", "Post");
309
354
  for (let i of ThreadInfo) {
310
355
  createData(i.threadID,i);
311
- global.Fca.Data.Userinfo.push(i.userInfo);
356
+ if (utils.getType(i.userInfo) == "Array") {
357
+ for (let ii of i.userInfo) {
358
+ if (global.Fca.Data.Userinfo.some(iii => iii.id == ii.id)) {
359
+ global.Fca.Data.Userinfo.splice(global.Fca.Data.Userinfo.findIndex(iii => iii.id == ii.id), 1);
360
+ }
361
+ global.Fca.Data.Userinfo.push(ii);
362
+ }
363
+ }
312
364
  }
313
365
  callback(null, ThreadInfo);
314
366
  }
315
367
  }
316
368
  else {
317
369
  callback(null, ThreadInfo[0]);
318
- global.Fca.Data.Userinfo.push(ThreadInfo[0].userInfo);
370
+ if (utils.getType(ThreadInfo[0].userInfo) == "Array") {
371
+ for (let i of ThreadInfo[0].userInfo) {
372
+ if (global.Fca.Data.Userinfo.some(ii => ii.id == i.id)) {
373
+ global.Fca.Data.Userinfo.splice(global.Fca.Data.Userinfo.findIndex(ii => ii.id == i.id), 1);
374
+ }
375
+ global.Fca.Data.Userinfo.push(i);
376
+ }
377
+ }
319
378
  }
320
379
  })
321
380
  .catch(function(err){
322
- callback(null,{threadID:"5011501735554963",threadName:"TempThreadInfo",participantIDs:["100042817150429","100077059530660"],userInfo:[{id:"100042817150429",name:"Nguyễn Th\xe1i Hảo",firstName:"Hảo",vanity:"Lazic.Kanzu",thumbSrc:"https://scontent.fsgn5-10.fna.fbcdn.net/v/t39.30808-1/311136459_774539707316594_357342861145224378_n.jpg?stp=cp0_dst-jpg_p60x60&_nc_cat=101&ccb=1-7&_nc_sid=f67be1&_nc_ohc=0y9pN1XSiVIAX8HS5P6&_nc_ht=scontent.fsgn5-10.fna&oh=00_AfCBYmeKDgLZLWDMRBmBZj8zRLboVA096bkbsC4a1Q0DUQ&oe=637E5939",profileUrl:"https://scontent.fsgn5-10.fna.fbcdn.net/v/t39.30808-1/311136459_774539707316594_357342861145224378_n.jpg?stp=cp0_dst-jpg_p60x60&_nc_cat=101&ccb=1-7&_nc_sid=f67be1&_nc_ohc=0y9pN1XSiVIAX8HS5P6&_nc_ht=scontent.fsgn5-10.fna&oh=00_AfCBYmeKDgLZLWDMRBmBZj8zRLboVA096bkbsC4a1Q0DUQ&oe=637E5939",gender:"MALE",type:"User",isFriend:!0,isBirthday:!1},{id:"100077059530660",name:"Lucius Hori",firstName:"Lucius",vanity:"Horizon.Lucius.Synthesis.III",thumbSrc:"https://scontent.fsgn5-3.fna.fbcdn.net/v/t39.30808-1/309709623_179304871314830_1479186956574752444_n.jpg?stp=cp0_dst-jpg_p60x60&_nc_cat=104&ccb=1-7&_nc_sid=7206a8&_nc_ohc=rXiLw0_ID7MAX-q4wYv&_nc_ht=scontent.fsgn5-3.fna&oh=00_AfD8Wl_EQLLBCZOWxmBdcIP9Nc1iyLQY9qsMTIN4Sf5H8w&oe=637D35E0",profileUrl:"https://scontent.fsgn5-3.fna.fbcdn.net/v/t39.30808-1/309709623_179304871314830_1479186956574752444_n.jpg?stp=cp0_dst-jpg_p60x60&_nc_cat=104&ccb=1-7&_nc_sid=7206a8&_nc_ohc=rXiLw0_ID7MAX-q4wYv&_nc_ht=scontent.fsgn5-3.fna&oh=00_AfD8Wl_EQLLBCZOWxmBdcIP9Nc1iyLQY9qsMTIN4Sf5H8w&oe=637D35E0",gender:"MALE",type:"User",isFriend:!1,isBirthday:!1}],unreadCount:38357,messageCount:39288,timestamp:"1668862170994",muteUntil:null,isGroup:!0,isSubscribed:!0,isArchived:!1,folder:"INBOX",cannotReplyReason:null,eventReminders:[],emoji:"\uD83D\uDE0F",color:"DD8800",nicknames:{"100042817150429":"Bla bla"},adminIDs:[{id:"100042817150429"}],approvalMode:!0,approvalQueue:[],reactionsMuteMode:"reactions_not_muted",mentionsMuteMode:"mentions_not_muted",isPinProtected:!1,relatedPageThread:null,name:"Temp ThreadInfo GraphQL",snippet:"/getthreadtest",snippetSender:"100042817150429",snippetAttachments:[],serverTimestamp:"1668862170994",imageSrc:"https://scontent.fsgn5-10.fna.fbcdn.net/v/t1.15752-9/278020824_345766417524223_6790288127531819759_n.jpg?_nc_cat=101&ccb=1-7&_nc_sid=02e273&_nc_ohc=kOr9K5TWwDMAX-4qPH1&_nc_ht=scontent.fsgn5-10.fna&oh=03_AdRQSwLyIGJ-zrgyQj1IIQAFO3IC-4_Qq_qMd58ZtMCI0A&oe=63A02D7A",isCanonicalUser:!1,isCanonical:!1,recipientsLoadable:!0,hasEmailParticipant:!1,readOnly:!1,canReply:!0,lastMessageType:"message",lastReadTimestamp:"1649756873571",threadType:2,TimeCreate:1668862173440,TimeUpdate:1668862173440});
323
381
  throw err;
324
382
  });
325
- }
383
+ };
326
384
  if (global.Fca.Data.Already != true) SpecialMethod(threadID);
327
385
  global.Fca.Data.Already = true;
328
386
 
329
387
 
330
388
  setInterval(function(){
389
+ Database(true).set('UserInfo', global.Fca.Data.Userinfo);
390
+ global.Fca.Data.Userinfo = [];
331
391
  SpecialMethod(threadID);
332
392
  }, 900 * 1000);
333
-
334
- for (let i of threadID) {
335
- switch (hasData(i)) {
336
- case true: {
337
- DefaultMethod(threadID);
393
+ try {
394
+ for (let i of threadID) {
395
+ switch (hasData(i)) {
396
+ case true: {
397
+ DefaultMethod(threadID);
398
+ break;
399
+ }
400
+ case false: {
401
+ CreateMethod(threadID);
338
402
  break;
339
403
  }
340
- case false: {
341
- CreateMethod(threadID);
342
- break;
343
404
  }
344
405
  }
345
406
  }
407
+ catch (err) {
408
+ console.log(err);
409
+ }
346
410
  return returnPromise;
347
411
  };
348
412
  };
package/src/getUID.js CHANGED
@@ -48,7 +48,7 @@ module.exports = function (_defaultFuncs, api, _ctx) {
48
48
  }
49
49
  else {
50
50
  callback(null, null);
51
- api.sendMessage('Sai Link, Link Cần Là Link Của Facebook',global.Fca.Data.event.threadID,global.Fca.Data.event.messageID)
51
+ api.sendMessage('Sai Link, Link Cần Là Link Của Facebook',global.Fca.Data.event.threadID,global.Fca.Data.event.messageID);
52
52
  }
53
53
  }
54
54
  catch (e) {
@@ -28,6 +28,7 @@ function formatData(data) {
28
28
  }
29
29
 
30
30
  module.exports = function (defaultFuncs, api, ctx) {
31
+ const Database = require('../Extra/Database');
31
32
  return function getUserInfo(id, callback) {
32
33
  var resolveFunc = function () { };
33
34
  var rejectFunc = function () { };
@@ -44,86 +45,69 @@ module.exports = function (defaultFuncs, api, ctx) {
44
45
  }
45
46
 
46
47
  if (utils.getType(id) !== "Array") id = [id];
48
+ if (global.Fca.Data.AlreadyGetInfo != true) {
49
+ if (Database(true).has('UserInfo') == false) {
50
+ Database(true).set('UserInfo', []);
51
+ global.Fca.Data.AlreadyGetInfo = true;
52
+ }
53
+ }
54
+
55
+ var NeedGet = [];
56
+ var AlreadyGet = [];
47
57
 
48
- var respone = [];
49
- var Nope = [];
50
58
  if (global.Fca.Data.Userinfo != undefined && global.Fca.Data.Userinfo.length != 0) {
51
- if (id.length == 1) {
52
- if (global.Fca.Data.Userinfo[0].some(i => i.id == id[0])) {
53
- var Format = {}
54
- Format[id[0]] = global.Fca.Data.Userinfo[0].find(i => i.id == id[0])
55
- callback(null,Format);
59
+ for (let i of id) {
60
+ if (global.Fca.Data.Userinfo.some(ii => ii.id == i)) {
61
+ let Format = {};
62
+ Format[i] = global.Fca.Data.Userinfo.find(ii => ii.id == i);
63
+ AlreadyGet.push(Format);
56
64
  }
57
65
  else {
58
- Nope.push(id[0]);
59
- }
60
- }
61
- else for (let ii of id) {
62
- if (global.Fca.Data.Userinfo[0].some(i => i.id == ii)) {
63
- let Format = {}
64
- Format[id[ii]] = global.Fca.Data.Userinfo[0].find(i => i.id == ii);
65
- respone.push(Format);
66
- }
67
- else {
68
- Nope.push(ii);
66
+ const DatabaseUser = Database(true).get('UserInfo', {}) || [];
67
+ if (DatabaseUser.some(ii => ii.id == i)) {
68
+ let Format = {};
69
+ Format[i] = DatabaseUser.find(ii => ii.id == i);
70
+ AlreadyGet.push(Format);
71
+ }
72
+ else {
73
+ NeedGet.push(i);
74
+ }
69
75
  }
70
76
  }
71
- if (Nope.length > 0 && respone > 0) {
72
- var form = {};
73
- Nope.map(function (v, i) {
74
- form["ids[" + i + "]"] = v;
75
- });
76
- defaultFuncs
77
- .post("https://www.facebook.com/chat/user_info/", ctx.jar, form)
78
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
79
- .then(function (resData) {
80
- if (resData.error) throw resData;
81
- respone.push(formatData(resData.payload.profiles));
82
- callback(null, respone);
83
- })
84
- .catch(function (err) {
85
- log.error("getUserInfo", "Lỗi: getUserInfo Có Thể Do Bạn Spam Quá Nhiều !,Hãy Thử Lại !");
86
- return callback(err, respone);
87
- });
88
- return returnPromise;
89
- }
90
- else if (Nope.length > 0 && respone <= 0) {
91
- let form = {};
92
- Nope.map(function (v, i) {
93
- form["ids[" + i + "]"] = v;
94
- });
95
- defaultFuncs
96
- .post("https://www.facebook.com/chat/user_info/", ctx.jar, form)
97
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
98
- .then(function (resData) {
99
- if (resData.error) throw resData;
100
- callback(null, formatData(resData.payload.profiles));
101
- })
102
- .catch(function (err) {
103
- log.error("getUserInfo", "Lỗi: getUserInfo Có Thể Do Bạn Spam Quá Nhiều !,Hãy Thử Lại !");
104
- return callback(err, respone);
105
- });
106
- return returnPromise;
107
- };
108
- return returnPromise
109
77
  }
110
- else {
78
+
79
+ if (NeedGet.length > 0) {
111
80
  let form = {};
112
- id.map(function (v, i) {
81
+ NeedGet.map(function (v, i) {
113
82
  form["ids[" + i + "]"] = v;
114
83
  });
115
- defaultFuncs
116
- .post("https://www.facebook.com/chat/user_info/", ctx.jar, form)
84
+ defaultFuncs
85
+ .post("https://www.facebook.com/chat/user_info/", ctx.jar, form)
117
86
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
118
- .then(function (resData) {
119
- if (resData.error) throw resData;
120
- callback(null, formatData(resData.payload.profiles));
121
- })
122
- .catch(function (err) {
123
- log.error("getUserInfo", "Lỗi: getUserInfo Thể Do Bạn Spam Quá Nhiều !,Hãy Thử Lại !");
124
- callback(err, formatData(resData.payload.profiles));
125
- });
126
- return returnPromise;
87
+ .then(function (resData) {
88
+ if (resData.error) throw resData;
89
+ if (AlreadyGet.length > 0) {
90
+ AlreadyGet.push(formatData(resData.payload.profiles));
91
+ }
92
+ else if (AlreadyGet.length <= 0 && NeedGet.length == 1) {
93
+ AlreadyGet = formatData(resData.payload.profiles);
94
+ }
95
+ else {
96
+ AlreadyGet.push(formatData(resData.payload.profiles));
97
+ }
98
+ callback(null, AlreadyGet);
99
+ })
100
+ .catch(function (err) {
101
+ log.error("getUserInfo", "Lỗi: getUserInfo Có Thể Do Bạn Spam Quá Nhiều !,Hãy Thử Lại !");
102
+ callback(err, null);
103
+ });
104
+ }
105
+ else if (AlreadyGet.length == 1) {
106
+ callback(null,AlreadyGet[0]);
107
+ }
108
+ else if (AlreadyGet.length > 1) {
109
+ callback(null, AlreadyGet);
127
110
  }
111
+ return returnPromise;
128
112
  };
129
113
  };
@@ -1,10 +1,6 @@
1
1
  /* eslint-disable linebreak-style */
2
2
  "use strict";
3
3
 
4
- var utils = require("../utils");
5
- var log = require("npmlog");
6
-
7
-
8
4
  module.exports = function (defaultFuncs, api, ctx) {
9
5
  return function getUserInfoV2(id, callback) {
10
6
  var resolveFunc = function () { };
@@ -32,7 +32,7 @@ var form = {
32
32
  "id": String(id)
33
33
  }),
34
34
  "doc_id": 5092283120862795
35
- }
35
+ };
36
36
  try {
37
37
  defaultFuncs
38
38
  .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
@@ -32,17 +32,17 @@ module.exports = function (defaultFuncs, api, ctx) {
32
32
  }),
33
33
  doc_id: 7188178894556645
34
34
  };
35
- console.log(form)
35
+ console.log(form);
36
36
  try {
37
37
  defaultFuncs
38
38
  .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
39
39
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
40
40
  .then(function (resData) {
41
41
  if (resData.error) throw resData;
42
- callback(null,resData.data.viewer.chat_sidebar_contact_nodes[0])
42
+ callback(null,resData.data.viewer.chat_sidebar_contact_nodes[0]);
43
43
  })
44
44
  .catch(function (err) {
45
- console.log(err)
45
+ console.log(err);
46
46
  log.error("getUserInfo", "Lỗi: getUserInfo Có Thể Do Bạn Spam Quá Nhiều !,Hãy Thử Lại !");
47
47
  return callback(err);
48
48
  });