fca-shankar-bot 20.2.0 → 20.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/.replit +14 -1
- package/Extra/Balancer.js +49 -0
- package/Extra/ExtraAddons.js +4 -4
- package/Extra/ExtraGetThread.js +27 -27
- package/Extra/ExtraScreenShot.js +3 -3
- package/Extra/ExtraUptimeRobot.js +4 -4
- package/Extra/Src/Change_Environment.js +2 -2
- package/Extra/Src/Check_Update.js +3 -3
- package/Extra/Src/Instant_Update.js +2 -2
- package/Extra/Src/Premium.js +7 -7
- package/Extra/Src/Release_Memory.js +7 -7
- package/Extra/Src/Websocket.js +12 -12
- package/Func/ClearCache.js +2 -2
- package/LICENSE +21 -0
- package/Language/index.json +22 -16
- package/Main.js +515 -349
- package/README.md +198 -0
- package/SECURITY.md +17 -0
- package/broadcast.js +44 -0
- package/index.js +215 -31
- package/logger.js +51 -122
- package/package.json +17 -15
- package/src/Dev_Horizon_Data.js +2 -2
- package/src/editMessage.js +45 -38
- package/src/listenMqtt.js +395 -373
- package/src/listenMqttV1.js +11 -11
- package/src/sendMessage.js +2 -2
- package/src/sendMqttMessage.js +51 -251
- package/src/setMessageReaction.js +64 -66
- package/src/shareContact.js +50 -75
- package/src/unsendMessage.js +32 -126
- package/src/unsendMqttMessage.js +66 -0
- package/test/data/shareAttach.js +146 -0
- package/test/data/something.mov +0 -0
- package/test/data/test.png +0 -0
- package/test/data/test.txt +7 -0
- package/test/example-config.json +18 -0
- package/test/test-page.js +140 -0
- package/test/test.js +385 -0
- package/test/testv2.js +3 -0
- package/utils.js +50 -11
- package/.cache/replit/env/latest +0 -49
- package/.cache/replit/env/latest.json +0 -1
- package/.cache/replit/modules/nodejs-20.res +0 -1
- package/.cache/replit/modules/replit.res +0 -1
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/replit/toolchain.json +0 -1
- package/CountTime.json +0 -1
- package/src/followUser.js +0 -171
- package/src/getFacebookInfo.js +0 -69
- package/src/listenMqtt.jk +0 -732
- package/src/postStory.js +0 -122
- package/src/refreshFb_dtsg.js +0 -81
package/README.md
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
This repo is a fork from main repo and will usually have new features bundled faster than main repo (and maybe bundle some bugs, too).
|
2
|
+
|
3
|
+
# Shankar Facebook Chat API
|
4
|
+
|
5
|
+
Facebook now has an official API for chat bots [here](https://developers.facebook.com/docs/messenger-platform).
|
6
|
+
|
7
|
+
This API is the only way to automate chat functionalities on a user account. We do this by emulating the browser. This means doing the exact same GET/POST requests and tricking Facebook into thinking we're accessing the website normally. Because we're doing it this way, this API won't work with an auth token but requires the credentials of a Facebook account.
|
8
|
+
|
9
|
+
_Disclaimer_: We are not responsible if your account gets banned for spammy activities such as sending lots of messages to people you don't know, sending messages very quickly, sending spammy looking URLs, logging in and out very quickly... Be responsible Facebook citizens.
|
10
|
+
|
11
|
+
See [below](#projects-using-this-api) for projects using this API.
|
12
|
+
|
13
|
+
## Install
|
14
|
+
If you just want to use fca-disme, you should use this command:
|
15
|
+
```bash
|
16
|
+
npm install fca-smart-shankar
|
17
|
+
```
|
18
|
+
It will download `fca-smart-shankar` from NPM repositories
|
19
|
+
|
20
|
+
### Bleeding edge
|
21
|
+
If you want to use bleeding edge (directly from github) to test new features or submit bug report, this is the command for you:
|
22
|
+
```bash
|
23
|
+
npm install fca-smart-shankar
|
24
|
+
```
|
25
|
+
|
26
|
+
## Testing your bots
|
27
|
+
If you want to test your bots without creating another account on Facebook, you can use [Facebook Whitehat Accounts](https://www.facebook.com/whitehat/accounts/).
|
28
|
+
|
29
|
+
## Example Usage
|
30
|
+
```javascript
|
31
|
+
const login = require("fca-smart-shankar");
|
32
|
+
|
33
|
+
// Create simple echo bot
|
34
|
+
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
|
35
|
+
if(err) return console.error(err);
|
36
|
+
|
37
|
+
api.listen((err, message) => {
|
38
|
+
api.sendMessage(message.body, message.threadID);
|
39
|
+
});
|
40
|
+
});
|
41
|
+
```
|
42
|
+
|
43
|
+
Result:
|
44
|
+
|
45
|
+
<img width="517" alt="screen shot 2016-11-04 at 14 36 00" src="https://cloud.githubusercontent.com/assets/4534692/20023545/f8c24130-a29d-11e6-9ef7-47568bdbc1f2.png">
|
46
|
+
|
47
|
+
|
48
|
+
## Documentation
|
49
|
+
|
50
|
+
You can see it [here](DOCS.md).
|
51
|
+
|
52
|
+
## Main Functionality
|
53
|
+
|
54
|
+
### Sending a message
|
55
|
+
#### api.sendMessage(message, threadID[, callback][, messageID])
|
56
|
+
|
57
|
+
Various types of message can be sent:
|
58
|
+
* *Regular:* set field `body` to the desired message as a string.
|
59
|
+
* *Sticker:* set a field `sticker` to the desired sticker ID.
|
60
|
+
* *File or image:* Set field `attachment` to a readable stream or an array of readable streams.
|
61
|
+
* *URL:* set a field `url` to the desired URL.
|
62
|
+
* *Emoji:* set field `emoji` to the desired emoji as a string and set field `emojiSize` with size of the emoji (`small`, `medium`, `large`)
|
63
|
+
|
64
|
+
Note that a message can only be a regular message (which can be empty) and optionally one of the following: a sticker, an attachment or a url.
|
65
|
+
|
66
|
+
__Tip__: to find your own ID, you can look inside the cookies. The `userID` is under the name `c_user`.
|
67
|
+
|
68
|
+
__Example (Basic Message)__
|
69
|
+
```js
|
70
|
+
const login = require("fca-smart-shankar");
|
71
|
+
|
72
|
+
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
|
73
|
+
if(err) return console.error(err);
|
74
|
+
|
75
|
+
var yourID = "000000000000000";
|
76
|
+
var msg = "Hey!";
|
77
|
+
api.sendMessage(msg, yourID);
|
78
|
+
});
|
79
|
+
```
|
80
|
+
|
81
|
+
__Example (File upload)__
|
82
|
+
```js
|
83
|
+
const login = require("fca-smart-shankar");
|
84
|
+
|
85
|
+
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
|
86
|
+
if(err) return console.error(err);
|
87
|
+
|
88
|
+
// Note this example uploads an image called image.jpg
|
89
|
+
var yourID = "000000000000000";
|
90
|
+
var msg = {
|
91
|
+
body: "Hey!",
|
92
|
+
attachment: fs.createReadStream(__dirname + '/image.jpg')
|
93
|
+
}
|
94
|
+
api.sendMessage(msg, yourID);
|
95
|
+
});
|
96
|
+
```
|
97
|
+
|
98
|
+
------------------------------------
|
99
|
+
### Saving session.
|
100
|
+
|
101
|
+
To avoid logging in every time you should save AppState (cookies etc.) to a file, then you can use it without having password in your scripts.
|
102
|
+
|
103
|
+
__Example__
|
104
|
+
|
105
|
+
```js
|
106
|
+
const fs = require("fs");
|
107
|
+
const login = require("fca-smart-shankar");
|
108
|
+
|
109
|
+
var credentials = {email: "FB_EMAIL", password: "FB_PASSWORD"};
|
110
|
+
|
111
|
+
login(credentials, (err, api) => {
|
112
|
+
if(err) return console.error(err);
|
113
|
+
|
114
|
+
fs.writeFileSync('appstate.json', JSON.stringify(api.getAppState()));
|
115
|
+
});
|
116
|
+
```
|
117
|
+
|
118
|
+
Alternative: Use [c3c-fbstate](https://github.com/c3cbot/c3c-fbstate) to get fbstate.json (appstate.json)
|
119
|
+
|
120
|
+
------------------------------------
|
121
|
+
|
122
|
+
### Listening to a chat
|
123
|
+
#### api.listen(callback)
|
124
|
+
|
125
|
+
Listen watches for messages sent in a chat. By default this won't receive events (joining/leaving a chat, title change etc…) but it can be activated with `api.setOptions({listenEvents: true})`. This will by default ignore messages sent by the current account, you can enable listening to your own messages with `api.setOptions({selfListen: true})`.
|
126
|
+
|
127
|
+
__Example__
|
128
|
+
|
129
|
+
```js
|
130
|
+
const fs = require("fs");
|
131
|
+
const login = require("fca-smart-shankar");
|
132
|
+
|
133
|
+
// Simple echo bot. It will repeat everything that you say.
|
134
|
+
// Will stop when you say '/stop'
|
135
|
+
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
136
|
+
if(err) return console.error(err);
|
137
|
+
|
138
|
+
api.setOptions({listenEvents: true});
|
139
|
+
|
140
|
+
var stopListening = api.listenMqtt((err, event) => {
|
141
|
+
if(err) return console.error(err);
|
142
|
+
|
143
|
+
api.markAsRead(event.threadID, (err) => {
|
144
|
+
if(err) console.error(err);
|
145
|
+
});
|
146
|
+
|
147
|
+
switch(event.type) {
|
148
|
+
case "message":
|
149
|
+
if(event.body === '/stop') {
|
150
|
+
api.sendMessage("Goodbye…", event.threadID);
|
151
|
+
return stopListening();
|
152
|
+
}
|
153
|
+
api.sendMessage("TEST BOT: " + event.body, event.threadID);
|
154
|
+
break;
|
155
|
+
case "event":
|
156
|
+
console.log(event);
|
157
|
+
break;
|
158
|
+
}
|
159
|
+
});
|
160
|
+
});
|
161
|
+
```
|
162
|
+
|
163
|
+
## FAQS
|
164
|
+
|
165
|
+
1. How do I run tests?
|
166
|
+
> For tests, create a `test-config.json` file that resembles `example-config.json` and put it in the `test` directory. From the root >directory, run `npm test`.
|
167
|
+
|
168
|
+
2. Why doesn't `sendMessage` always work when I'm logged in as a page?
|
169
|
+
> Pages can't start conversations with users directly; this is to prevent pages from spamming users.
|
170
|
+
|
171
|
+
3. What do I do when `login` doesn't work?
|
172
|
+
> First check that you can login to Facebook using the website. If login approvals are enabled, you might be logging in incorrectly. For how to handle login approvals, read our docs on [`login`](DOCS.md#login).
|
173
|
+
|
174
|
+
4. How can I avoid logging in every time? Can I log into a previous session?
|
175
|
+
> We support caching everything relevant for you to bypass login. `api.getAppState()` returns an object that you can save and pass into login as `{appState: mySavedAppState}` instead of the credentials object. If this fails, your session has expired.
|
176
|
+
|
177
|
+
5. Do you support sending messages as a page?
|
178
|
+
> Yes, set the pageID option on login (this doesn't work if you set it using api.setOptions, it affects the login process).
|
179
|
+
> ```js
|
180
|
+
> login(credentials, {pageID: "000000000000000"}, (err, api) => { … }
|
181
|
+
> ```
|
182
|
+
|
183
|
+
6. I'm getting some crazy weird syntax error like `SyntaxError: Unexpected token [`!!!
|
184
|
+
> Please try to update your version of node.js before submitting an issue of this nature. We like to use new language features.
|
185
|
+
|
186
|
+
7. I don't want all of these logging messages!
|
187
|
+
> You can use `api.setOptions` to silence the logging. You get the `api` object from `login` (see example above). Do
|
188
|
+
> ```js
|
189
|
+
> api.setOptions({
|
190
|
+
> logLevel: "silent"
|
191
|
+
> });
|
192
|
+
> ```
|
193
|
+
|
194
|
+
<a name="projects-using-this-api"></a>
|
195
|
+
## Projects using this API:
|
196
|
+
|
197
|
+
- [c3c](https://github.com/lequanglam/c3c) - A bot that can be customizable using plugins. Support Facebook & Discord.
|
198
|
+
- [SMART-SHANKAR-BOT](https://github.com/SHANKAR-PROJECT/SMART-SHANKAR-BOT) - A simple Facebook Messenger Bot made by Smart Shankar.
|
package/SECURITY.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
+ if have any Vulnerability finded contact: Author(Shankar) or (Facebook.com/Shankar.Suman). Thanks!
|
4
|
+
|
5
|
+
## Supported Versions
|
6
|
+
|
7
|
+
Use this section to tell people about which versions of your project are
|
8
|
+
currently being supported with security updates.
|
9
|
+
|
10
|
+
| Version | Supported |
|
11
|
+
| ------- | ------------------ |
|
12
|
+
| Main Version With Autoupdate | :white_check_mark: |
|
13
|
+
| Old Version | :x:|
|
14
|
+
|
15
|
+
## Reporting a Vulnerability
|
16
|
+
|
17
|
+
Contact Author
|
package/broadcast.js
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const logger = require('./logger');
|
4
|
+
const Fetch = require('got');
|
5
|
+
|
6
|
+
const broadcastConfig = {
|
7
|
+
enabled: false,
|
8
|
+
data: [],
|
9
|
+
};
|
10
|
+
|
11
|
+
const fetchBroadcastData = async () => {
|
12
|
+
try {
|
13
|
+
const response = await Fetch.get('https://raw.githubusercontent.com/SHANKAR-PROJECT/Global_Shankar/main/Fca_BroadCast.json');
|
14
|
+
broadcastConfig.data = JSON.parse(response.body.toString());
|
15
|
+
return broadcastConfig.data;
|
16
|
+
} catch (error) {
|
17
|
+
logger.Error(`Failed to fetch broadcast data: ${error.message}`);
|
18
|
+
broadcastConfig.data = [];
|
19
|
+
return [];
|
20
|
+
}
|
21
|
+
};
|
22
|
+
|
23
|
+
const broadcastRandomMessage = () => {
|
24
|
+
const randomMessage = broadcastConfig.data.length > 0 ? broadcastConfig.data[Math.floor(Math.random() * broadcastConfig.data.length)] : 'Ae Zui Zẻ Nhé !';
|
25
|
+
logger.Normal(randomMessage);
|
26
|
+
};
|
27
|
+
|
28
|
+
const startBroadcasting = async (enabled) => {
|
29
|
+
enabled = global.Fca.Require.Shankar.BroadCast
|
30
|
+
|
31
|
+
if (enabled) {
|
32
|
+
try {
|
33
|
+
await fetchBroadcastData();
|
34
|
+
broadcastRandomMessage();
|
35
|
+
setInterval(broadcastRandomMessage, 3600 * 1000);
|
36
|
+
} catch (error) {
|
37
|
+
logger.Error(`Failed to start broadcasting: ${error.message}`);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
};
|
41
|
+
|
42
|
+
module.exports = {
|
43
|
+
startBroadcasting,
|
44
|
+
};
|
package/index.js
CHANGED
@@ -22,10 +22,10 @@ global.Fca = new Object({
|
|
22
22
|
return Main;
|
23
23
|
},
|
24
24
|
Data: new Object({
|
25
|
-
|
25
|
+
ObjShankar: {
|
26
26
|
"Language": "en",
|
27
|
-
"PreKey": "
|
28
|
-
"AutoUpdate":
|
27
|
+
"PreKey": "",
|
28
|
+
"AutoUpdate": true,
|
29
29
|
"MainColor": "#9900FF",
|
30
30
|
"MainName": "[ FCA-SHANKAR ]",
|
31
31
|
"Uptime": false,
|
@@ -34,27 +34,27 @@ global.Fca = new Object({
|
|
34
34
|
"Login2Fa": false,
|
35
35
|
"AutoLogin": false,
|
36
36
|
"BroadCast": true,
|
37
|
-
"AuthString": "",
|
37
|
+
"AuthString": "SD4S XQ32 O2JA WXB3 FUX2 OPJ7 Q7JZ 4R6Z | https://i.imgur.com/RAg3rvw.png Please remove this !, Recommend If You Using getUserInfoV2",
|
38
38
|
"EncryptFeature": true,
|
39
39
|
"ResetDataLogin": false,
|
40
|
-
"AutoInstallNode":
|
40
|
+
"AutoInstallNode": false,
|
41
41
|
"AntiSendAppState": true,
|
42
42
|
"AutoRestartMinutes": 0,
|
43
|
-
"RestartMQTT_Minutes":
|
43
|
+
"RestartMQTT_Minutes": 0,
|
44
44
|
"Websocket_Extension": {
|
45
45
|
"Status": false,
|
46
46
|
"ResetData": false,
|
47
47
|
"AppState_Path": "appstate.json"
|
48
48
|
},
|
49
49
|
"HTML": {
|
50
|
-
"HTML":
|
51
|
-
"UserName": "
|
52
|
-
"MusicLink": "https://
|
50
|
+
"HTML": true,
|
51
|
+
"UserName": "Guest",
|
52
|
+
"MusicLink": "https://drive.google.com/uc?id=1zlAALlxk1TnO7jXtEP_O6yvemtzA2ukA&export=download"
|
53
53
|
},
|
54
54
|
"AntiGetInfo": {
|
55
55
|
"Database_Type": "default", //json or default
|
56
|
-
"AntiGetThreadInfo":
|
57
|
-
"AntiGetUserInfo":
|
56
|
+
"AntiGetThreadInfo": true,
|
57
|
+
"AntiGetUserInfo": true
|
58
58
|
},
|
59
59
|
"Stable_Version": {
|
60
60
|
"Accept": false,
|
@@ -69,7 +69,7 @@ global.Fca = new Object({
|
|
69
69
|
},
|
70
70
|
"AntiStuckAndMemoryLeak": {
|
71
71
|
"AutoRestart": {
|
72
|
-
"Use":
|
72
|
+
"Use": true,
|
73
73
|
"Explain": "When this feature is turned on, the system will continuously check and confirm that if memory usage reaches 90%, it will automatically restart to avoid freezing or stopping."
|
74
74
|
},
|
75
75
|
"LogFile": {
|
@@ -166,25 +166,25 @@ try {
|
|
166
166
|
let All_Variable = Boolean_Fca.concat(String_Fca,Number_Fca,Object_Fca);
|
167
167
|
|
168
168
|
|
169
|
-
if (!global.Fca.Require.fs.existsSync(process.cwd() + '/
|
170
|
-
global.Fca.Require.fs.writeFileSync(process.cwd() + "/
|
169
|
+
if (!global.Fca.Require.fs.existsSync(process.cwd() + '/ShankarFca.json')) {
|
170
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/ShankarFca.json", JSON.stringify(global.Fca.Data.ObjShankar, null, "\t"));
|
171
171
|
process.exit(1);
|
172
172
|
}
|
173
173
|
|
174
174
|
try {
|
175
|
-
var Data_Setting = require(process.cwd() + "/
|
175
|
+
var Data_Setting = require(process.cwd() + "/ShankarFca.json");
|
176
176
|
}
|
177
177
|
catch (e) {
|
178
|
-
global.Fca.Require.logger.Error('Detect Your
|
179
|
-
global.Fca.Require.fs.writeFileSync(process.cwd() + "/
|
178
|
+
global.Fca.Require.logger.Error('Detect Your ShankarFca Settings Invalid!, Carry out default restoration');
|
179
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/ShankarFca.json", JSON.stringify(global.Fca.Data.ObjShankar, null, "\t"));
|
180
180
|
process.exit(1)
|
181
181
|
}
|
182
|
-
if (global.Fca.Require.fs.existsSync(process.cwd() + '/
|
182
|
+
if (global.Fca.Require.fs.existsSync(process.cwd() + '/ShankarFca.json')) {
|
183
183
|
|
184
184
|
for (let i of All_Variable) {
|
185
185
|
if (Data_Setting[i] == undefined) {
|
186
|
-
Data_Setting[i] = global.Fca.Data.
|
187
|
-
global.Fca.Require.fs.writeFileSync(process.cwd() + "/
|
186
|
+
Data_Setting[i] = global.Fca.Data.ObjShankar[i];
|
187
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/ShankarFca.json", JSON.stringify(Data_Setting, null, "\t"));
|
188
188
|
}
|
189
189
|
else continue;
|
190
190
|
} //Check Variable
|
@@ -204,28 +204,28 @@ catch (e) {
|
|
204
204
|
}
|
205
205
|
else if (Object_Fca.includes(i)) {
|
206
206
|
if (global.Fca.Require.utils.getType(Data_Setting[i]) != "Object") {
|
207
|
-
Data_Setting[i] = global.Fca.Data.
|
208
|
-
global.Fca.Require.fs.writeFileSync(process.cwd() + "/
|
207
|
+
Data_Setting[i] = global.Fca.Data.ObjShankar[i];
|
208
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/ShankarFca.json", JSON.stringify(Data_Setting, null, "\t"));
|
209
209
|
}
|
210
210
|
else continue;
|
211
211
|
}
|
212
212
|
}
|
213
213
|
|
214
214
|
for (let i of Object_Fca) {
|
215
|
-
const All_Paths = utils.getPaths(global.Fca.Data.
|
215
|
+
const All_Paths = utils.getPaths(global.Fca.Data.ObjShankar[i]);
|
216
216
|
const Mission = { Main_Path: i, Data_Path: All_Paths }
|
217
217
|
for (let i of Mission.Data_Path) {
|
218
218
|
if (Data_Setting[Mission.Main_Path] == undefined) {
|
219
|
-
Data_Setting[Mission.Main_Path] = global.Fca.Data.
|
220
|
-
global.Fca.Require.fs.writeFileSync(process.cwd() + "/
|
219
|
+
Data_Setting[Mission.Main_Path] = global.Fca.Data.ObjShankat[Mission.Main_Path];
|
220
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/ShankarFca.json", JSON.stringify(Data_Setting, null, "\t"));
|
221
221
|
}
|
222
222
|
const User_Data = (utils.getData_Path(Data_Setting[Mission.Main_Path], i, 0))
|
223
223
|
const User_Data_Type = utils.getType(User_Data);
|
224
224
|
if (User_Data_Type == "Number") {
|
225
225
|
const Mission_Path = User_Data == 0 ? i : i.slice(0, User_Data);
|
226
|
-
const Mission_Obj = utils.getData_Path(global.Fca.Data.
|
226
|
+
const Mission_Obj = utils.getData_Path(global.Fca.Data.ObjShankar[Mission.Main_Path], Mission_Path, 0);
|
227
227
|
Data_Setting[Mission.Main_Path] = utils.setData_Path(Data_Setting[Mission.Main_Path], Mission_Path, Mission_Obj)
|
228
|
-
global.Fca.Require.fs.writeFileSync(process.cwd() + "/
|
228
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/ShankarFca.json", JSON.stringify(Data_Setting, null, "\t"));
|
229
229
|
}
|
230
230
|
}
|
231
231
|
}
|
@@ -236,15 +236,32 @@ catch (e) {
|
|
236
236
|
}
|
237
237
|
global.Fca.Require.Language = global.Fca.Require.languageFile.find((/** @type {{ Language: string; }} */i) => i.Language == Data_Setting.Language).Folder;
|
238
238
|
} else process.exit(1);
|
239
|
-
global.Fca.Require.
|
239
|
+
global.Fca.Require.Shankar = Data_Setting;
|
240
240
|
}
|
241
241
|
catch (e) {
|
242
242
|
console.log(e);
|
243
243
|
global.Fca.Require.logger.Error();
|
244
244
|
}
|
245
245
|
|
246
|
+
/*
|
247
|
+
if (global.Fca.Require.FastConfig.Websocket_Extension.Status) {
|
248
|
+
console.history = new Array();
|
249
|
+
var Convert = require('ansi-to-html');
|
250
|
+
var convert = new Convert();
|
251
|
+
console.__log = console.log;
|
252
|
+
console.log = function (data) {
|
253
|
+
const log = convert.toHtml(data)
|
254
|
+
console.history.push(log)
|
255
|
+
console.__log.apply(console,arguments)
|
256
|
+
if (console.history.length > 80) {
|
257
|
+
console.history.shift();
|
258
|
+
}
|
259
|
+
}
|
260
|
+
}
|
261
|
+
**/
|
262
|
+
|
246
263
|
module.exports = function(loginData, options, callback) {
|
247
|
-
//const Language = global.Fca.Require.languageFile.find((/** @type {{ Language: string; }} */i) => i.Language == global.Fca.Require.
|
264
|
+
//const Language = global.Fca.Require.languageFile.find((/** @type {{ Language: string; }} */i) => i.Language == global.Fca.Require.FastConfig.Language).Folder.Index;
|
248
265
|
var login;
|
249
266
|
try {
|
250
267
|
login = require('./Main');
|
@@ -252,13 +269,180 @@ module.exports = function(loginData, options, callback) {
|
|
252
269
|
catch (e) {
|
253
270
|
console.log(e)
|
254
271
|
}
|
255
|
-
|
272
|
+
//const fs = require('fs-extra');
|
273
|
+
//const got = require('got');
|
274
|
+
//const log = require('npmlog');
|
275
|
+
//const { execSync } = require('child_process');
|
256
276
|
require('./Extra/Database');
|
277
|
+
|
278
|
+
/*
|
279
|
+
return got.get('https://github.com/KanzuXHorizon/Global_Horizon/raw/main/InstantAction.json').then(async function(res) {
|
280
|
+
if (global.Fca.Require.FastConfig.AutoInstallNode) {
|
281
|
+
switch (fs.existsSync(process.cwd() + "/replit.nix") && process.env["REPL_ID"] != undefined) {
|
282
|
+
case true: {
|
283
|
+
await require('./Extra/Src/Change_Environment.js')();
|
284
|
+
break;
|
285
|
+
}
|
286
|
+
case false: {
|
287
|
+
const NodeVersion = execSync('node -v').toString().replace(/(\r\n|\n|\r)/gm, "");
|
288
|
+
if (!NodeVersion.includes("v14") && !NodeVersion.includes("v16") && !Database(true).has('SkipReplitNix')) {
|
289
|
+
log.warn("[ FCA-UPDATE ] •",global.Fca.getText(Language.NodeVersionNotSupported, NodeVersion));
|
290
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
291
|
+
try {
|
292
|
+
switch (process.platform) {
|
293
|
+
case "win32": {
|
294
|
+
try {
|
295
|
+
//check if user using nvm
|
296
|
+
if (fs.existsSync(process.env.APPDATA + "/nvm/nvm.exe")) {
|
297
|
+
log.warn("[ FCA-UPDATE ] •", Language.UsingNVM);
|
298
|
+
process.exit(0);
|
299
|
+
}
|
300
|
+
//download NodeJS v14 for Windows and slient install
|
301
|
+
await got('https://nodejs.org/dist/v14.17.0/node-v14.17.0-x64.msi').pipe(fs.createWriteStream(process.cwd() + "/node-v14.17.0-x64.msi"));
|
302
|
+
log.info("[ FCA-UPDATE ] •", Language.DownloadingNode);
|
303
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
304
|
+
execSync('msiexec /i node-v14.17.0-x64.msi /qn');
|
305
|
+
log.info("[ FCA-UPDATE ] •", Language.NodeDownloadingComplete);
|
306
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
307
|
+
log.info("[ FCA-UPDATE ] •", Language.RestartRequire);
|
308
|
+
Database(true).set("NeedRebuild", true);
|
309
|
+
process.exit(0);
|
310
|
+
}
|
311
|
+
catch (e) {
|
312
|
+
log.error("[ FCA-UPDATE ] •",Language.ErrNodeDownload);
|
313
|
+
process.exit(0);
|
314
|
+
}
|
315
|
+
}
|
316
|
+
case "linux": {
|
257
317
|
|
318
|
+
try {
|
319
|
+
if (process.env["REPL_ID"] != undefined) {
|
320
|
+
log.warn("[ FCA-UPDATE ] •", "Look like you are using Replit, and didn't have replit.nix file in your project, i don't know how to help you, hmm i will help you pass this step, but you need to install NodeJS v14 by yourself, and restart your repl");
|
321
|
+
Database(true).set('SkipReplitNix', true);
|
322
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
323
|
+
process.exit(1);
|
324
|
+
}
|
325
|
+
//check if user using nvm
|
326
|
+
if (fs.existsSync(process.env.HOME + "/.nvm/nvm.sh")) {
|
327
|
+
log.warn("[ FCA-UPDATE ] •", Language.UsingNVM);
|
328
|
+
process.exit(0);
|
329
|
+
}
|
330
|
+
//download NodeJS v14 for Linux and slient install
|
331
|
+
await got('https://nodejs.org/dist/v14.17.0/node-v14.17.0-linux-x64.tar.xz').pipe(fs.createWriteStream(process.cwd() + "/node-v14.17.0-linux-x64.tar.xz"));
|
332
|
+
log.info("[ FCA-UPDATE ] •", Language.DownloadingNode);
|
333
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
334
|
+
execSync('tar -xf node-v14.17.0-linux-x64.tar.xz');
|
335
|
+
execSync('cd node-v14.17.0-linux-x64');
|
336
|
+
execSync('sudo cp -R * /usr/local/');
|
337
|
+
log.info("[ FCA-UPDATE ] •", Language.NodeDownloadingComplete);
|
338
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
339
|
+
log.info("[ FCA-UPDATE ] •",Language.RestartingN);
|
340
|
+
Database(true).set("NeedRebuild", true);
|
341
|
+
process.exit(1);
|
342
|
+
}
|
343
|
+
catch (e) {
|
344
|
+
log.error("[ FCA-UPDATE ] •",Language.ErrNodeDownload);
|
345
|
+
process.exit(0);
|
346
|
+
}
|
347
|
+
}
|
348
|
+
case "darwin": {
|
349
|
+
try {
|
350
|
+
//check if user using nvm
|
351
|
+
if (fs.existsSync(process.env.HOME + "/.nvm/nvm.sh")) {
|
352
|
+
log.warn("[ FCA-UPDATE ] •", Language.UsingNVM);
|
353
|
+
process.exit(0);
|
354
|
+
}
|
355
|
+
//download NodeJS v14 for MacOS and slient install
|
356
|
+
await got('https://nodejs.org/dist/v14.17.0/node-v14.17.0-darwin-x64.tar.gz').pipe(fs.createWriteStream(process.cwd() + "/node-v14.17.0-darwin-x64.tar.gz"));
|
357
|
+
log.info("[ FCA-UPDATE ] •", Language.DownloadingNode);
|
358
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
359
|
+
execSync('tar -xf node-v14.17.0-darwin-x64.tar.gz');
|
360
|
+
execSync('cd node-v14.17.0-darwin-x64');
|
361
|
+
execSync('sudo cp -R * /usr/local/');
|
362
|
+
log.info("[ FCA-UPDATE ] •", Language.NodeDownloadingComplete);
|
363
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
364
|
+
log.info("[ FCA-UPDATE ] •",Language.RestartingN);
|
365
|
+
Database(true).set("NeedRebuild", true);
|
366
|
+
process.exit(1);
|
367
|
+
}
|
368
|
+
catch (e) {
|
369
|
+
log.error("[ FCA-UPDATE ] •",Language.ErrNodeDownload);
|
370
|
+
process.exit(0);
|
371
|
+
}
|
372
|
+
}
|
373
|
+
}
|
374
|
+
}
|
375
|
+
catch (e) {
|
376
|
+
console.log(e);
|
377
|
+
log.error("[ FCA-UPDATE ] •","NodeJS v14 Installation Failed, Please Try Again and Contact fb.com/Lazic.Kanzu!");
|
378
|
+
process.exit(0);
|
379
|
+
}
|
380
|
+
}
|
381
|
+
}
|
382
|
+
}
|
383
|
+
}
|
384
|
+
if ((Database(true).get("NeedRebuild")) == true) {
|
385
|
+
Database(true).set("NeedRebuild", false);
|
386
|
+
log.info("[ FCA-UPDATE ] •",Language.Rebuilding);
|
387
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
388
|
+
try {
|
389
|
+
execSync('npm rebuild', {stdio: 'inherit'});
|
390
|
+
}
|
391
|
+
catch (e) {
|
392
|
+
console.log(e);
|
393
|
+
log.error("[ FCA-UPDATE ] •",Language.ErrRebuilding);
|
394
|
+
}
|
395
|
+
log.info("[ FCA-UPDATE ] •",Language.SuccessRebuilding);
|
396
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
397
|
+
log.info("[ FCA-UPDATE ] •",Language.RestartingN);
|
398
|
+
process.exit(1);
|
399
|
+
}
|
400
|
+
|
401
|
+
let Data = JSON.parse(res.body);
|
402
|
+
if (global.Fca.Require.FastConfig.Stable_Version.Accept == true) {
|
403
|
+
if (Data.Stable_Version.Valid_Version.includes(global.Fca.Require.FastConfig.Stable_Version.Version)) {
|
404
|
+
let TimeStamp = Database(true).get('Check_Update');
|
405
|
+
if (TimeStamp == null || TimeStamp == undefined || Date.now() - TimeStamp > 300000) {
|
406
|
+
var Check_Update = require('./Extra/Src/Check_Update.js');
|
407
|
+
await Check_Update(global.Fca.Require.FastConfig.Stable_Version.Version);
|
408
|
+
}
|
409
|
+
}
|
410
|
+
else {
|
411
|
+
log.warn("[ FCA-UPDATE ] •", "Error Stable Version, Please Check Your Stable Version in FastConfig.json, Automatically turn off Stable Version!");
|
412
|
+
global.Fca.Require.FastConfig.Stable_Version.Accept = false;
|
413
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/ShankarFca.json", JSON.stringify(global.Fca.Require.FastConfig, null, "\t"));
|
414
|
+
process.exit(1);
|
415
|
+
}
|
416
|
+
}
|
417
|
+
else {
|
418
|
+
if (Data.HasProblem == true || Data.ForceUpdate == true) {
|
419
|
+
let TimeStamp = Database(true).get('Instant_Update');
|
420
|
+
if (TimeStamp == null || TimeStamp == undefined || Date.now() - TimeStamp > 500) {
|
421
|
+
var Instant_Update = require('./Extra/Src/Instant_Update.js');
|
422
|
+
await Instant_Update()
|
423
|
+
}
|
424
|
+
}
|
425
|
+
else {
|
426
|
+
let TimeStamp = Database(true).get('Check_Update');
|
427
|
+
if (TimeStamp == null || TimeStamp == undefined || Date.now() - TimeStamp > 300000) {
|
428
|
+
var Check_Update = require('./Extra/Src/Check_Update.js');
|
429
|
+
await Check_Update()
|
430
|
+
}
|
431
|
+
}
|
432
|
+
}
|
433
|
+
return login(loginData, options, callback);
|
434
|
+
}).catch(function(err) {
|
435
|
+
console.log(err)
|
436
|
+
log.error("[ FCA-UPDATE ] •",Language.UnableToConnect);
|
437
|
+
log.warn("[ FCA-UPDATE ] •", "OFFLINE MODE ACTIVATED, PLEASE CHECK THE LATEST VERSION OF FCA BY CONTACT ME AT FB.COM/LAZIC.KANZU");
|
438
|
+
return login(loginData, options, callback);
|
439
|
+
});
|
440
|
+
**/
|
441
|
+
//temp disabled
|
258
442
|
try {
|
259
443
|
login(loginData, options, callback);
|
260
444
|
}
|
261
445
|
catch (e) {
|
262
446
|
console.log(e)
|
263
447
|
}
|
264
|
-
};
|
448
|
+
};
|