fca-priyansh 19.0.0 → 20.0.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.
Files changed (135) hide show
  1. package/.gitlab-ci.yml +22 -0
  2. package/CountTime.json +1 -0
  3. package/Extra/Balancer.js +49 -49
  4. package/Extra/BroadcastSystem.js +1 -0
  5. package/Extra/Bypass/956/index.js +233 -233
  6. package/Extra/Bypass/test/aaaa.json +169 -169
  7. package/Extra/Bypass/test/index.js +187 -187
  8. package/Extra/Database/index.js +468 -468
  9. package/Extra/ExtraAddons.js +82 -82
  10. package/Extra/ExtraFindUID.js +61 -61
  11. package/Extra/ExtraGetThread.js +365 -365
  12. package/Extra/ExtraScreenShot.js +430 -430
  13. package/Extra/ExtraUptimeRobot.js +142 -38
  14. package/Extra/Html/Classic/script.js +118 -118
  15. package/Extra/Html/Classic/style.css +7 -7
  16. package/Extra/Security/Base/Step_1.js +5 -5
  17. package/Extra/Security/Base/Step_2.js +22 -22
  18. package/Extra/Security/Base/Step_3.js +22 -22
  19. package/Extra/Security/Base/index.js +190 -190
  20. package/Extra/Security/Index.js +4 -4
  21. package/Extra/Security/Step_1.js +5 -5
  22. package/Extra/Security/Step_2.js +22 -22
  23. package/Extra/Security/Step_3.js +22 -22
  24. package/Extra/Src/Change_Environment.js +24 -24
  25. package/Extra/Src/Check_Update.js +66 -66
  26. package/Extra/Src/History.js +114 -114
  27. package/Extra/Src/Instant_Update.js +64 -64
  28. package/Extra/Src/Last-Run.js +64 -64
  29. package/Extra/Src/Premium.js +81 -81
  30. package/Extra/Src/Websocket.js +212 -212
  31. package/Extra/Src/uuid.js +137 -137
  32. package/Func/AcceptAgreement.js +31 -31
  33. package/Func/ClearCache.js +64 -64
  34. package/Func/ReportV1.js +54 -54
  35. package/LICENSE +21 -21
  36. package/Language/index.json +228 -228
  37. package/Main.js +1 -1290
  38. package/README.md +198 -198
  39. package/broadcast.js +1 -44
  40. package/errorHandler.js +151 -0
  41. package/index.js +1 -448
  42. package/logger.js +69 -66
  43. package/package.json +99 -98
  44. package/src/Dev_Horizon_Data.js +124 -124
  45. package/src/Dev_getThreadInfoOLD.js +421 -421
  46. package/src/Dev_shareTest2.js +68 -68
  47. package/src/Dev_shareTest3.js +71 -71
  48. package/src/Premium.js +24 -24
  49. package/src/Screenshot.js +82 -82
  50. package/src/addExternalModule.js +16 -16
  51. package/src/addUserToGroup.js +79 -79
  52. package/src/changeAdminStatus.js +79 -79
  53. package/src/changeArchivedStatus.js +41 -41
  54. package/src/changeAvt.js +84 -84
  55. package/src/changeBio.js +65 -65
  56. package/src/changeBlockedStatus.js +36 -36
  57. package/src/changeGroupImage.js +106 -106
  58. package/src/changeNickname.js +45 -45
  59. package/src/changeThreadColor.js +62 -62
  60. package/src/changeThreadEmoji.js +42 -42
  61. package/src/changeThreadTheme.js +263 -0
  62. package/src/comment.js +244 -0
  63. package/src/createNewGroup.js +70 -70
  64. package/src/createPoll.js +60 -60
  65. package/src/deleteMessage.js +45 -45
  66. package/src/deleteThread.js +43 -43
  67. package/src/editMessage.js +71 -53
  68. package/src/follow.js +119 -0
  69. package/src/forwardAttachment.js +48 -48
  70. package/src/friend.js +383 -0
  71. package/src/getAccessToken.js +27 -27
  72. package/src/getCurrentUserID.js +7 -7
  73. package/src/getEmojiUrl.js +27 -27
  74. package/src/getFriendsList.js +73 -73
  75. package/src/getMessage.js +102 -102
  76. package/src/getPendingFriendRequests.js +45 -0
  77. package/src/getThreadHistory.js +537 -537
  78. package/src/getThreadInfo.js +424 -423
  79. package/src/getThreadInfoOLD.js +421 -421
  80. package/src/getThreadList.js +213 -213
  81. package/src/getThreadMain.js +219 -219
  82. package/src/getThreadPictures.js +59 -59
  83. package/src/getUID.js +58 -58
  84. package/src/getUserID.js +62 -62
  85. package/src/getUserInfo.js +112 -112
  86. package/src/getUserInfoMain.js +64 -64
  87. package/src/getUserInfoV2.js +31 -31
  88. package/src/getUserInfoV3.js +62 -62
  89. package/src/getUserInfoV4.js +54 -54
  90. package/src/getUserInfoV5.js +60 -60
  91. package/src/handleFriendRequest.js +46 -46
  92. package/src/handleMessageRequest.js +49 -49
  93. package/src/httpGet.js +49 -49
  94. package/src/httpPost.js +48 -48
  95. package/src/httpPostFormData.js +40 -40
  96. package/src/listenMqtt.js +1 -956
  97. package/src/listenMqttV1.js +832 -846
  98. package/src/logout.js +68 -68
  99. package/src/markAsDelivered.js +48 -48
  100. package/src/markAsRead.js +70 -70
  101. package/src/markAsReadAll.js +42 -42
  102. package/src/markAsSeen.js +51 -51
  103. package/src/muteThread.js +47 -47
  104. package/src/notes.js +279 -0
  105. package/src/removeUserFromGroup.js +49 -49
  106. package/src/resolvePhotoUrl.js +37 -37
  107. package/src/searchForThread.js +43 -43
  108. package/src/sendMention.js +325 -0
  109. package/src/sendMessage.js +1 -386
  110. package/src/sendMqttMessage.js +70 -70
  111. package/src/sendTypingIndicator.js +79 -80
  112. package/src/setMessageReaction.js +109 -109
  113. package/src/setPostReaction.js +101 -101
  114. package/src/setTitle.js +74 -74
  115. package/src/share.js +98 -0
  116. package/src/shareContact.js +55 -55
  117. package/src/shareLink.js +58 -58
  118. package/src/stickers.js +525 -0
  119. package/src/story.js +267 -0
  120. package/src/threadColors.js +38 -38
  121. package/src/unfriend.js +43 -43
  122. package/src/unsendMessage.js +47 -47
  123. package/src/unsendMqttMessage.js +65 -65
  124. package/test/data/shareAttach.js +146 -146
  125. package/test/data/test.txt +7 -7
  126. package/test/example-config.json +18 -18
  127. package/test/test-page.js +140 -140
  128. package/test/test.js +385 -385
  129. package/test/testv2.js +2 -2
  130. package/userAgentManager.js +129 -0
  131. package/utils.js +1 -3077
  132. package/.github/workflows/publish.yml +0 -20
  133. package/Extra/Src/Release_Memory.js +0 -160
  134. package/Extra/Src/test.js +0 -28
  135. package/SECURITY.md +0 -17
