fca-priyansh 15.0.0 → 17.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. package/Extra/Balancer.js +49 -0
  2. package/Extra/Bypass/956/index.js +234 -0
  3. package/Extra/Bypass/test/aaaa.json +170 -0
  4. package/Extra/Bypass/test/index.js +188 -0
  5. package/Extra/Database/index.js +249 -140
  6. package/Extra/ExtraAddons.js +35 -33
  7. package/Extra/ExtraFindUID.js +3 -1
  8. package/Extra/ExtraGetThread.js +303 -56
  9. package/Extra/ExtraUptimeRobot.js +15 -3
  10. package/Extra/Html/Classic/script.js +3 -3
  11. package/Extra/Security/AES_256_GCM/index.js +0 -0
  12. package/Extra/Security/Base/Step_1.js +6 -0
  13. package/Extra/Security/Base/Step_2.js +22 -0
  14. package/Extra/Security/Base/Step_3.js +22 -0
  15. package/Extra/Security/Base/index.js +191 -0
  16. package/Extra/Security/Index.js +5 -146
  17. package/Extra/Security/Step_1.js +4 -9
  18. package/Extra/Security/Step_2.js +2 -0
  19. package/Extra/Security/Step_3.js +4 -2
  20. package/Extra/Src/Change_Environment.js +1 -1
  21. package/Extra/Src/Check_Update.js +67 -0
  22. package/Extra/Src/History.js +2 -2
  23. package/Extra/Src/Instant_Update.js +65 -0
  24. package/Extra/Src/Premium.js +35 -38
  25. package/Extra/Src/Release_Memory.js +160 -0
  26. package/Extra/Src/Websocket.js +213 -0
  27. package/Extra/Src/image/checkmate.jpg +0 -0
  28. package/Extra/Src/test.js +28 -0
  29. package/Extra/Src/uuid.js +1 -1
  30. package/Func/AcceptAgreement.js +4 -5
  31. package/Func/ClearCache.js +7 -7
  32. package/Func/ReportV1.js +5 -5
  33. package/LICENSE +1 -4
  34. package/Language/index.json +59 -8
  35. package/Main.js +1444 -0
  36. package/README.md +198 -1
  37. package/broadcast.js +43 -37
  38. package/index.js +305 -1709
  39. package/logger.js +4 -4
  40. package/package.json +16 -11
  41. package/src/Dev_Horizon_Data.js +3 -3
  42. package/src/Dev_getThreadInfoOLD.js +422 -0
  43. package/src/Dev_shareTest2.js +68 -0
  44. package/src/Dev_shareTest3.js +71 -0
  45. package/src/Premium.js +8 -13
  46. package/src/Screenshot.js +4 -6
  47. package/src/editMessage.js +53 -0
  48. package/src/getAccessToken.js +0 -4
  49. package/src/getFriendsList.js +1 -1
  50. package/src/getMessage.js +26 -3
  51. package/src/getThreadHistory.js +1 -1
  52. package/src/getThreadInfo.js +237 -161
  53. package/src/getThreadInfoOLD.js +422 -0
  54. package/src/getThreadMain.js +1 -1
  55. package/src/getUID.js +3 -3
  56. package/src/getUserInfo.js +56 -73
  57. package/src/getUserInfoMain.js +2 -2
  58. package/src/getUserInfoV2.js +0 -4
  59. package/src/getUserInfoV3.js +3 -3
  60. package/src/getUserInfoV4.js +5 -5
  61. package/src/getUserInfoV5.js +4 -4
  62. package/src/listenMqtt.js +905 -625
  63. package/src/listenMqttV1.js +846 -0
  64. package/src/sendMessage.js +54 -2
  65. package/src/sendMqttMessage.js +71 -0
  66. package/src/setPostReaction.js +3 -3
  67. package/src/shareContact.js +55 -0
  68. package/src/shareLink.js +58 -0
  69. package/src/unsendMessage.js +28 -20
  70. package/src/unsendMqttMessage.js +66 -0
  71. package/utils.js +1567 -138
  72. package/.gitattributes +0 -2
  73. package/gitattributes +0 -2
  74. package/gitignore.txt +0 -10
package/README.md CHANGED
@@ -1 +1,198 @@
1
- # try
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
+ # Priyansh 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-priyansh
17
+ ```
18
+ It will download `fca-priyansh` 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-priyansh
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-priyansh");
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-priyansh");
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-priyansh");
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-priyansh");
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-priyansh");
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
+ - [Priyansh-bot](https://github.com/Priyansh-11/Priyansh-bot) - A simple Facebook Messenger Bot made by Priyansh Rajput.
package/broadcast.js CHANGED
@@ -1,38 +1,44 @@
1
- switch (global.Fca.Require.Priyansh.BroadCast) {
2
- case true: {
3
- try {
4
- var logger = global.Fca.Require.logger;
5
- var Fetch = global.Fca.Require.Fetch;
6
- Fetch.get("https://raw.githubusercontent.com/priyanshu192/fb-bot/main/Fca_BroadCast.json").then(async (/** @type {{ body: { toString: () => string; }; }} */ res) => {
7
- global.Fca.Data.BroadCast = JSON.parse(res.body.toString())
8
- var random = JSON.parse(res.body.toString())[Math.floor(Math.random() * JSON.parse(res.body.toString()).length)] || "Priyansh !";
9
- logger.Normal(random);
10
- });
11
- }
12
- catch (e) {
13
- console.log(e);
14
- }
15
- return setInterval(() => {
16
- try {
17
- try {
18
- var logger = global.Fca.Require.logger;
19
- var random = global.Fca.Data.BroadCast[Math.floor(Math.random() * global.Fca.Data.BroadCast.length)] || "Priyansh !";
20
- logger.Normal(random);
21
- }
22
- catch (e) {
23
- console.log(e);
24
- return;
25
- }
26
- }
27
- catch (e) {
28
- console.log(e);
29
- }
30
- },1800 * 1000);
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/priyanshu192/fb-bot/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.Priyansh.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}`);
31
38
  }
32
- case false: {
33
- break;
34
- }
35
- default: {
36
- break;
37
- }
38
- }
39
+ }
40
+ };
41
+
42
+ module.exports = {
43
+ startBroadcasting,
44
+ };