fca-sakibin-remarsted 3.5.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.cache/replit/__replit_disk_meta.json +1 -0
- package/.cache/replit/modules.stamp +1 -0
- package/.cache/replit/nix/env.json +1 -0
- package/.upm/store.json +1 -0
- package/CHANGELOG.md +2 -0
- package/CountTime.json +1 -0
- package/DOCS.md +1947 -0
- package/Extra/Database/N +1 -0
- package/Extra/Database/index.js +469 -0
- package/Extra/ExtraAddons.js +82 -0
- package/Extra/ExtraFindUID.js +62 -0
- package/Extra/ExtraGetThread.js +340 -0
- package/Extra/ExtraScreenShot.js +430 -0
- package/Extra/ExtraUptimeRobot.js +38 -0
- package/Extra/Html/Classic/script.js +119 -0
- package/Extra/Html/Classic/style.css +32 -0
- package/Extra/Html/N +1 -0
- package/Extra/N +1 -0
- package/Extra/Security/Index.js +173 -0
- package/Extra/Security/N +1 -0
- package/Extra/Security/Step_1.js +6 -0
- package/Extra/Security/Step_2.js +22 -0
- package/Extra/Security/Step_3.js +22 -0
- package/Extra/Src/Change_Environment.js +24 -0
- package/Extra/Src/Check_Update.js +67 -0
- package/Extra/Src/History.js +115 -0
- package/Extra/Src/Instant_Update.js +65 -0
- package/Extra/Src/Last-Run.js +65 -0
- package/Extra/Src/N +1 -0
- package/Extra/Src/Premium.js +81 -0
- package/Extra/Src/Release_Memory.js +41 -0
- package/Extra/Src/Websocket.js +213 -0
- package/Extra/Src/uuid.js +137 -0
- package/Func/AcceptAgreement.js +31 -0
- package/Func/ClearCache.js +64 -0
- package/Func/N +1 -0
- package/Func/ReportV1.js +54 -0
- package/LICENSE +21 -0
- package/LICENSE-MIT +21 -0
- package/Main.js +1203 -0
- package/README.md +201 -0
- package/SECURITY.md +18 -0
- package/broadcast.js +40 -0
- package/fca-sakibin-remarsted.zip +0 -0
- package/index.js +383 -0
- package/logger.js +66 -0
- package/package.json +206 -0
- package/replit.nix +5 -0
- package/src/Dev_Horizon_Data.js +125 -0
- package/src/Premium.js +25 -0
- package/src/Screenshot.js +83 -0
- package/src/addExternalModule.js +16 -0
- package/src/addUserToGroup.js +79 -0
- package/src/changeAdminStatus.js +79 -0
- package/src/changeArchivedStatus.js +41 -0
- package/src/changeAvatar.js +127 -0
- package/src/changeAvt.js +85 -0
- package/src/changeBio.js +65 -0
- package/src/changeBlockedStatus.js +36 -0
- package/src/changeGroupImage.js +106 -0
- package/src/changeNickname.js +45 -0
- package/src/changeThreadColor.js +62 -0
- package/src/changeThreadEmoji.js +42 -0
- package/src/createNewGroup.js +70 -0
- package/src/createPoll.js +60 -0
- package/src/deleteMessage.js +45 -0
- package/src/deleteThread.js +43 -0
- package/src/forwardAttachment.js +48 -0
- package/src/getAccessToken.js +28 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +27 -0
- package/src/getFriendsList.js +73 -0
- package/src/getMessage.js +80 -0
- package/src/getThreadHistory.js +537 -0
- package/src/getThreadInfo.js +425 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadMain.js +220 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getUID.js +59 -0
- package/src/getUserID.js +62 -0
- package/src/getUserInfo.js +113 -0
- package/src/getUserInfoMain.js +65 -0
- package/src/getUserInfoV2.js +32 -0
- package/src/getUserInfoV3.js +63 -0
- package/src/getUserInfoV4.js +55 -0
- package/src/getUserInfoV5.js +61 -0
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +49 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/httpPostFormData.js +41 -0
- package/src/listenMqtt.js +787 -0
- package/src/logout.js +68 -0
- package/src/markAsDelivered.js +48 -0
- package/src/markAsRead.js +70 -0
- package/src/markAsReadAll.js +43 -0
- package/src/markAsSeen.js +51 -0
- package/src/muteThread.js +47 -0
- package/src/n +1 -0
- package/src/removeUserFromGroup.js +49 -0
- package/src/resolvePhotoUrl.js +37 -0
- package/src/searchForThread.js +43 -0
- package/src/sendMessage.js +379 -0
- package/src/sendTypingIndicator.js +80 -0
- package/src/setMessageReaction.js +109 -0
- package/src/setPostReaction.js +102 -0
- package/src/setTitle.js +74 -0
- package/src/threadColors.js +39 -0
- package/src/unfriend.js +43 -0
- package/src/unsendMessage.js +40 -0
- package/src/uploadAttachment.js +96 -0
- package/test/.env/.env +1 -0
- package/test/Database_Test.js +4 -0
- package/test/Db2.js +530 -0
- package/test/Horizon_Database/A_README.md +1 -0
- package/test/Horizon_Database/Database.db +0 -0
- package/test/Horizon_Database/N +1 -0
- package/test/SAKIBIN_Database/A_README.md +1 -0
- package/test/SAKIBIN_Database/Database.db +0 -0
- package/test/SAKIBIN_Database/N +1 -0
- package/test/data/N +1 -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/env.env +0 -0
- package/test/example-config.json +18 -0
- package/test/memoryleak.js +18 -0
- package/test/test-page.js +140 -0
- package/test/test.js +385 -0
- package/test/testv2.js +18 -0
- package/utils.js +1684 -0
package/README.md
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
# Unofficial Facebook Chat API
|
2
|
+
[![Socket Badge](https://socket.dev/api/badge/npm/package/fca-sakibin-remarsted)](https://socket.dev/npm/package/fca-sakibin-remarsted)
|
3
|
+
<a href="https://www.npmjs.com/package/fca-sakibin-remarsted"><img alt="npm version" src="https://img.shields.io/npm/v/fca-sakibin-remarsted.svg?style=flat-square"></a>
|
4
|
+
<img alt="version" src="https://img.shields.io/github/package-json/v/SAKIBIN-BOT69/fca-sakibin-remarsted?label=github&style=flat-square">
|
5
|
+
<a href="https://www.npmjs.com/package/fca-sakibin-remarsted"><img src="https://img.shields.io/npm/dm/fca-sakibin-remarsted.svg?style=flat-square" alt="npm downloads"></a>
|
6
|
+
|
7
|
+
Facebook now has an official API for chat bots [here](https://developers.facebook.com/docs/messenger-platform).
|
8
|
+
|
9
|
+
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.
|
10
|
+
|
11
|
+
_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.
|
12
|
+
|
13
|
+
See [below](#projects-using-this-api) for projects using this API.
|
14
|
+
|
15
|
+
See the [full changelog](/CHANGELOG.md) for release details.
|
16
|
+
|
17
|
+
## Install
|
18
|
+
If you just want to use fb-chat-api, you should use this command:
|
19
|
+
```bash
|
20
|
+
npm install fca-sakibin-remarsted
|
21
|
+
```
|
22
|
+
It will download `fca-sakibin-remarsted` from NPM repositories
|
23
|
+
|
24
|
+
### Bleeding edge
|
25
|
+
If you want to use bleeding edge (directly from github) to test new features or submit bug report, this is the command for you:
|
26
|
+
```bash
|
27
|
+
npm install fca-sakibin-remarsted
|
28
|
+
```
|
29
|
+
|
30
|
+
## Testing your bots
|
31
|
+
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/).
|
32
|
+
|
33
|
+
## Example Usage
|
34
|
+
```javascript
|
35
|
+
const login = require("fca-sakibin-remarsted");
|
36
|
+
|
37
|
+
// Create simple echo bot
|
38
|
+
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
|
39
|
+
if(err) return console.error(err);
|
40
|
+
|
41
|
+
api.listen((err, message) => {
|
42
|
+
api.sendMessage(message.body, message.threadID);
|
43
|
+
});
|
44
|
+
});
|
45
|
+
```
|
46
|
+
|
47
|
+
Result:
|
48
|
+
|
49
|
+
<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">
|
50
|
+
|
51
|
+
|
52
|
+
## Documentation
|
53
|
+
|
54
|
+
You can see it [here](DOCS.md).
|
55
|
+
|
56
|
+
## Main Functionality
|
57
|
+
|
58
|
+
### Sending a message
|
59
|
+
#### api.sendMessage(message, threadID, [callback], [messageID])
|
60
|
+
|
61
|
+
Various types of message can be sent:
|
62
|
+
* *Regular:* set field `body` to the desired message as a string.
|
63
|
+
* *Sticker:* set a field `sticker` to the desired sticker ID.
|
64
|
+
* *File or image:* Set field `attachment` to a readable stream or an array of readable streams.
|
65
|
+
* *URL:* set a field `url` to the desired URL.
|
66
|
+
* *Emoji:* set field `emoji` to the desired emoji as a string and set field `emojiSize` with size of the emoji (`small`, `medium`, `large`)
|
67
|
+
|
68
|
+
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.
|
69
|
+
|
70
|
+
__Tip__: to find your own ID, you can look inside the cookies. The `userID` is under the name `c_user`.
|
71
|
+
|
72
|
+
__Example (Basic Message)__
|
73
|
+
```js
|
74
|
+
const login = require("fca-sakibin-remarsted");
|
75
|
+
|
76
|
+
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
|
77
|
+
if(err) return console.error(err);
|
78
|
+
|
79
|
+
var yourID = "000000000000000";
|
80
|
+
var msg = "Hey!";
|
81
|
+
api.sendMessage(msg, yourID);
|
82
|
+
});
|
83
|
+
```
|
84
|
+
|
85
|
+
__Example (File upload)__
|
86
|
+
```js
|
87
|
+
const login = require("fca-sakibin-remarsted");
|
88
|
+
|
89
|
+
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
|
90
|
+
if(err) return console.error(err);
|
91
|
+
|
92
|
+
// Note this example uploads an image called image.jpg
|
93
|
+
var yourID = "000000000000000";
|
94
|
+
var msg = {
|
95
|
+
body: "Hey!",
|
96
|
+
attachment: fs.createReadStream(__dirname + '/image.jpg')
|
97
|
+
}
|
98
|
+
api.sendMessage(msg, yourID);
|
99
|
+
});
|
100
|
+
```
|
101
|
+
|
102
|
+
------------------------------------
|
103
|
+
### Saving session.
|
104
|
+
|
105
|
+
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.
|
106
|
+
|
107
|
+
__Example__
|
108
|
+
|
109
|
+
```js
|
110
|
+
const fs = require("fs");
|
111
|
+
const login = require("fca-sakibin-remarsted");
|
112
|
+
|
113
|
+
var credentials = {email: "FB_EMAIL", password: "FB_PASSWORD"};
|
114
|
+
|
115
|
+
login(credentials, (err, api) => {
|
116
|
+
if(err) return console.error(err);
|
117
|
+
|
118
|
+
fs.writeFileSync('appstate.json', JSON.stringify(api.getAppState()));
|
119
|
+
});
|
120
|
+
```
|
121
|
+
|
122
|
+
Alternative: Use [c3c-fbstate](https://github.com/lequanglam/c3c-fbstate) to get fbstate.json (appstate.json)
|
123
|
+
|
124
|
+
------------------------------------
|
125
|
+
|
126
|
+
### Listening to a chat
|
127
|
+
#### api.listenMqtt(callback)
|
128
|
+
|
129
|
+
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})`.
|
130
|
+
|
131
|
+
__Example__
|
132
|
+
|
133
|
+
```js
|
134
|
+
const fs = require("fs");
|
135
|
+
const login = require("fca-sakibin-remarsted");
|
136
|
+
|
137
|
+
// Simple echo bot. It will repeat everything that you say.
|
138
|
+
// Will stop when you say '/stop'
|
139
|
+
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
140
|
+
if(err) return console.error(err);
|
141
|
+
|
142
|
+
api.setOptions({listenEvents: true});
|
143
|
+
|
144
|
+
var stopListening = api.listenMqtt((err, event) => {
|
145
|
+
if(err) return console.error(err);
|
146
|
+
|
147
|
+
api.markAsRead(event.threadID, (err) => {
|
148
|
+
if(err) console.error(err);
|
149
|
+
});
|
150
|
+
|
151
|
+
switch(event.type) {
|
152
|
+
case "message":
|
153
|
+
if(event.body === '/stop') {
|
154
|
+
api.sendMessage("Goodbye…", event.threadID);
|
155
|
+
return stopListening();
|
156
|
+
}
|
157
|
+
api.sendMessage("TEST BOT: " + event.body, event.threadID);
|
158
|
+
break;
|
159
|
+
case "event":
|
160
|
+
console.log(event);
|
161
|
+
break;
|
162
|
+
}
|
163
|
+
});
|
164
|
+
});
|
165
|
+
```
|
166
|
+
|
167
|
+
## FAQS
|
168
|
+
|
169
|
+
1. How do I run tests?
|
170
|
+
> 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`.
|
171
|
+
|
172
|
+
2. Why doesn't `sendMessage` always work when I'm logged in as a page?
|
173
|
+
> Pages can't start conversations with users directly; this is to prevent pages from spamming users.
|
174
|
+
|
175
|
+
3. What do I do when `login` doesn't work?
|
176
|
+
> 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).
|
177
|
+
|
178
|
+
4. How can I avoid logging in every time? Can I log into a previous session?
|
179
|
+
> 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.
|
180
|
+
|
181
|
+
5. Do you support sending messages as a page?
|
182
|
+
> Yes, set the pageID option on login (this doesn't work if you set it using api.setOptions, it affects the login process).
|
183
|
+
> ```js
|
184
|
+
> login(credentials, {pageID: "000000000000000"}, (err, api) => { … }
|
185
|
+
> ```
|
186
|
+
|
187
|
+
6. I'm getting some crazy weird syntax error like `SyntaxError: Unexpected token [`!!!
|
188
|
+
> Please try to update your version of node.js before submitting an issue of this nature. We like to use new language features.
|
189
|
+
|
190
|
+
7. I don't want all of these logging messages!
|
191
|
+
> You can use `api.setOptions` to silence the logging. You get the `api` object from `login` (see example above). Do
|
192
|
+
> ```js
|
193
|
+
> api.setOptions({
|
194
|
+
> logLevel: "silent"
|
195
|
+
> });
|
196
|
+
> ```
|
197
|
+
|
198
|
+
<a name="projects-using-this-api"></a>
|
199
|
+
## Projects using this API:
|
200
|
+
- [c3c](https://github.com/lequanglam/c3c) - A bot that can be customizable using plugins. Support Facebook & Discord.
|
201
|
+
- [Mohammad SAKIBIN](https://www.facebook.com/www.xnxx.com169)
|
package/SECURITY.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
+ if have any Vulnerability finded contact: Author(KanzuWakazaki.Main@proton.me) or (Facebook.com/Lazic.Kanzu). 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
|
+
| StableVersion | :white_check_mark: |
|
13
|
+
| AutoUpdate | :white_check_mark:|
|
14
|
+
| Modified | :x:
|
15
|
+
|
16
|
+
## Reporting a Vulnerability
|
17
|
+
|
18
|
+
Contact Author or create pull!
|
package/broadcast.js
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
switch (global.Fca.Require.FastConfig.BroadCast) {
|
4
|
+
case true: {
|
5
|
+
try {
|
6
|
+
var logger = global.Fca.Require.logger;
|
7
|
+
var Fetch = global.Fca.Require.Fetch;
|
8
|
+
Fetch.get("https://raw.githubusercontent.com/SAKIBIN-BOT69/Global_SAKIBIN/main/Broadcast.json").then(async (/** @type {{ body: { toString: () => string; }; }} */ res) => {
|
9
|
+
global.Fca.Data.BroadCast = JSON.parse(res.body.toString())
|
10
|
+
var random = JSON.parse(res.body.toString())[Math.floor(Math.random() * JSON.parse(res.body.toString()).length)] || "Ae Zui Zẻ Nhé !";
|
11
|
+
logger.Normal(random);
|
12
|
+
});
|
13
|
+
}
|
14
|
+
catch (e) {
|
15
|
+
console.log(e);
|
16
|
+
}
|
17
|
+
return setInterval(() => {
|
18
|
+
try {
|
19
|
+
try {
|
20
|
+
var logger = global.Fca.Require.logger;
|
21
|
+
var random = global.Fca.Data.BroadCast[Math.floor(Math.random() * global.Fca.Data.BroadCast.length)] || "Ae Zui Zẻ Nhé !";
|
22
|
+
logger.Normal(random);
|
23
|
+
}
|
24
|
+
catch (e) {
|
25
|
+
console.log(e);
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
catch (e) {
|
30
|
+
console.log(e);
|
31
|
+
}
|
32
|
+
},3600 * 1000);
|
33
|
+
}
|
34
|
+
case false: {
|
35
|
+
break;
|
36
|
+
}
|
37
|
+
default: {
|
38
|
+
break;
|
39
|
+
}
|
40
|
+
}
|
Binary file
|
package/index.js
ADDED
@@ -0,0 +1,383 @@
|
|
1
|
+
'use strict';
|
2
|
+
/* eslint-disable linebreak-style */
|
3
|
+
const utils = require('./utils');
|
4
|
+
global.Fca = new Object({
|
5
|
+
isThread: new Array(),
|
6
|
+
isUser: new Array(),
|
7
|
+
startTime: Date.now(),
|
8
|
+
Setting: new Map(),
|
9
|
+
Version: require('./package.json').version,
|
10
|
+
Require: new Object({
|
11
|
+
fs: require("fs"),
|
12
|
+
Fetch: require('got'),
|
13
|
+
log: require("npmlog"),
|
14
|
+
utils: require("./utils.js"),
|
15
|
+
logger: require('./logger.js'),
|
16
|
+
languageFile: require('./Language/index.json'),
|
17
|
+
Security: require('./Extra/Src/uuid.js')
|
18
|
+
}),
|
19
|
+
getText: function(/** @type {any[]} */...Data) {
|
20
|
+
var Main = (Data.splice(0,1)).toString();
|
21
|
+
for (let i = 0; i < Data.length; i++) Main = Main.replace(RegExp(`%${i + 1}`, 'g'), Data[i]);
|
22
|
+
return Main;
|
23
|
+
},
|
24
|
+
Data: new Object({
|
25
|
+
ObjFastConfig: {
|
26
|
+
"Language": "en",
|
27
|
+
"PreKey": "",
|
28
|
+
"AutoUpdate": true,
|
29
|
+
"MainColor": "#f0e50c",
|
30
|
+
"MainName": "[ SAKIBIN ]",
|
31
|
+
"Uptime": false,
|
32
|
+
"Config": "default",
|
33
|
+
"DevMode": false,
|
34
|
+
"Login2Fa": false,
|
35
|
+
"AutoLogin": false,
|
36
|
+
"BroadCast": true,
|
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
|
+
"EncryptFeature": true,
|
39
|
+
"ResetDataLogin": false,
|
40
|
+
"AutoInstallNode": false,
|
41
|
+
"AntiSendAppState": true,
|
42
|
+
"AutoRestartMinutes": 0,
|
43
|
+
"RestartMQTT_Minutes": 0,
|
44
|
+
"Websocket_Extension": {
|
45
|
+
"Status": false,
|
46
|
+
"ResetData": false,
|
47
|
+
"AppState_Path": "appstate.json"
|
48
|
+
},
|
49
|
+
"HTML": {
|
50
|
+
"HTML": true,
|
51
|
+
"UserName": "Guest",
|
52
|
+
"MusicLink": "https://drive.google.com/uc?id=1Mq2yF8lF3kpTbiLj7428zMPKGXOxGwd4&export=download"
|
53
|
+
},
|
54
|
+
"AntiGetInfo": {
|
55
|
+
"Database_Type": "default", //json or default
|
56
|
+
"AntiGetThreadInfo": true,
|
57
|
+
"AntiGetUserInfo": true
|
58
|
+
},
|
59
|
+
"Stable_Version": {
|
60
|
+
"Accept": false,
|
61
|
+
"Version": ""
|
62
|
+
}
|
63
|
+
},
|
64
|
+
CountTime: function() {
|
65
|
+
var fs = global.Fca.Require.fs;
|
66
|
+
if (fs.existsSync(__dirname + '/CountTime.json')) {
|
67
|
+
try {
|
68
|
+
var data = Number(fs.readFileSync(__dirname + '/CountTime.json', 'utf8')),
|
69
|
+
hours = Math.floor(data / (60 * 60));
|
70
|
+
}
|
71
|
+
catch (e) {
|
72
|
+
fs.writeFileSync(__dirname + '/CountTime.json', 0);
|
73
|
+
hours = 0;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
else {
|
77
|
+
hours = 0;
|
78
|
+
}
|
79
|
+
return `${hours} Hours`;
|
80
|
+
}
|
81
|
+
}),
|
82
|
+
Action: function(Type) {
|
83
|
+
switch (Type) {
|
84
|
+
case "AutoLogin": {
|
85
|
+
var Database = require('./Extra/Database');
|
86
|
+
var logger = global.Fca.Require.logger;
|
87
|
+
var Email = (Database().get('Account')).replace(RegExp('"', 'g'), ''); //hmm IDK
|
88
|
+
var PassWord = (Database().get('Password')).replace(RegExp('"', 'g'), '');
|
89
|
+
require('./Main')({ email: Email, password: PassWord},async (error, api) => {
|
90
|
+
if (error) {
|
91
|
+
logger.Error(JSON.stringify(error,null,2), function() { logger.Error("AutoLogin Failed!", function() { process.exit(0); }) });
|
92
|
+
}
|
93
|
+
try {
|
94
|
+
Database().set("TempState", Database().get('Through2Fa'));
|
95
|
+
}
|
96
|
+
catch(e) {
|
97
|
+
logger.Warning(global.Fca.Require.Language.Index.ErrDatabase);
|
98
|
+
logger.Error();
|
99
|
+
process.exit(0);
|
100
|
+
}
|
101
|
+
process.exit(1);
|
102
|
+
});
|
103
|
+
}
|
104
|
+
break;
|
105
|
+
default: {
|
106
|
+
require('npmlog').Error("Invalid Message!");
|
107
|
+
};
|
108
|
+
}
|
109
|
+
}
|
110
|
+
});
|
111
|
+
|
112
|
+
try {
|
113
|
+
let Boolean_Fca = ["AntiSendAppState","AutoUpdate","Uptime","BroadCast","EncryptFeature","AutoLogin","ResetDataLogin","Login2Fa", "DevMode","AutoInstallNode"];
|
114
|
+
let String_Fca = ["MainName","PreKey","Language","AuthString","Config"]
|
115
|
+
let Number_Fca = ["AutoRestartMinutes","RestartMQTT_Minutes"];
|
116
|
+
let Object_Fca = ["HTML","Stable_Version","AntiGetInfo","Websocket_Extension"];
|
117
|
+
let All_Variable = Boolean_Fca.concat(String_Fca,Number_Fca,Object_Fca);
|
118
|
+
|
119
|
+
|
120
|
+
if (!global.Fca.Require.fs.existsSync(process.cwd() + '/FastConfigSAKIBIN.json')) {
|
121
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigSAKIBIN.json", JSON.stringify(global.Fca.Data.ObjFastConfig, null, "\t"));
|
122
|
+
process.exit(1);
|
123
|
+
}
|
124
|
+
|
125
|
+
try {
|
126
|
+
var Data_Setting = require(process.cwd() + "/FastConfigSAKIBIN.json");
|
127
|
+
}
|
128
|
+
catch (e) {
|
129
|
+
global.Fca.Require.logger.Error('Detect Your FastConfigFca Settings Invalid!, Carry out default restoration');
|
130
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigSAKIBIN.json", JSON.stringify(global.Fca.Data.ObjFastConfig, null, "\t"));
|
131
|
+
process.exit(1)
|
132
|
+
}
|
133
|
+
if (global.Fca.Require.fs.existsSync(process.cwd() + '/FastConfigSAKIBIN.json')) {
|
134
|
+
|
135
|
+
for (let i of All_Variable) {
|
136
|
+
if (Data_Setting[i] == undefined) {
|
137
|
+
Data_Setting[i] = global.Fca.Data.ObjFastConfig[i];
|
138
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigSAKIBIN.json", JSON.stringify(Data_Setting, null, "\t"));
|
139
|
+
}
|
140
|
+
else continue;
|
141
|
+
} //Check Variable
|
142
|
+
|
143
|
+
for (let i in Data_Setting) {
|
144
|
+
if (Boolean_Fca.includes(i)) {
|
145
|
+
if (global.Fca.Require.utils.getType(Data_Setting[i]) != "Boolean") logger.Error(i + " Is Not A Boolean, Need To Be true Or false !", function() { process.exit(0) });
|
146
|
+
else continue;
|
147
|
+
}
|
148
|
+
else if (String_Fca.includes(i)) {
|
149
|
+
if (global.Fca.Require.utils.getType(Data_Setting[i]) != "String") logger.Error(i + " Is Not A String, Need To Be String!", function() { process.exit(0) });
|
150
|
+
else continue;
|
151
|
+
}
|
152
|
+
else if (Number_Fca.includes(i)) {
|
153
|
+
if (global.Fca.Require.utils.getType(Data_Setting[i]) != "Number") logger.Error(i + " Is Not A Number, Need To Be Number !", function() { process.exit(0) });
|
154
|
+
else continue;
|
155
|
+
}
|
156
|
+
else if (Object_Fca.includes(i)) {
|
157
|
+
if (global.Fca.Require.utils.getType(Data_Setting[i]) != "Object") {
|
158
|
+
Data_Setting[i] = global.Fca.Data.ObjFastConfig[i];
|
159
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigSAKIBIN.json", JSON.stringify(Data_Setting, null, "\t"));
|
160
|
+
}
|
161
|
+
else continue;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
for (let i of Object_Fca) {
|
166
|
+
const All_Paths = utils.getPaths(global.Fca.Data.ObjFastConfig[i]);
|
167
|
+
const Mission = { Main_Path: i, Data_Path: All_Paths }
|
168
|
+
for (let i of Mission.Data_Path) {
|
169
|
+
if (Data_Setting[Mission.Main_Path] == undefined) {
|
170
|
+
Data_Setting[Mission.Main_Path] = global.Fca.Data.ObjFastConfig[Mission.Main_Path];
|
171
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigSAKIBIN.json", JSON.stringify(Data_Setting, null, "\t"));
|
172
|
+
}
|
173
|
+
const User_Data = (utils.getData_Path(Data_Setting[Mission.Main_Path], i, 0))
|
174
|
+
const User_Data_Type = utils.getType(User_Data);
|
175
|
+
if (User_Data_Type == "Number") {
|
176
|
+
const Mission_Path = User_Data == 0 ? i : i.slice(0, User_Data);
|
177
|
+
const Mission_Obj = utils.getData_Path(global.Fca.Data.ObjFastConfig[Mission.Main_Path], Mission_Path, 0);
|
178
|
+
Data_Setting[Mission.Main_Path] = utils.setData_Path(Data_Setting[Mission.Main_Path], Mission_Path, Mission_Obj)
|
179
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigSAKIBIN.json", JSON.stringify(Data_Setting, null, "\t"));
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
183
|
+
|
184
|
+
if (!global.Fca.Require.languageFile.some((/** @type {{ Language: string; }} */i) => i.Language == Data_Setting.Language)) {
|
185
|
+
global.Fca.Require.logger.Warning("Not Support Language: " + Data_Setting.Language + " Only 'en' and 'vi'");
|
186
|
+
process.exit(0);
|
187
|
+
}
|
188
|
+
global.Fca.Require.Language = global.Fca.Require.languageFile.find((/** @type {{ Language: string; }} */i) => i.Language == Data_Setting.Language).Folder;
|
189
|
+
} else process.exit(1);
|
190
|
+
global.Fca.Require.FastConfig = Data_Setting;
|
191
|
+
}
|
192
|
+
catch (e) {
|
193
|
+
console.log(e);
|
194
|
+
global.Fca.Require.logger.Error();
|
195
|
+
}
|
196
|
+
|
197
|
+
if (global.Fca.Require.FastConfig.Websocket_Extension.Status) {
|
198
|
+
console.history = new Array();
|
199
|
+
var Convert = require('ansi-to-html');
|
200
|
+
var convert = new Convert();
|
201
|
+
console.__log = console.log;
|
202
|
+
console.log = function (data) {
|
203
|
+
const log = convert.toHtml(data)
|
204
|
+
console.history.push(log)
|
205
|
+
console.__log.apply(console,arguments)
|
206
|
+
}
|
207
|
+
}
|
208
|
+
|
209
|
+
module.exports = function(loginData, options, callback) {
|
210
|
+
const Language = global.Fca.Require.languageFile.find((/** @type {{ Language: string; }} */i) => i.Language == global.Fca.Require.FastConfig.Language).Folder.Index;
|
211
|
+
const login = require('./Main');
|
212
|
+
const fs = require('fs-extra');
|
213
|
+
const got = require('got');
|
214
|
+
const log = require('npmlog');
|
215
|
+
const { execSync } = require('child_process');
|
216
|
+
const Database = require('./Extra/Database');
|
217
|
+
|
218
|
+
if (global.Fca.Require.FastConfig.DevMode) {
|
219
|
+
require('./Extra/Src/Release_Memory');
|
220
|
+
}
|
221
|
+
|
222
|
+
return got.get('https://github.com/SAKIBIN-BOT69/Global_SAKIBIN/raw/main/InstantAction.json').then(async function(res) {
|
223
|
+
if (global.Fca.Require.FastConfig.AutoInstallNode) {
|
224
|
+
switch (fs.existsSync(process.cwd() + "/replit.nix") && process.env["REPL_ID"] != undefined) {
|
225
|
+
case true: {
|
226
|
+
await require('./Extra/Src/Change_Environment.js')();
|
227
|
+
break;
|
228
|
+
}
|
229
|
+
case false: {
|
230
|
+
const NodeVersion = execSync('node -v').toString().replace(/(\r\n|\n|\r)/gm, "");
|
231
|
+
if (!NodeVersion.includes("v14") && !NodeVersion.includes("v16") && !Database(true).has('SkipReplitNix')) {
|
232
|
+
log.warn("[ SAKIBIN-UPDATE ] •",global.Fca.getText(Language.NodeVersionNotSupported, NodeVersion));
|
233
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
234
|
+
try {
|
235
|
+
switch (process.platform) {
|
236
|
+
case "win32": {
|
237
|
+
try {
|
238
|
+
//check if user using nvm
|
239
|
+
if (fs.existsSync(process.env.APPDATA + "/nvm/nvm.exe")) {
|
240
|
+
log.warn("[ SAKIBIN-UPDATE ] •", Language.UsingNVM);
|
241
|
+
process.exit(0);
|
242
|
+
}
|
243
|
+
//download NodeJS v14 for Windows and slient install
|
244
|
+
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"));
|
245
|
+
log.info("[ SAKIBIN-UPDATE ] •", Language.DownloadingNode);
|
246
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
247
|
+
execSync('msiexec /i node-v14.17.0-x64.msi /qn');
|
248
|
+
log.info("[ SAKIBIN-UPDATE ] •", Language.NodeDownloadingComplete);
|
249
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
250
|
+
log.info("[ SAKIBIN-UPDATE ] •", Language.RestartRequire);
|
251
|
+
Database(true).set("NeedRebuild", true);
|
252
|
+
process.exit(0);
|
253
|
+
}
|
254
|
+
catch (e) {
|
255
|
+
log.error("[ SAKIBIN-UPDATE ] •",Language.ErrNodeDownload);
|
256
|
+
process.exit(0);
|
257
|
+
}
|
258
|
+
}
|
259
|
+
case "linux": {
|
260
|
+
|
261
|
+
try {
|
262
|
+
if (process.env["REPL_ID"] != undefined) {
|
263
|
+
log.warn("[ SAKIBIN-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");
|
264
|
+
Database(true).set('SkipReplitNix', true);
|
265
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
266
|
+
process.exit(1);
|
267
|
+
}
|
268
|
+
//check if user using nvm
|
269
|
+
if (fs.existsSync(process.env.HOME + "/.nvm/nvm.sh")) {
|
270
|
+
log.warn("[ SAKIBIN-UPDATE ] •", Language.UsingNVM);
|
271
|
+
process.exit(0);
|
272
|
+
}
|
273
|
+
//download NodeJS v14 for Linux and slient install
|
274
|
+
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"));
|
275
|
+
log.info("[ SAKIBIN-UPDATE ] •", Language.DownloadingNode);
|
276
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
277
|
+
execSync('tar -xf node-v14.17.0-linux-x64.tar.xz');
|
278
|
+
execSync('cd node-v14.17.0-linux-x64');
|
279
|
+
execSync('sudo cp -R * /usr/local/');
|
280
|
+
log.info("[ SAKIBIN-UPDATE ] •", Language.NodeDownloadingComplete);
|
281
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
282
|
+
log.info("[ SAKIBIN-UPDATE ] •",Language.RestartingN);
|
283
|
+
Database(true).set("NeedRebuild", true);
|
284
|
+
process.exit(1);
|
285
|
+
}
|
286
|
+
catch (e) {
|
287
|
+
log.error("[ SAKIBIN-UPDATE ] •",Language.ErrNodeDownload);
|
288
|
+
process.exit(0);
|
289
|
+
}
|
290
|
+
}
|
291
|
+
case "darwin": {
|
292
|
+
try {
|
293
|
+
//check if user using nvm
|
294
|
+
if (fs.existsSync(process.env.HOME + "/.nvm/nvm.sh")) {
|
295
|
+
log.warn("[ SAKIBIN-UPDATE ] •", Language.UsingNVM);
|
296
|
+
process.exit(0);
|
297
|
+
}
|
298
|
+
//download NodeJS v14 for MacOS and slient install
|
299
|
+
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"));
|
300
|
+
log.info("[ SAKIBIN-UPDATE ] •", Language.DownloadingNode);
|
301
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
302
|
+
execSync('tar -xf node-v14.17.0-darwin-x64.tar.gz');
|
303
|
+
execSync('cd node-v14.17.0-darwin-x64');
|
304
|
+
execSync('sudo cp -R * /usr/local/');
|
305
|
+
log.info("[ SAKIBIN-UPDATE ] •", Language.NodeDownloadingComplete);
|
306
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
307
|
+
log.info("[ SAKIBIN-UPDATE ] •",Language.RestartingN);
|
308
|
+
Database(true).set("NeedRebuild", true);
|
309
|
+
process.exit(1);
|
310
|
+
}
|
311
|
+
catch (e) {
|
312
|
+
log.error("[ SAKIBIN-UPDATE ] •",Language.ErrNodeDownload);
|
313
|
+
process.exit(0);
|
314
|
+
}
|
315
|
+
}
|
316
|
+
}
|
317
|
+
}
|
318
|
+
catch (e) {
|
319
|
+
console.log(e);
|
320
|
+
log.error("[ SAKIBIN-UPDATE ] •","NodeJS v14 Installation Failed, Please Try Again and Contact https://github.com/sakibin");
|
321
|
+
process.exit(0);
|
322
|
+
}
|
323
|
+
}
|
324
|
+
}
|
325
|
+
}
|
326
|
+
}
|
327
|
+
if ((Database(true).get("NeedRebuild")) == true) {
|
328
|
+
Database(true).set("NeedRebuild", false);
|
329
|
+
log.info("[ SAKIBIN-UPDATE ] •",Language.Rebuilding);
|
330
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
331
|
+
try {
|
332
|
+
execSync('npm rebuild', {stdio: 'inherit'});
|
333
|
+
}
|
334
|
+
catch (e) {
|
335
|
+
console.log(e);
|
336
|
+
log.error("[ SAKIBIN-UPDATE ] •",Language.ErrRebuilding);
|
337
|
+
}
|
338
|
+
log.info("[ SAKIBIN-UPDATE ] •",Language.SuccessRebuilding);
|
339
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
340
|
+
log.info("[ SAKIBIN-UPDATE ] •",Language.RestartingN);
|
341
|
+
process.exit(1);
|
342
|
+
}
|
343
|
+
|
344
|
+
let Data = JSON.parse(res.body);
|
345
|
+
if (global.Fca.Require.FastConfig.Stable_Version.Accept == true) {
|
346
|
+
if (Data.Stable_Version.Valid_Version.includes(global.Fca.Require.FastConfig.Stable_Version.Version)) {
|
347
|
+
let TimeStamp = Database(true).get('Check_Update');
|
348
|
+
if (TimeStamp == null || TimeStamp == undefined || Date.now() - TimeStamp > 300000) {
|
349
|
+
var Check_Update = require('./Extra/Src/Check_Update.js');
|
350
|
+
await Check_Update(global.Fca.Require.FastConfig.Stable_Version.Version);
|
351
|
+
}
|
352
|
+
}
|
353
|
+
else {
|
354
|
+
log.warn("[ SAKIBIN-UPDATE ] •", "Error Stable Version, Please Check Your Stable Version in FastConfig.json, Automatically turn off Stable Version!");
|
355
|
+
global.Fca.Require.FastConfig.Stable_Version.Accept = false;
|
356
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigSAKIBIN.json", JSON.stringify(global.Fca.Require.FastConfig, null, "\t"));
|
357
|
+
process.exit(1);
|
358
|
+
}
|
359
|
+
}
|
360
|
+
else {
|
361
|
+
if (Data.HasProblem == true || Data.ForceUpdate == true) {
|
362
|
+
let TimeStamp = Database(true).get('Instant_Update');
|
363
|
+
if (TimeStamp == null || TimeStamp == undefined || Date.now() - TimeStamp > 500) {
|
364
|
+
var Instant_Update = require('./Extra/Src/Instant_Update.js');
|
365
|
+
await Instant_Update()
|
366
|
+
}
|
367
|
+
}
|
368
|
+
else {
|
369
|
+
let TimeStamp = Database(true).get('Check_Update');
|
370
|
+
if (TimeStamp == null || TimeStamp == undefined || Date.now() - TimeStamp > 300000) {
|
371
|
+
var Check_Update = require('./Extra/Src/Check_Update.js');
|
372
|
+
await Check_Update()
|
373
|
+
}
|
374
|
+
}
|
375
|
+
}
|
376
|
+
return login(loginData, options, callback);
|
377
|
+
}).catch(function(err) {
|
378
|
+
console.log(err)
|
379
|
+
log.error("[ SAKIBIN-UPDATE ] •",Language.UnableToConnect);
|
380
|
+
log.warn("[ SAKIBIN-UPDATE ] •", "OFFLINE MODE ACTIVATED, PLEASE CHECK THE LATEST VERSION OF fca-sakibin-remarsted BY CONTACT ME AT https://www.facebook.com/imsakibin007");
|
381
|
+
return login(loginData, options, callback);
|
382
|
+
});
|
383
|
+
};
|