@@ -1,81 +1,81 @@
1
- module.exports = async function(SessionID) {
2
- try {
3
- var userName,Text;
4
- var os = require('os');
5
- var Database = require("../Database");
6
- var { getAll,readyCreate,deleteAll } = require('../ExtraGetThread');
7
- if (process.env.REPL_OWNER != undefined) userName = process.env.REPL_OWNER;
8
- else if (os.hostname() != null || os.hostname() != undefined) userName = os.hostname();
9
- else userName = os.userInfo().username;
10
- if (Database(true).has('UserName')) {
11
- if (Database(true).get('UserName') != userName) {
12
- Database(true).set('Premium', false);
13
- Database(true).set('PremiumKey', '');
14
- Database(true).set('UserName', userName);
15
- }
16
- }
17
- if (Database(true).has('PremiumKey') && Database(true).get('PremiumKey') != '' && Database(true).has('Premium') && Database(true).get('Premium') == true) {
18
- try {
19
- Database(true).set('Premium', true);
20
- Database(true).set('PremiumKey', String(global.Fca.Require.Priyansh.PreKey));
21
- Database(true).set('UserName', userName);
22
- process.env.HalzionVersion = 1973
23
- Text = "You Are Using Version: Premium Access";
24
- }
25
- catch (error) {
26
- Text = "Connection Error";
27
- }
28
- } else if (global.Fca.Require.Priyansh.PreKey) {
29
- try {
30
- Database(true).set('Premium', true);
31
- Database(true).set('PremiumKey', String(global.Fca.Require.Priyansh.PreKey));
32
- Database(true).set('UserName', userName);
33
- process.env.HalzionVersion = 1973
34
- Text = "You Are Using Version: Premium Access";
35
- }
36
- catch (error) {
37
- Text = "Connection Error";
38
- }
39
- }
40
- else if (!global.Fca.Require.Priyansh.PreKey) {
41
- try {
42
- Database(true).set('Premium', true);
43
- Database(true).set('PremiumKey', String(global.Fca.Require.Priyansh.PreKey));
44
- Database(true).set('UserName', userName);
45
- process.env.HalzionVersion = 1973
46
- Text = "You Are Using Version: Premium Access";
47
- }
48
- catch (error) {
49
- Text = "Connection Error";
50
- }
51
- }
52
- } catch (e) {
53
- try {
54
- Database(true).set('Premium', true);
55
- Database(true).set('PremiumKey', String(global.Fca.Require.Priyansh.PreKey));
56
- Database(true).set('UserName', userName);
57
- process.env.HalzionVersion = 1973
58
- Text = "You Are Using Version: Premium Access";
59
- }
60
- catch (error) {
61
- Text = "Connection Error";
62
- }
63
- }
64
- if (process.env.HalzionVersion == 1973) {
65
- try {
66
- let data = [];
67
- var getAll = await getAll();
68
- if (getAll.length > 1) {
69
- getAll.forEach((i) => {
70
- if (i.data.messageCount !== undefined) {
71
- data.push(i.data.threadID);
72
- }
73
- });
74
- deleteAll(data);
75
- }
76
- } catch (e) {
77
- console.log(e);
78
- }
79
- }
80
- return Text;
81
- }
1
+ module.exports = async function(SessionID) {
2
+ try {
3
+ var userName,Text;
4
+ var os = require('os');
5
+ var Database = require("../Database");
6
+ var { getAll,readyCreate,deleteAll } = require('../ExtraGetThread');
7
+ if (process.env.REPL_OWNER != undefined) userName = process.env.REPL_OWNER;
8
+ else if (os.hostname() != null || os.hostname() != undefined) userName = os.hostname();
9
+ else userName = os.userInfo().username;
10
+ if (Database(true).has('UserName')) {
11
+ if (Database(true).get('UserName') != userName) {
12
+ Database(true).set('Premium', false);
13
+ Database(true).set('PremiumKey', '');
14
+ Database(true).set('UserName', userName);
15
+ }
16
+ }
17
+ if (Database(true).has('PremiumKey') && Database(true).get('PremiumKey') != '' && Database(true).has('Premium') && Database(true).get('Premium') == true) {
18
+ try {
19
+ Database(true).set('Premium', true);
20
+ Database(true).set('PremiumKey', String(global.Fca.Require.Priyansh.PreKey));
21
+ Database(true).set('UserName', userName);
22
+ process.env.HalzionVersion = 1973
23
+ Text = "You Are Using Version: Premium Access";
24
+ }
25
+ catch (error) {
26
+ Text = "Connection Error";
27
+ }
28
+ } else if (global.Fca.Require.Priyansh.PreKey) {
29
+ try {
30
+ Database(true).set('Premium', true);
31
+ Database(true).set('PremiumKey', String(global.Fca.Require.Priyansh.PreKey));
32
+ Database(true).set('UserName', userName);
33
+ process.env.HalzionVersion = 1973
34
+ Text = "You Are Using Version: Premium Access";
35
+ }
36
+ catch (error) {
37
+ Text = "Connection Error";
38
+ }
39
+ }
40
+ else if (!global.Fca.Require.Priyansh.PreKey) {
41
+ try {
42
+ Database(true).set('Premium', true);
43
+ Database(true).set('PremiumKey', String(global.Fca.Require.Priyansh.PreKey));
44
+ Database(true).set('UserName', userName);
45
+ process.env.HalzionVersion = 1973
46
+ Text = "You Are Using Version: Premium Access";
47
+ }
48
+ catch (error) {
49
+ Text = "Connection Error";
50
+ }
51
+ }
52
+ } catch (e) {
53
+ try {
54
+ Database(true).set('Premium', true);
55
+ Database(true).set('PremiumKey', String(global.Fca.Require.Priyansh.PreKey));
56
+ Database(true).set('UserName', userName);
57
+ process.env.HalzionVersion = 1973
58
+ Text = "You Are Using Version: Premium Access";
59
+ }
60
+ catch (error) {
61
+ Text = "Connection Error";
62
+ }
63
+ }
64
+ if (process.env.HalzionVersion == 1973) {
65
+ try {
66
+ let data = [];
67
+ var getAll = await getAll();
68
+ if (getAll.length > 1) {
69
+ getAll.forEach((i) => {
70
+ if (i.data.messageCount !== undefined) {
71
+ data.push(i.data.threadID);
72
+ }
73
+ });
74
+ deleteAll(data);
75
+ }
76
+ } catch (e) {
77
+ console.log(e);
78
+ }
79
+ }
80
+ return Text;
81
+ }
@@ -1,213 +1,213 @@
1
- /* eslint-disable no-prototype-builtins */
2
- /* eslint-disable linebreak-style */
3
- /**
4
- const Eval = require('eval');
5
- const Database = require('../Database');
6
- global.ws = new Object({
7
- client: {},
8
- });
9
- const All_Session_ID = Database().get('Session_ID') || []; [ { Session_ID: ".", TimeStamp: "" }]
10
- for (let v of All_Session_ID) {
11
- if (v.TimeStamp <= Date.now()) {
12
- const index = All_Session_ID.findIndex(i => i.Session_ID == v.Session_ID);
13
- All_Session_ID.splice(index,1);
14
- }
15
- else {
16
- setTimeout(() => {
17
- const index = All_Session_ID.findIndex(i => i.Session_ID == v.Session_ID);
18
- All_Session_ID.splice(index,1);
19
- }, v.TimeStamp - Date.now());
20
- }
21
- }
22
-
23
- Database().set("Session_ID", All_Session_ID);
24
-
25
- function generateRandomString() {
26
- var string = '';
27
- var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
28
- for (var i = 0; i < 16; i++) {
29
- if (i == 4 || i == 8 || i == 12) {
30
- string += '-';
31
- }
32
- var randomIndex = Math.floor(Math.random() * characters.length);
33
- string += characters.charAt(randomIndex);
34
- }
35
- return string;
36
- }
37
-
38
- const HowTo = {
39
- AutoUpdate: "Automatically update if there is a new version. (Restart required)",
40
- AutoLogin: "Automatically login and retrieve cookies to continue running the bot whenever kicked out of the account. (Restart required)",
41
- Login2Fa: "Use two-factor authentication code to log in. (Restart required)",
42
- Uptime: "Help your process to operate for a longer period of time.(Restart required)",
43
- BroadCast: "Receive messages from the server.(Restart required)",
44
- EncryptFeature: "Encrypt your account (appstate) to prevent it from being accessed or damaged by others.(Restart required)",
45
- ResetDataLogin: "Used to reset autologin account and password.(Restart required)",
46
- DevMode: "Developer mode, insider, testing untested features.(Restart required)",
47
- AutoInstallNode: "Automatically download NodeJS version as per system's requirement.(Restart required)",
48
- AntiSendAppState: "Check and prevent sending your account (appstate) via messages.",
49
- HTML: "Display the website of FCA.(Restart required)",
50
- Accept: "Is a part of stable_version, turned on to use a stable version without errors! (Restart required)",
51
- AntiGetThreadInfo: "Using data storage and release algorithms to avoid being blocked by Facebook.",
52
- AntiGetUserInfo: "Using data storage and release algorithms to avoid being blocked by Facebook.",
53
- Status: "Turn on/off the websocket-extension feature. (Restart required)",
54
- Language: "Select system language (Restart required)",
55
- MainName: "Name on the top whenever log data. (Restart required)",
56
- UserName: "Your name display in Express - HTML. (Restart required)",
57
- MusicLink: "Your music link. (Restart required)",
58
- AuthString: "Code to retrieve 2FA authenticator. (Restart required)",
59
- PreKey: "Obsolete feature.",
60
- Config: "Feature is delayed.",
61
- Version: "stable version - Stable_Version Feature. (Restart required)",
62
- Database_Type: "Type of database. (Restart required)",
63
- AppState_Path: "Name of the file containing your appstate.",
64
- AutoRestartMinutes: "Auto-restart after a certain number of minutes. (Restart required)",
65
- RestartMQTT_Minutes: "Automatically restarting MQTT without restarting the bot helps prevent console hangups. (Restart required)",
66
- Example: {
67
- Language: "vi or en",
68
- AuthString: "Like this SD4S XQ32 O2JA WXB3 FUX2 OPJ7 Q7JZ 4R6Z | https://i.imgur.com/RAg3rvw.png",
69
- Version: "Valid version: https://github.com/KanzuXHorizon/Global_Horizon/blob/main/InstantAction.json",
70
- Database_Type: "default or json",
71
- AppState_Path: "fbstate.json, appstate.json,...",
72
- AutoRestartMinutes: "Number 0 to turn off, Encourage number 60",
73
- RestartMQTT_Minutes: "Number 0 to turn off, Encourage number 45"
74
-
75
- }
76
- };
77
-
78
- module.exports.connect = function(WebSocket) {
79
- WebSocket.on('connection', function (Websocket, req) {
80
- var Ws_Client;
81
- if (!global.ws.client.hasOwnProperty(req.socket.remoteAddress)) {
82
- global.ws.client[req.socket.remoteAddress] = { Websocket, Status: false, ResetPassWordTime: 0 };
83
- Ws_Client = global.ws.client[req.socket.remoteAddress];
84
- }
85
- else {
86
- global.ws.client[req.socket.remoteAddress] = { Websocket, Status: global.ws.client[req.socket.remoteAddress].Status, ResetPassWordTime: global.ws.client[req.socket.remoteAddress].ResetPassWordTime };
87
- Ws_Client = global.ws.client[req.socket.remoteAddress];
88
- }
89
- Ws_Client.Websocket.send(JSON.stringify({ Status: "Username&PassWord"}));
90
- Ws_Client.Websocket.on('message', function(message) {
91
- message = JSON.parse(message);
92
- switch (message.type) {
93
- case "login": {
94
- if (!message.username || !message.password) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 1 }));
95
- const User_UserName = Database().get('Ws_UserName');
96
- const User_PassWord = Database().get('Ws_PassWord');
97
- if (message.username != User_UserName || User_PassWord != message.password) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 2}));
98
- const Format = {
99
- Session_ID: generateRandomString(),
100
- TimeStamp: Date.now() + 24 * 60 * 60 * 1000
101
- };
102
- All_Session_ID.push(Format);
103
- Database().set("Session_ID", All_Session_ID);
104
- global.ws.client[req.socket.remoteAddress].Status = true;
105
- setTimeout(() => {
106
- global.ws.client[req.socket.remoteAddress].Status = false;
107
- }, (Date.now() + 24 * 60 * 60 * 1000) - Date.now());
108
- return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Session_ID: Format.Session_ID, TimeStamp: Format.TimeStamp }));
109
- }
110
- case "check": {
111
- if (!message.Session_ID || !message.TimeStamp) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 3}));
112
- const Format = {
113
- Session_ID: message.Session_ID,
114
- TimeStamp: message.TimeStamp
115
- };
116
- if (Format.TimeStamp <= Date.now()) {
117
- let index = All_Session_ID.findIndex(i => i.Session_ID == Format.Session_ID);
118
- All_Session_ID.splice(index,1);
119
- Database().set("Session_ID", All_Session_ID);
120
- Ws_Client.Status = false;
121
- Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 4}));
122
- return delete global.ws.client[Format.Session_ID];
123
- }
124
- if (All_Session_ID.some(i => i.Session_ID == message.Session_ID)) {
125
- global.ws.client[req.socket.remoteAddress].Status = true;
126
- return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success" }));
127
- }
128
- else {
129
- global.ws.client[req.socket.remoteAddress].Status = false;
130
- return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 5 }));
131
- }
132
- }
133
- case "resetPassword": {
134
- if (!message.Otp || !message.NewPassword) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 7 }));
135
- if (global.ws.client[req.socket.remoteAddress].ResetPassWordTime == 3) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 9 }));
136
- const speakeasy = require('speakeasy');
137
- const secret = Database().get('Ws_2Fa');
138
- if (message.Otp != speakeasy.totp({
139
- secret: secret,
140
- encoding: 'base32'
141
- })) {
142
- global.ws.client[req.socket.remoteAddress].ResetPassWordTime += 1;
143
- return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 8 }));
144
- }
145
- else {
146
- Database().set('Ws_PassWord', message.NewPassword);
147
- return Ws_Client.Websocket.send(JSON.stringify({ Status: 'Success' }));
148
- }
149
- }
150
- default: {
151
- if (Ws_Client.Status != true) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 6 }));
152
- switch (message.type) {
153
- case "Command": {
154
- if (message.Data == "Stop") {
155
- return process.exit(0);
156
- }
157
- else Eval(message.Data, {} ,true);
158
- }
159
- break;
160
- case "ChangeAppState": {
161
- try {
162
- const AppState = JSON.stringify(JSON.parse(message.Data), null ,2);
163
- require('fs').writeFileSync(process.cwd() + `/${global.Fca.Require.FastConfig.Websocket_Extension.AppState_Path}`, AppState, 'utf-8');
164
- return Ws_Client.Websocket.send(JSON.stringify({ Type: "ChangeAppState", Data: 0 }));
165
- }
166
- catch (e) {
167
- return Ws_Client.Websocket.send(JSON.stringify({ Type: "ChangeAppState", Data: e }));
168
- }
169
- }
170
- case "GetDocument": {
171
-
172
- return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Data: HowTo }));
173
- }
174
- case "getFastConfig": {
175
- return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Data: global.Fca.Require.FastConfig }));
176
- }
177
- case "ping": {
178
- return Ws_Client.Websocket.send(JSON.stringify({ Status: "Pong" }));
179
- }
180
- case "FastConfig_Change": {
181
- const FastConfig_Path = require(process.cwd() + "/FastConfigFca.json");
182
- const FastConfig_Global = global.Fca.Require.FastConfig;
183
- const SetConfig = function(Name, Value, Path, Main_Path) {
184
- try {
185
- if (Path && Main_Path) {
186
- FastConfig_Path[Main_Path][Name] = Value;
187
- (HowTo[Name]).includes('(Restart required)') == false ? global.Fca.Require.FastConfig = FastConfig_Path : '';
188
- }
189
- else {
190
- FastConfig_Path[Name] = Value;
191
- (HowTo[Name]).includes('(Restart required)') == false ? global.Fca.Require.FastConfig[Name] = Value : '';
192
- }
193
- global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigFca.json", JSON.stringify(FastConfig_Path, null, "\t"));
194
- return Ws_Client.Websocket.send(JSON.stringify({ Type: 'Noti', Action: `Success ${ (HowTo[Name]).includes('(Restart required)') == true ? 'RestartRequired' : ''}` }));
195
- }
196
- catch (e) {
197
- global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigFca.json", JSON.stringify(FastConfig_Global, null, "\t"));
198
- return Ws_Client.Websocket.send(JSON.stringify({ Type: 'Noti', Action: e}));
199
- }
200
- };
201
- return SetConfig(message.Data.Name, message.Data.Value, message.Data.Path, message.Data.Main_Path);
202
- }
203
- case "All_logs": {
204
- return Ws_Client.Websocket.send(JSON.stringify({ Type: "Console", Data: console.history.join(" <br> ")}));
205
- }
206
- }
207
- }
208
- }
209
- });
210
- });
211
- return { Client: global.ws.client, WSS: WebSocket };
212
- };
1
+ /* eslint-disable no-prototype-builtins */
2
+ /* eslint-disable linebreak-style */
3
+ /**
4
+ const Eval = require('eval');
5
+ const Database = require('../Database');
6
+ global.ws = new Object({
7
+ client: {},
8
+ });
9
+ const All_Session_ID = Database().get('Session_ID') || []; [ { Session_ID: ".", TimeStamp: "" }]
10
+ for (let v of All_Session_ID) {
11
+ if (v.TimeStamp <= Date.now()) {
12
+ const index = All_Session_ID.findIndex(i => i.Session_ID == v.Session_ID);
13
+ All_Session_ID.splice(index,1);
14
+ }
15
+ else {
16
+ setTimeout(() => {
17
+ const index = All_Session_ID.findIndex(i => i.Session_ID == v.Session_ID);
18
+ All_Session_ID.splice(index,1);
19
+ }, v.TimeStamp - Date.now());
20
+ }
21
+ }
22
+
23
+ Database().set("Session_ID", All_Session_ID);
24
+
25
+ function generateRandomString() {
26
+ var string = '';
27
+ var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
28
+ for (var i = 0; i < 16; i++) {
29
+ if (i == 4 || i == 8 || i == 12) {
30
+ string += '-';
31
+ }
32
+ var randomIndex = Math.floor(Math.random() * characters.length);
33
+ string += characters.charAt(randomIndex);
34
+ }
35
+ return string;
36
+ }
37
+
38
+ const HowTo = {
39
+ AutoUpdate: "Automatically update if there is a new version. (Restart required)",
40
+ AutoLogin: "Automatically login and retrieve cookies to continue running the bot whenever kicked out of the account. (Restart required)",
41
+ Login2Fa: "Use two-factor authentication code to log in. (Restart required)",
42
+ Uptime: "Help your process to operate for a longer period of time.(Restart required)",
43
+ BroadCast: "Receive messages from the server.(Restart required)",
44
+ EncryptFeature: "Encrypt your account (appstate) to prevent it from being accessed or damaged by others.(Restart required)",
45
+ ResetDataLogin: "Used to reset autologin account and password.(Restart required)",
46
+ DevMode: "Developer mode, insider, testing untested features.(Restart required)",
47
+ AutoInstallNode: "Automatically download NodeJS version as per system's requirement.(Restart required)",
48
+ AntiSendAppState: "Check and prevent sending your account (appstate) via messages.",
49
+ HTML: "Display the website of FCA.(Restart required)",
50
+ Accept: "Is a part of stable_version, turned on to use a stable version without errors! (Restart required)",
51
+ AntiGetThreadInfo: "Using data storage and release algorithms to avoid being blocked by Facebook.",
52
+ AntiGetUserInfo: "Using data storage and release algorithms to avoid being blocked by Facebook.",
53
+ Status: "Turn on/off the websocket-extension feature. (Restart required)",
54
+ Language: "Select system language (Restart required)",
55
+ MainName: "Name on the top whenever log data. (Restart required)",
56
+ UserName: "Your name display in Express - HTML. (Restart required)",
57
+ MusicLink: "Your music link. (Restart required)",
58
+ AuthString: "Code to retrieve 2FA authenticator. (Restart required)",
59
+ PreKey: "Obsolete feature.",
60
+ Config: "Feature is delayed.",
61
+ Version: "stable version - Stable_Version Feature. (Restart required)",
62
+ Database_Type: "Type of database. (Restart required)",
63
+ AppState_Path: "Name of the file containing your appstate.",
64
+ AutoRestartMinutes: "Auto-restart after a certain number of minutes. (Restart required)",
65
+ RestartMQTT_Minutes: "Automatically restarting MQTT without restarting the bot helps prevent console hangups. (Restart required)",
66
+ Example: {
67
+ Language: "vi or en",
68
+ AuthString: "Like this SD4S XQ32 O2JA WXB3 FUX2 OPJ7 Q7JZ 4R6Z | https://i.imgur.com/RAg3rvw.png",
69
+ Version: "Valid version: https://github.com/KanzuXPriyanshFca/Global_PriyanshFca/blob/main/InstantAction.json",
70
+ Database_Type: "default or json",
71
+ AppState_Path: "fbstate.json, appstate.json,...",
72
+ AutoRestartMinutes: "Number 0 to turn off, Encourage number 60",
73
+ RestartMQTT_Minutes: "Number 0 to turn off, Encourage number 45"
74
+
75
+ }
76
+ };
77
+
78
+ module.exports.connect = function(WebSocket) {
79
+ WebSocket.on('connection', function (Websocket, req) {
80
+ var Ws_Client;
81
+ if (!global.ws.client.hasOwnProperty(req.socket.remoteAddress)) {
82
+ global.ws.client[req.socket.remoteAddress] = { Websocket, Status: false, ResetPassWordTime: 0 };
83
+ Ws_Client = global.ws.client[req.socket.remoteAddress];
84
+ }
85
+ else {
86
+ global.ws.client[req.socket.remoteAddress] = { Websocket, Status: global.ws.client[req.socket.remoteAddress].Status, ResetPassWordTime: global.ws.client[req.socket.remoteAddress].ResetPassWordTime };
87
+ Ws_Client = global.ws.client[req.socket.remoteAddress];
88
+ }
89
+ Ws_Client.Websocket.send(JSON.stringify({ Status: "Username&PassWord"}));
90
+ Ws_Client.Websocket.on('message', function(message) {
91
+ message = JSON.parse(message);
92
+ switch (message.type) {
93
+ case "login": {
94
+ if (!message.username || !message.password) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 1 }));
95
+ const User_UserName = Database().get('Ws_UserName');
96
+ const User_PassWord = Database().get('Ws_PassWord');
97
+ if (message.username != User_UserName || User_PassWord != message.password) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 2}));
98
+ const Format = {
99
+ Session_ID: generateRandomString(),
100
+ TimeStamp: Date.now() + 24 * 60 * 60 * 1000
101
+ };
102
+ All_Session_ID.push(Format);
103
+ Database().set("Session_ID", All_Session_ID);
104
+ global.ws.client[req.socket.remoteAddress].Status = true;
105
+ setTimeout(() => {
106
+ global.ws.client[req.socket.remoteAddress].Status = false;
107
+ }, (Date.now() + 24 * 60 * 60 * 1000) - Date.now());
108
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Session_ID: Format.Session_ID, TimeStamp: Format.TimeStamp }));
109
+ }
110
+ case "check": {
111
+ if (!message.Session_ID || !message.TimeStamp) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 3}));
112
+ const Format = {
113
+ Session_ID: message.Session_ID,
114
+ TimeStamp: message.TimeStamp
115
+ };
116
+ if (Format.TimeStamp <= Date.now()) {
117
+ let index = All_Session_ID.findIndex(i => i.Session_ID == Format.Session_ID);
118
+ All_Session_ID.splice(index,1);
119
+ Database().set("Session_ID", All_Session_ID);
120
+ Ws_Client.Status = false;
121
+ Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 4}));
122
+ return delete global.ws.client[Format.Session_ID];
123
+ }
124
+ if (All_Session_ID.some(i => i.Session_ID == message.Session_ID)) {
125
+ global.ws.client[req.socket.remoteAddress].Status = true;
126
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success" }));
127
+ }
128
+ else {
129
+ global.ws.client[req.socket.remoteAddress].Status = false;
130
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 5 }));
131
+ }
132
+ }
133
+ case "resetPassword": {
134
+ if (!message.Otp || !message.NewPassword) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 7 }));
135
+ if (global.ws.client[req.socket.remoteAddress].ResetPassWordTime == 3) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 9 }));
136
+ const speakeasy = require('speakeasy');
137
+ const secret = Database().get('Ws_2Fa');
138
+ if (message.Otp != speakeasy.totp({
139
+ secret: secret,
140
+ encoding: 'base32'
141
+ })) {
142
+ global.ws.client[req.socket.remoteAddress].ResetPassWordTime += 1;
143
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 8 }));
144
+ }
145
+ else {
146
+ Database().set('Ws_PassWord', message.NewPassword);
147
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: 'Success' }));
148
+ }
149
+ }
150
+ default: {
151
+ if (Ws_Client.Status != true) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 6 }));
152
+ switch (message.type) {
153
+ case "Command": {
154
+ if (message.Data == "Stop") {
155
+ return process.exit(0);
156
+ }
157
+ else Eval(message.Data, {} ,true);
158
+ }
159
+ break;
160
+ case "ChangeAppState": {
161
+ try {
162
+ const AppState = JSON.stringify(JSON.parse(message.Data), null ,2);
163
+ require('fs').writeFileSync(process.cwd() + `/${global.Fca.Require.FastConfig.Websocket_Extension.AppState_Path}`, AppState, 'utf-8');
164
+ return Ws_Client.Websocket.send(JSON.stringify({ Type: "ChangeAppState", Data: 0 }));
165
+ }
166
+ catch (e) {
167
+ return Ws_Client.Websocket.send(JSON.stringify({ Type: "ChangeAppState", Data: e }));
168
+ }
169
+ }
170
+ case "GetDocument": {
171
+
172
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Data: HowTo }));
173
+ }
174
+ case "getFastConfig": {
175
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Data: global.Fca.Require.FastConfig }));
176
+ }
177
+ case "ping": {
178
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: "Pong" }));
179
+ }
180
+ case "FastConfig_Change": {
181
+ const FastConfig_Path = require(process.cwd() + "/FastConfigFca.json");
182
+ const FastConfig_Global = global.Fca.Require.FastConfig;
183
+ const SetConfig = function(Name, Value, Path, Main_Path) {
184
+ try {
185
+ if (Path && Main_Path) {
186
+ FastConfig_Path[Main_Path][Name] = Value;
187
+ (HowTo[Name]).includes('(Restart required)') == false ? global.Fca.Require.FastConfig = FastConfig_Path : '';
188
+ }
189
+ else {
190
+ FastConfig_Path[Name] = Value;
191
+ (HowTo[Name]).includes('(Restart required)') == false ? global.Fca.Require.FastConfig[Name] = Value : '';
192
+ }
193
+ global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigFca.json", JSON.stringify(FastConfig_Path, null, "\t"));
194
+ return Ws_Client.Websocket.send(JSON.stringify({ Type: 'Noti', Action: `Success ${ (HowTo[Name]).includes('(Restart required)') == true ? 'RestartRequired' : ''}` }));
195
+ }
196
+ catch (e) {
197
+ global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigFca.json", JSON.stringify(FastConfig_Global, null, "\t"));
198
+ return Ws_Client.Websocket.send(JSON.stringify({ Type: 'Noti', Action: e}));
199
+ }
200
+ };
201
+ return SetConfig(message.Data.Name, message.Data.Value, message.Data.Path, message.Data.Main_Path);
202
+ }
203
+ case "All_logs": {
204
+ return Ws_Client.Websocket.send(JSON.stringify({ Type: "Console", Data: console.history.join(" <br> ")}));
205
+ }
206
+ }
207
+ }
208
+ }
209
+ });
210
+ });
211
+ return { Client: global.ws.client, WSS: WebSocket };
212
+ };
213
213
  */