capfb 0.0.1-security → 1.3.63-beta
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of capfb might be problematic. Click here for more details.
- package/.gitattributes +2 -0
- package/.github/dependabot.yml +11 -0
- package/.github/workflows/nodejs.yml +26 -0
- package/.github/workflows/npmpublish.yml +30 -0
- package/CHANGELOG.md +2 -0
- package/DOCS.md +1738 -0
- package/Extra/Database/index.js +399 -0
- package/Extra/Database/methods.js +286 -0
- package/Extra/ExtraAddons.js +78 -0
- package/Extra/ExtraAddonsDeprecated.js +213 -0
- package/Extra/ExtraGetThread.js +1 -0
- package/Extra/ExtraUptimeRobot.js +59 -0
- package/Extra/PM2/ecosystem.config.js +23 -0
- package/Extra/Src/Last-Run.js +48 -0
- package/LICENSE-MIT +21 -0
- package/Language/index.json +151 -0
- package/README.md +225 -3
- package/StateCrypt.js +22 -0
- package/broadcast.js +42 -0
- package/index-backup.js +1079 -0
- package/index.js +1108 -0
- package/logger.js +21 -0
- package/package.json +88 -3
- package/src/addExternalModule.js +16 -0
- package/src/addUserToGroup.js +78 -0
- package/src/changeAdminStatus.js +79 -0
- package/src/changeArchivedStatus.js +41 -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 +32 -0
- package/src/getAccessTokenDeprecated.js +31 -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/getThreadHistoryDeprecated.js +71 -0
- package/src/getThreadInfo.js +197 -0
- package/src/getThreadInfoDeprecated.js +56 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadListDeprecated.js +46 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getUserID.js +62 -0
- package/src/getUserInfo.js +65 -0
- package/src/getUserInfoV2.js +35 -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 +633 -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/removeUserFromGroup.js +49 -0
- package/src/resolvePhotoUrl.js +37 -0
- package/src/searchForThread.js +43 -0
- package/src/sendMessage.js +342 -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/utils.js +1284 -0
@@ -0,0 +1,151 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"Language": "vi",
|
4
|
+
"Folder": {
|
5
|
+
"Index": {
|
6
|
+
"ErrAppState": "Appstate - Cookie Của Bạn Đã Bị Lỗi, Hãy Thay Cái Mới, Hoặc Vô Trình Duyệt Ẩn Danh Rồi Đăng Nhập Và Thử Lại !",
|
7
|
+
"CheckPointLevelI": "Phát Hiện CheckPoint - Không Đăng Nhập Được, Hãy Thử Logout Rồi Login Và Lấy Lại Appstate - Cookie !",
|
8
|
+
"UID": "Đăng Nhập Tại ID: %1",
|
9
|
+
"Area": "Vùng Của Tài Khoản Là: %1",
|
10
|
+
"NoAreaData": "Không Thể Lấy Vùng Của Tài Khoản !",
|
11
|
+
"OnLogin": "Đang Đăng Nhập ...",
|
12
|
+
"InvaildAccount": "Sai Mật Khẩu Hoặc Tài Khoản !",
|
13
|
+
"TwoAuth": "Bạn Đang Bật 2 Bảo Mật !",
|
14
|
+
"InvaildTwoAuthCode": "Sai Mã Hai Bảo Mật !",
|
15
|
+
"ApprovalsErr": "Lỗi Khi Đăng Nhập Với Hai Bảo Mật !",
|
16
|
+
"VerifiedCheck": "Xác Nhận Từ Trình Duyệt, Đang Đăng Nhập...",
|
17
|
+
"ForceLoginNotEnable": "Không Thể Đăng Nhập, Hãy Thử Bật 'forceLogin' !",
|
18
|
+
"SubmitErrSuccess": "Đã Gửi Báo Cáo Lỗi Tới Server !",
|
19
|
+
"ErrorWhileSendErr": "Đã Xảy Ra Lỗi Khi Cố Gửi Lỗi Đến Server !",
|
20
|
+
"OnProcess": "Khởi Động Tiến Trình Đăng Nhập !",
|
21
|
+
"BackupNoti": "Đang Thay AppState Từ Backup, Nếu Điều Này Tiếp Tục Diễn Ra, Hãy Liên Hệ Với Fb.com/Lazic.Kanzu",
|
22
|
+
"ErrGetPassWord": "Lỗi Khi Lấy Mật Khẩu Mã Hoá AppState !",
|
23
|
+
"ErrGenerateKey": "Lỗi Khi Tạo Mật Khẩu Cho AppState !",
|
24
|
+
"UnsupportedDevice": "Hệ Điều Hành Của Bạn Hiện Không Được Hỗ Trợ !",
|
25
|
+
"NotReadyToDecrypt": "Chưa Sẵn Sàng Để Giải Hóa Appstate !",
|
26
|
+
"DecryptSuccess": "Giải Hóa Appstate Thành Công !",
|
27
|
+
"ErrBackup": "Lỗi Khi Sao Lưu AppState, Hãy Thay AppState !",
|
28
|
+
"DecryptFailed": "Giải Hóa Không Thành Công, Hãy Thử Thay AppState !",
|
29
|
+
"InvaildAppState": "Không Nhận Dạng Được AppState, Xin Vui Lòng Thay AppState !",
|
30
|
+
"YourAppStatePass": "Mật Khẩu AppState Của Bạn Là: %1",
|
31
|
+
"BackupFailed": "Sao Lưu AppState Không Thành Công !",
|
32
|
+
"ScreenShotConsoleAndSendToAdmin": "Chụp Lại Màn Hình Dòng Này Và Gửi Vô Facebook: Fb.com/Lazic.Kanzu",
|
33
|
+
"DoneLogin": "Hoàn Thành Quá Trình Đăng Nhập !",
|
34
|
+
"AutoCheckUpdate": "Đang Kiểm Tra Bản Cập Nhật !",
|
35
|
+
"NewVersionFound": "Phiên Bản Mới Đã Được Cập Nhật: %1 => %2",
|
36
|
+
"AutoUpdate": "Tiến Hành Tự Động Cập Nhật Lên Phiên Bản Mới Nhất !",
|
37
|
+
"UpdateSuccess": "Nâng Cấp Phiên Bản Thành Công !",
|
38
|
+
"RestartAfterUpdate": "Đang Khởi Động Lại Để Phiên Bản Mới Có Hiệu Lực !",
|
39
|
+
"UpdateFailed": "Lỗi Khi Nâng Cấp Lên Phiên Bản Mới Nhất !",
|
40
|
+
"UseSupportToolAfterUpdateFailed": "Nâng Cấp Thức Bại, Tiến Hành Sử Dụng Công Cụ Hỗ Trợ !",
|
41
|
+
"InstallSupportTool": "Đang Tải Dụng Cụ Hộ Trợ Cho Fca !",
|
42
|
+
"NotiAfterUseToolFail": "Hãy Tự Fix Bằng Cách Nhập:",
|
43
|
+
"LocalVersion": "Bạn Hiện Đang Sử Dụng Phiên Bản: %1 !",
|
44
|
+
"EncryptSuccess": "Mã Hoá AppState Thành Công !",
|
45
|
+
"ProcessDone": "Kết Thúc Với: %1 !",
|
46
|
+
"InvaildMainColor": "%1 Không Phải Là Một Màu Hex !",
|
47
|
+
"IsNotABoolean": "%1 Không Phải Là Một Boolean, Cần Là true Hoặc false !",
|
48
|
+
"InvaildOption": "%1 Không Phải Là Một Lựa Chọn !",
|
49
|
+
"EncryptStateOff": "Tính Năng EncryptState Đã Bị Tắt !",
|
50
|
+
"WishMessage": [
|
51
|
+
"Chúc Bạn Một Ngày Tốt Lành Nhé !",
|
52
|
+
"Hãy Báo Cáo Với Admin Khi Có Lỗi Fca Nhé !",
|
53
|
+
"Cảm Ơn Đã Sử Dụng Fca Của Horizon !",
|
54
|
+
"Donate Tại: Momo: 0396301843, MBank: 0396301843"
|
55
|
+
]
|
56
|
+
},
|
57
|
+
"ExtraGetThread": {
|
58
|
+
"CreateDatabaseSuccess": "Khởi Tạo Thành Công Database Cho Nhóm: %1",
|
59
|
+
"CreateDatabaseFailure": "Khởi Tạo Thất Bại Database Của Nhóm: %1",
|
60
|
+
"alreadyUpdate": "%1 Đã Sẵn Sàng Để Update Database",
|
61
|
+
"updateDataSuccess": "Cập Nhật Dữ Liệu Cho Nhóm %1 Thành Công !",
|
62
|
+
"updateDataFailure": "Cập Nhật Dữ Liệu Cho Nhóm %1 Thất Bại !"
|
63
|
+
},
|
64
|
+
"ExtraUpTime": {
|
65
|
+
"Uptime": "Kết Nối Đến Server Uptime Thành Công !",
|
66
|
+
"PM2": "Đang Vào Chế Độ Uptime !",
|
67
|
+
"InPm2Mode": "Bạn Đang Ở Chế Độ Uptime PM2",
|
68
|
+
"NotSupport": "Không Hỗ Trợ Uptime Server!",
|
69
|
+
"Maintenance": "Server Uptime Đang Bảo Trì, Hãy Thử Lại Sau !"
|
70
|
+
},
|
71
|
+
"Src": {
|
72
|
+
"AutoRestart": "Tự Động Khởi Động Lại Sau: %1 Phút Nữa !",
|
73
|
+
"OnRestart": "Đang Restart..."
|
74
|
+
}
|
75
|
+
}
|
76
|
+
},
|
77
|
+
{
|
78
|
+
"Language": "en",
|
79
|
+
"Folder": {
|
80
|
+
"Index": {
|
81
|
+
"ErrAppState": "Appstate - Your Cookie Is Wrong, Please Replace It, Or Go To Incognito Browser Then Sign In And Try Again !",
|
82
|
+
"CheckPointLevelI": "CheckPoint Detected - Can't Login, Try Logout Then Login And Retrieve Appstate - Cookie !",
|
83
|
+
"UID": "Login as ID: %1",
|
84
|
+
"Area": "Area Of Account Is: %1",
|
85
|
+
"NoAreaData": "Can't Get Area Of Account !",
|
86
|
+
"OnLogin": "Currently logged ...",
|
87
|
+
"InvaildAccount": "Wrong Password Or Account !",
|
88
|
+
"TwoAuth": "You Currently On 2 Factor Security !",
|
89
|
+
"InvaildTwoAuthCode": "Wrong Code Two Factor Security !",
|
90
|
+
"ApprovalsErr": "Error When Login With Two Factor Security !",
|
91
|
+
"VerifiedCheck": "Confirm From Browser, Logging In...",
|
92
|
+
"ForceLoginNotEnable": "Can't Login, Try Enable 'forceLogin' !",
|
93
|
+
"SubmitErrSuccess": "Error Report Sent To Server !",
|
94
|
+
"ErrorWhileSendErr": "An error occurred while trying to send an error to the server !",
|
95
|
+
"OnProcess": "Start the Login Process !",
|
96
|
+
"BackupNoti": "Changing AppState From Backup, If This Continues, Contact Fb.com/Lazic.Kanzu",
|
97
|
+
"ErrGetPassWord": "Error Retrieving AppState Encryption Password !",
|
98
|
+
"ErrGenerateKey": "Error Creating Password For AppState !",
|
99
|
+
"UnsupportedDevice": "Your Operating System Is Currently Not Supported !",
|
100
|
+
"NotReadyToDecrypt": "Not Ready To Solve Appstate !",
|
101
|
+
"DecryptSuccess": "Successfully Appstate Solved !",
|
102
|
+
"ErrBackup": "Error When Backing Up AppState, Please Replace AppState !",
|
103
|
+
"DecryptFailed": "Solution Failed, Try Replacing AppState !",
|
104
|
+
"InvaildAppState": "AppState Not Recognized, Please Replace AppState !",
|
105
|
+
"YourAppStatePass": "Your AppState Password Is: %1",
|
106
|
+
"BackupFailed": "AppState Backup Failed !",
|
107
|
+
"ScreenShotConsoleAndSendToAdmin": "Take a Screenshot of This Line And Send It To Facebook: Fb.com/Lazic.Kanzu",
|
108
|
+
"DoneLogin": "Complete the Login Process !",
|
109
|
+
"AutoCheckUpdate": "Checking for Updates !",
|
110
|
+
"NewVersionFound": "New Version, Ready to Update: %1 => %2",
|
111
|
+
"AutoUpdate": "Perform Automatic Update to the Latest Version !",
|
112
|
+
"UpdateSuccess": "Upgrade Version Successfully !",
|
113
|
+
"RestartAfterUpdate": "Rebooting For New Version To Take Effect !",
|
114
|
+
"UpdateFailed": "Error When Upgrading To Latest Version !",
|
115
|
+
"UseSupportToolAfterUpdateFailed": "Upgrade Failed, Proceed to Using Support Tools !",
|
116
|
+
"InstallSupportTool": "Loading Support Tools For FCA !",
|
117
|
+
"NotiAfterUseToolFail": "Please Fix It Yourself By Entering:",
|
118
|
+
"LocalVersion": "You Are Currently Using Version: %1 !",
|
119
|
+
"EncryptSuccess": "Encrypt Appstate Success !",
|
120
|
+
"ProcessDone": "Process Done: %1 !",
|
121
|
+
"InvaildMainColor": "%1 Is Not A Hex Color Code !",
|
122
|
+
"IsNotABoolean": "%1 Is Not A Boolean, Need To Be true Or false !",
|
123
|
+
"EncryptStateOff": "Encryption Has Been Turned Off !",
|
124
|
+
"InvaildOption": "Invail Option: %1",
|
125
|
+
"WishMessage": [
|
126
|
+
"Have a Nice Day !",
|
127
|
+
"Please Report To Admin When There Is Error in FCA !",
|
128
|
+
"Thank You For Using Horizon's FCA !"
|
129
|
+
]
|
130
|
+
},
|
131
|
+
"ExtraGetThread": {
|
132
|
+
"CreateDatabaseSuccess": "Successfully Initiate Database for Group: %1",
|
133
|
+
"CreateDatabaseFailure": "Initialization of Group Database Failure: %1",
|
134
|
+
"alreadyUpdate": "%1 Ready to Update Database",
|
135
|
+
"updateDataSuccess": "Data Update for Group %1 Success!",
|
136
|
+
"updateDataFailure": "Data Update for Group %1 Failed!"
|
137
|
+
},
|
138
|
+
"ExtraUpTime": {
|
139
|
+
"Uptime": "Connecting To Server Uptime Succeeds!",
|
140
|
+
"PM2": "Trying to PM2 Mode!",
|
141
|
+
"InPm2Mode": "You Are In Uptime PM2 Mode !",
|
142
|
+
"NotSupport": "Your Operating System does not currently support Uptime Server !",
|
143
|
+
"Maintenance": "Server Uptime In Maintenance, Try Again Later!"
|
144
|
+
},
|
145
|
+
"Src": {
|
146
|
+
"AutoRestart": "Automatically Restart After: %1 Minutes !",
|
147
|
+
"OnRestart": "Restarting..."
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
151
|
+
]
|
package/README.md
CHANGED
@@ -1,5 +1,227 @@
|
|
1
|
-
|
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
2
|
|
3
|
-
|
3
|
+
# Unofficial Facebook Chat API
|
4
|
+
<a href="https://www.npmjs.com/package/node-ainzfb"><img alt="npm version" src="https://img.shields.io/npm/v/node-ainzfb.svg?style=flat-square"></a>
|
5
|
+
<img alt="version" src="https://img.shields.io/github/package-json/v/amogusdevlol/node-ainzfb?label=github&style=flat-square">
|
6
|
+
<a href="https://www.npmjs.com/package/node-ainzfb"><img src="https://img.shields.io/npm/dm/node-ainzfb.svg?style=flat-square" alt="npm downloads"></a>
|
7
|
+
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
|
4
8
|
|
5
|
-
|
9
|
+
Facebook now has an official API for chat bots [here](https://developers.facebook.com/docs/messenger-platform).
|
10
|
+
|
11
|
+
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.
|
12
|
+
|
13
|
+
_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.
|
14
|
+
|
15
|
+
See [below](#projects-using-this-api) for projects using this API.
|
16
|
+
|
17
|
+
See the [full changelog](/CHANGELOG.md) for release details.
|
18
|
+
|
19
|
+
## Install
|
20
|
+
If you just want to use node-ainzfb, you should use this command:
|
21
|
+
```bash
|
22
|
+
npm install node-ainzfb
|
23
|
+
```
|
24
|
+
It will download `node-ainzfb` from NPM repositories
|
25
|
+
|
26
|
+
### Bleeding edge
|
27
|
+
If you want to use bleeding edge (directly from github) to test new features or submit bug report, this is the command for you:
|
28
|
+
```bash
|
29
|
+
npm install node-ainzfb@latest
|
30
|
+
```
|
31
|
+
|
32
|
+
## Testing your bots
|
33
|
+
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/).
|
34
|
+
|
35
|
+
## Example Usage
|
36
|
+
```javascript
|
37
|
+
const login = require("node-ainzfb");
|
38
|
+
|
39
|
+
// Create simple echo bot
|
40
|
+
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
|
41
|
+
if(err) return console.error(err);
|
42
|
+
|
43
|
+
api.listen((err, message) => {
|
44
|
+
api.sendMessage(message.body, message.threadID);
|
45
|
+
});
|
46
|
+
});
|
47
|
+
```
|
48
|
+
|
49
|
+
Result:
|
50
|
+
|
51
|
+
<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">
|
52
|
+
|
53
|
+
|
54
|
+
## Documentation
|
55
|
+
|
56
|
+
You can see it [here](DOCS.md).
|
57
|
+
|
58
|
+
## Main Functionality
|
59
|
+
|
60
|
+
### Sending a message
|
61
|
+
#### api.sendMessage(message, threadID[, callback][, messageID])
|
62
|
+
|
63
|
+
Various types of message can be sent:
|
64
|
+
* *Regular:* set field `body` to the desired message as a string.
|
65
|
+
* *Sticker:* set a field `sticker` to the desired sticker ID.
|
66
|
+
* *File or image:* Set field `attachment` to a readable stream or an array of readable streams.
|
67
|
+
* *URL:* set a field `url` to the desired URL.
|
68
|
+
* *Emoji:* set field `emoji` to the desired emoji as a string and set field `emojiSize` with size of the emoji (`small`, `medium`, `large`)
|
69
|
+
|
70
|
+
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.
|
71
|
+
|
72
|
+
__Tip__: to find your own ID, you can look inside the cookies. The `userID` is under the name `c_user`.
|
73
|
+
|
74
|
+
__Example (Basic Message)__
|
75
|
+
```js
|
76
|
+
const login = require("node-ainzfb");
|
77
|
+
|
78
|
+
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
|
79
|
+
if(err) return console.error(err);
|
80
|
+
|
81
|
+
var yourID = "000000000000000";
|
82
|
+
var msg = "Hey!";
|
83
|
+
api.sendMessage(msg, yourID);
|
84
|
+
});
|
85
|
+
```
|
86
|
+
|
87
|
+
__Example (File upload)__
|
88
|
+
```js
|
89
|
+
const login = require("node-ainzfb");
|
90
|
+
|
91
|
+
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
|
92
|
+
if(err) return console.error(err);
|
93
|
+
|
94
|
+
// Note this example uploads an image called image.jpg
|
95
|
+
var yourID = "000000000000000";
|
96
|
+
var msg = {
|
97
|
+
body: "Hey!",
|
98
|
+
attachment: fs.createReadStream(__dirname + '/image.jpg')
|
99
|
+
}
|
100
|
+
api.sendMessage(msg, yourID);
|
101
|
+
});
|
102
|
+
```
|
103
|
+
|
104
|
+
------------------------------------
|
105
|
+
### Saving session.
|
106
|
+
|
107
|
+
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.
|
108
|
+
|
109
|
+
__Example__
|
110
|
+
|
111
|
+
```js
|
112
|
+
const fs = require("fs");
|
113
|
+
const login = require("node-ainzfb");
|
114
|
+
|
115
|
+
var credentials = {email: "FB_EMAIL", password: "FB_PASSWORD"};
|
116
|
+
|
117
|
+
login(credentials, (err, api) => {
|
118
|
+
if(err) return console.error(err);
|
119
|
+
|
120
|
+
fs.writeFileSync('appstate.json', JSON.stringify(api.getAppState()));
|
121
|
+
});
|
122
|
+
```
|
123
|
+
|
124
|
+
Alternative: Use [c3c-fbstate](https://github.com/lequanglam/c3c-fbstate) to get fbstate.json (appstate.json)
|
125
|
+
|
126
|
+
------------------------------------
|
127
|
+
|
128
|
+
### Listening to a chat
|
129
|
+
#### api.listen(callback)
|
130
|
+
|
131
|
+
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})`.
|
132
|
+
|
133
|
+
__Example__
|
134
|
+
|
135
|
+
```js
|
136
|
+
const fs = require("fs");
|
137
|
+
const login = require("node-ainzfb");
|
138
|
+
|
139
|
+
// Simple echo bot. It will repeat everything that you say.
|
140
|
+
// Will stop when you say '/stop'
|
141
|
+
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
142
|
+
if(err) return console.error(err);
|
143
|
+
|
144
|
+
api.setOptions({listenEvents: true});
|
145
|
+
|
146
|
+
var stopListening = api.listenMqtt((err, event) => {
|
147
|
+
if(err) return console.error(err);
|
148
|
+
|
149
|
+
api.markAsRead(event.threadID, (err) => {
|
150
|
+
if(err) console.error(err);
|
151
|
+
});
|
152
|
+
|
153
|
+
switch(event.type) {
|
154
|
+
case "message":
|
155
|
+
if(event.body === '/stop') {
|
156
|
+
api.sendMessage("Goodbye…", event.threadID);
|
157
|
+
return stopListening();
|
158
|
+
}
|
159
|
+
api.sendMessage("TEST BOT: " + event.body, event.threadID);
|
160
|
+
break;
|
161
|
+
case "event":
|
162
|
+
console.log(event);
|
163
|
+
break;
|
164
|
+
}
|
165
|
+
});
|
166
|
+
});
|
167
|
+
```
|
168
|
+
|
169
|
+
## FAQS
|
170
|
+
|
171
|
+
1. How do I run tests?
|
172
|
+
> 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`.
|
173
|
+
|
174
|
+
2. Why doesn't `sendMessage` always work when I'm logged in as a page?
|
175
|
+
> Pages can't start conversations with users directly; this is to prevent pages from spamming users.
|
176
|
+
|
177
|
+
3. What do I do when `login` doesn't work?
|
178
|
+
> 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).
|
179
|
+
|
180
|
+
4. How can I avoid logging in every time? Can I log into a previous session?
|
181
|
+
> 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.
|
182
|
+
|
183
|
+
5. Do you support sending messages as a page?
|
184
|
+
> Yes, set the pageID option on login (this doesn't work if you set it using api.setOptions, it affects the login process).
|
185
|
+
> ```js
|
186
|
+
> login(credentials, {pageID: "000000000000000"}, (err, api) => { … }
|
187
|
+
> ```
|
188
|
+
|
189
|
+
6. I'm getting some crazy weird syntax error like `SyntaxError: Unexpected token [`!!!
|
190
|
+
> Please try to update your version of node.js before submitting an issue of this nature. We like to use new language features.
|
191
|
+
|
192
|
+
7. I don't want all of these logging messages!
|
193
|
+
> You can use `api.setOptions` to silence the logging. You get the `api` object from `login` (see example above). Do
|
194
|
+
> ```js
|
195
|
+
> api.setOptions({
|
196
|
+
> logLevel: "silent"
|
197
|
+
> });
|
198
|
+
> ```
|
199
|
+
|
200
|
+
<a name="projects-using-this-api"></a>
|
201
|
+
## Projects using this API:
|
202
|
+
|
203
|
+
- [c3c](https://github.com/lequanglam/c3c) - A bot that can be customizable using plugins. Support Facebook & Discord.
|
204
|
+
|
205
|
+
## Projects using this API (original repository, facebook-chat-api):
|
206
|
+
|
207
|
+
- [Messer](https://github.com/mjkaufer/Messer) - Command-line messaging for Facebook Messenger
|
208
|
+
- [messen](https://github.com/tomquirk/messen) - Rapidly build Facebook Messenger apps in Node.js
|
209
|
+
- [Concierge](https://github.com/concierge/Concierge) - Concierge is a highly modular, easily extensible general purpose chat bot with a built in package manager
|
210
|
+
- [Marc Zuckerbot](https://github.com/bsansouci/marc-zuckerbot) - Facebook chat bot
|
211
|
+
- [Marc Thuckerbot](https://github.com/bsansouci/lisp-bot) - Programmable lisp bot
|
212
|
+
- [MarkovsInequality](https://github.com/logicx24/MarkovsInequality) - Extensible chat bot adding useful functions to Facebook Messenger
|
213
|
+
- [AllanBot](https://github.com/AllanWang/AllanBot-Public) - Extensive module that combines the facebook api with firebase to create numerous functions; no coding experience is required to implement this.
|
214
|
+
- [Larry Pudding Dog Bot](https://github.com/Larry850806/facebook-chat-bot) - A facebook bot you can easily customize the response
|
215
|
+
- [fbash](https://github.com/avikj/fbash) - Run commands on your computer's terminal over Facebook Messenger
|
216
|
+
- [Klink](https://github.com/KeNt178/klink) - This Chrome extension will 1-click share the link of your active tab over Facebook Messenger
|
217
|
+
- [Botyo](https://github.com/ivkos/botyo) - Modular bot designed for group chat rooms on Facebook
|
218
|
+
- [matrix-puppet-facebook](https://github.com/matrix-hacks/matrix-puppet-facebook) - A facebook bridge for [matrix](https://matrix.org)
|
219
|
+
- [facebot](https://github.com/Weetbix/facebot) - A facebook bridge for Slack.
|
220
|
+
- [Botium](https://github.com/codeforequity-at/botium-core) - The Selenium for Chatbots
|
221
|
+
- [Messenger-CLI](https://github.com/AstroCB/Messenger-CLI) - A command-line interface for sending and receiving messages through Facebook Messenger.
|
222
|
+
- [AssumeZero-Bot](https://github.com/AstroCB/AssumeZero-Bot) – A highly customizable Facebook Messenger bot for group chats.
|
223
|
+
- [Miscord](https://github.com/Bjornskjald/miscord) - An easy-to-use Facebook bridge for Discord.
|
224
|
+
- [chat-bridge](https://github.com/rexx0520/chat-bridge) - A Messenger, Telegram and IRC chat bridge.
|
225
|
+
- [messenger-auto-reply](https://gitlab.com/theSander/messenger-auto-reply) - An auto-reply service for Messenger.
|
226
|
+
- [BotCore](https://github.com/AstroCB/BotCore) – A collection of tools for writing and managing Facebook Messenger bots.
|
227
|
+
- [mnotify](https://github.com/AstroCB/mnotify) – A command-line utility for sending alerts and notifications through Facebook Messenger.
|
package/StateCrypt.js
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
/* eslint-disable linebreak-style */
|
2
|
+
const crypto = require('crypto');
|
3
|
+
const aes = require("aes-js");
|
4
|
+
|
5
|
+
function encryptState(data, key) {
|
6
|
+
let hashEngine = crypto.createHash("sha256");
|
7
|
+
let hashKey = hashEngine.update(key).digest();
|
8
|
+
let bytes = aes.utils.utf8.toBytes(data);
|
9
|
+
let aesCtr = new aes.ModeOfOperation.ctr(hashKey);
|
10
|
+
let encryptedData = aesCtr.encrypt(bytes);
|
11
|
+
return aes.utils.hex.fromBytes(encryptedData);
|
12
|
+
}
|
13
|
+
|
14
|
+
function decryptState(data, key) {
|
15
|
+
let hashEngine = crypto.createHash("sha256");
|
16
|
+
let hashKey = hashEngine.update(key).digest();
|
17
|
+
let encryptedBytes = aes.utils.hex.toBytes(data);
|
18
|
+
let aesCtr = new aes.ModeOfOperation.ctr(hashKey);
|
19
|
+
let decryptedData = aesCtr.decrypt(encryptedBytes);
|
20
|
+
return aes.utils.utf8.fromBytes(decryptedData);
|
21
|
+
}
|
22
|
+
module.exports = { encryptState,decryptState };
|
package/broadcast.js
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module.exports = function({ api }) {
|
2
|
+
return function() {
|
3
|
+
switch (require("../../FastConfigFca.json").BroadCast) {
|
4
|
+
case true:
|
5
|
+
{
|
6
|
+
BroadCast();
|
7
|
+
return setInterval(() => {
|
8
|
+
try {
|
9
|
+
var test = api.getCurrentUserID();
|
10
|
+
if (test) return;
|
11
|
+
else process.exit(1);
|
12
|
+
} catch (e) {
|
13
|
+
console.log(e);
|
14
|
+
}
|
15
|
+
return BroadCast();
|
16
|
+
}, 1800 * 1000);
|
17
|
+
}
|
18
|
+
case false:
|
19
|
+
{
|
20
|
+
break;
|
21
|
+
}
|
22
|
+
default:
|
23
|
+
{
|
24
|
+
break;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
function BroadCast() {
|
31
|
+
try {
|
32
|
+
var logger = require('./logger');
|
33
|
+
var Fetch = require('got');
|
34
|
+
Fetch.get("https://raw.githubusercontent.com/amogusdevlol/FCASUS-DATA/main/FcaSusBC.json").then(async(res) => {
|
35
|
+
var random = JSON.parse(res.body.toString())[Math.floor(Math.random() * JSON.parse(res.body.toString()).length)] || "Sanaol";
|
36
|
+
logger(random, "[ FCA-SUS ]");
|
37
|
+
});
|
38
|
+
} catch (e) {
|
39
|
+
console.log(e);
|
40
|
+
return;
|
41
|
+
}
|
42
|
+
}
|