fca-smart-shankar 10.9.1 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/.replit +12 -3
  2. package/.upm/store.json +1 -1
  3. package/CHANGELOG.md +2 -0
  4. package/LICENSE-MIT +21 -0
  5. package/README.md +175 -30
  6. package/generated-icon.png +0 -0
  7. package/index.js +511 -414
  8. package/package.json +370 -85
  9. package/replit.nix +5 -0
  10. package/shankar-fca.json +4 -0
  11. package/src/addExternalModule.js +14 -5
  12. package/src/addUserToGroup.js +56 -20
  13. package/src/changeAdminStatus.js +44 -20
  14. package/src/changeArchivedStatus.js +25 -11
  15. package/src/changeAvatar.js +136 -0
  16. package/src/{changeAvt.js → changeAvatarV2.js} +3 -2
  17. package/src/changeBio.js +26 -15
  18. package/src/changeBlockedStatus.js +21 -8
  19. package/src/changeBlockedStatusMqtt.js +80 -0
  20. package/src/changeCover.js +73 -0
  21. package/src/changeGroupImage.js +53 -24
  22. package/src/changeName.js +79 -0
  23. package/src/changeNickname.js +27 -13
  24. package/src/changeThreadColor.js +22 -19
  25. package/src/changeThreadEmoji.js +24 -11
  26. package/src/changeUsername.js +59 -0
  27. package/src/createCommentPost.js +230 -0
  28. package/src/createNewGroup.js +38 -20
  29. package/src/createPoll.js +27 -16
  30. package/src/createPost.js +277 -0
  31. package/src/data/getThreadInfo.json +1 -0
  32. package/src/deleteMessage.js +24 -13
  33. package/src/deleteThread.js +25 -12
  34. package/src/editMessage.js +71 -53
  35. package/src/editMessageOld.js +67 -0
  36. package/src/follow.js +74 -0
  37. package/src/forwardAttachment.js +27 -15
  38. package/src/getAccess.js +112 -0
  39. package/src/getAvatarUser.js +78 -0
  40. package/src/getCurrentUserID.js +1 -1
  41. package/src/getEmojiUrl.js +10 -8
  42. package/src/getFriendsList.js +25 -15
  43. package/src/getMessage.js +813 -81
  44. package/src/getRegion.js +7 -0
  45. package/src/getThreadHistory.js +241 -98
  46. package/src/getThreadHistoryDeprecated.js +93 -0
  47. package/src/getThreadInfo.js +90 -287
  48. package/src/getThreadInfoDeprecated.js +80 -0
  49. package/src/getThreadList.js +214 -157
  50. package/src/getThreadListDeprecated.js +75 -0
  51. package/src/getThreadPictures.js +39 -19
  52. package/src/getUID.js +113 -50
  53. package/src/getUserID.js +18 -14
  54. package/src/getUserInfo.js +65 -71
  55. package/src/handleFriendRequest.js +24 -13
  56. package/src/handleMessageRequest.js +36 -20
  57. package/src/httpGet.js +34 -18
  58. package/src/httpPost.js +35 -18
  59. package/src/httpPostFormData.js +53 -24
  60. package/src/listenMqtt.js +680 -944
  61. package/src/listenNotification.js +85 -0
  62. package/src/logout.js +22 -15
  63. package/src/markAsDelivered.js +25 -15
  64. package/src/markAsRead.js +45 -27
  65. package/src/markAsReadAll.js +21 -14
  66. package/src/markAsSeen.js +28 -18
  67. package/src/muteThread.js +17 -12
  68. package/src/pinMessage.js +59 -0
  69. package/src/refreshFb_dtsg.js +89 -0
  70. package/src/removeUserFromGroup.js +47 -17
  71. package/src/resolvePhotoUrl.js +21 -13
  72. package/src/searchForThread.js +23 -13
  73. package/src/searchStickers.js +53 -0
  74. package/src/sendMessage.js +178 -117
  75. package/src/sendMessageMqtt.js +322 -0
  76. package/src/sendTypingIndicator.js +46 -16
  77. package/src/sendTypingIndicatorV2.js +28 -0
  78. package/src/setMessageReaction.js +33 -20
  79. package/src/setMessageReactionMqtt.js +62 -0
  80. package/src/setPostReaction.js +105 -95
  81. package/src/setProfileGuard.js +45 -0
  82. package/src/setStoryReaction.js +64 -0
  83. package/src/setTitle.js +34 -18
  84. package/src/shareContact.js +92 -37
  85. package/src/shareLink.js +5 -4
  86. package/src/stopListenMqtt.js +26 -0
  87. package/src/threadColors.js +110 -18
  88. package/src/unfriend.js +18 -9
  89. package/src/unsendMessage.js +31 -34
  90. package/src/uploadAttachment.js +94 -0
  91. package/test/data/shareAttach.js +1 -1
  92. package/test/test.js +1 -1
  93. package/utils.js +1393 -2918
  94. package/.cache/replit/env/latest +0 -56
  95. package/.cache/replit/env/latest.json +0 -1
  96. package/.cache/replit/modules/nodejs-14.res +0 -1
  97. package/.cache/replit/modules/replit.res +0 -1
  98. package/.cache/replit/modules/web.res +0 -1
  99. package/.cache/replit/modules.stamp +0 -0
  100. package/.cache/typescript/5.5/package.json +0 -1
  101. package/.config/configstore/update-notifier-npm.json +0 -4
  102. package/.gitattributes +0 -2
  103. package/Extra/Balancer.js +0 -49
  104. package/Extra/Bypass/956/index.js +0 -234
  105. package/Extra/Bypass/test/aaaa.json +0 -170
  106. package/Extra/Bypass/test/index.js +0 -188
  107. package/Extra/Database/index.js +0 -469
  108. package/Extra/ExtraAddons.js +0 -82
  109. package/Extra/ExtraFindUID.js +0 -62
  110. package/Extra/ExtraGetThread.js +0 -365
  111. package/Extra/ExtraScreenShot.js +0 -430
  112. package/Extra/ExtraUptimeRobot.js +0 -38
  113. package/Extra/Html/Classic/script.js +0 -119
  114. package/Extra/Html/Classic/style.css +0 -8
  115. package/Extra/Security/AES_256_GCM/index.js +0 -0
  116. package/Extra/Security/Base/Step_1.js +0 -6
  117. package/Extra/Security/Base/Step_2.js +0 -22
  118. package/Extra/Security/Base/Step_3.js +0 -22
  119. package/Extra/Security/Base/index.js +0 -191
  120. package/Extra/Security/Index.js +0 -5
  121. package/Extra/Security/Step_1.js +0 -6
  122. package/Extra/Security/Step_2.js +0 -22
  123. package/Extra/Security/Step_3.js +0 -22
  124. package/Extra/Src/Change_Environment.js +0 -24
  125. package/Extra/Src/Check_Update.js +0 -67
  126. package/Extra/Src/History.js +0 -115
  127. package/Extra/Src/Instant_Update.js +0 -65
  128. package/Extra/Src/Last-Run.js +0 -65
  129. package/Extra/Src/Premium.js +0 -81
  130. package/Extra/Src/Release_Memory.js +0 -160
  131. package/Extra/Src/Websocket.js +0 -213
  132. package/Extra/Src/image/checkmate.jpg +0 -0
  133. package/Extra/Src/test.js +0 -28
  134. package/Extra/Src/uuid.js +0 -137
  135. package/Func/AcceptAgreement.js +0 -31
  136. package/Func/ClearCache.js +0 -64
  137. package/Func/ReportV1.js +0 -54
  138. package/LICENSE +0 -678
  139. package/Language/index.json +0 -228
  140. package/Main.js +0 -1444
  141. package/SECURITY.md +0 -18
  142. package/broadcast.js +0 -44
  143. package/logger.js +0 -66
  144. package/src/Dev_Horizon_Data.js +0 -125
  145. package/src/Dev_getThreadInfoOLD.js +0 -422
  146. package/src/Dev_shareTest2.js +0 -68
  147. package/src/Dev_shareTest3.js +0 -71
  148. package/src/Premium.js +0 -25
  149. package/src/Screenshot.js +0 -83
  150. package/src/getAccessToken.js +0 -28
  151. package/src/getThreadInfoOLD.js +0 -422
  152. package/src/getThreadMain.js +0 -220
  153. package/src/getUserInfoMain.js +0 -65
  154. package/src/getUserInfoV2.js +0 -32
  155. package/src/getUserInfoV3.js +0 -63
  156. package/src/getUserInfoV4.js +0 -55
  157. package/src/getUserInfoV5.js +0 -61
  158. package/src/listenMqttV1.js +0 -846
  159. package/src/sendMqttMessage.js +0 -71
  160. package/src/unsendMqttMessage.js +0 -66
  161. package/test/Database_Test.js +0 -4
  162. package/test/Db2.js +0 -530
  163. package/test/Shankar_Database/A_README.md +0 -1
  164. package/test/Shankar_Database/Database.db +0 -0
  165. package/test/env/.env +0 -0
  166. package/test/example-db.db +0 -0
  167. package/test/memoryleak.js +0 -18
  168. package/test/testname.js +0 -1342
  169. package/test/testv2.js +0 -3
package/.replit CHANGED
@@ -1,8 +1,17 @@
1
- modules = ["nodejs-14", "web"]
2
- run = "node index.js"
1
+ entrypoint = "index.js"
2
+ modules = ["nodejs-20"]
3
+ hidden = [".config", "package-lock.json"]
4
+
5
+ [gitHubImport]
6
+ requiredFiles = [".replit", "replit.nix", "package.json", "package-lock.json"]
3
7
 
4
8
  [nix]
5
9
  channel = "stable-24_05"
6
10
 
11
+ [unitTest]
12
+ language = "nodejs"
13
+
7
14
  [deployment]
8
- run = ["sh", "-c", "node index.js"]
15
+ run = ["node", "index.js"]
16
+ deploymentTarget = "cloudrun"
17
+ ignorePorts = false
package/.upm/store.json CHANGED
@@ -1 +1 @@
1
- {"version":2,"languages":{"nodejs-npm":{"specfileHash":"3039add15c652fa50acf2c7c3de87738","lockfileHash":"4b5ed40f46aafc488b8e83e33ea2c216"}}}
1
+ {"version":2,"languages":{"nodejs-npm":{"specfileHash":"9c1daf70fa913035bdc35b14bd0cd834","lockfileHash":"afe00810f9cef88d191fa428eb7d1d88"}}}
package/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ # Changelog
2
+ Too lazy to write changelog, sorry! (will write changelog in the next release, through.)
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Avery, Benjamin, David, Maude
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,53 +1,198 @@
1
- [![Socket Badge](https://www.npmjs.com/package/fca-smart-shankar)](https://www.npmjs.com/package/fca-smart-shankar)
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
- # The following are not allowed here and a little note:
3
+ # Shankar Facebook Chat API
4
4
 
5
- 🎆
5
+ Facebook now has an official API for chat bots [here](https://developers.facebook.com/docs/messenger-platform).
6
6
 
7
- ## Important !
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
8
 
9
- <img width="517" alt="Reason" src="https://i.imgur.com/IEwl35Q.gif">
10
- This project is no longer being developed because the project owner lacks high security capabilities, leading to potential security vulnerabilities. Therefore, the project will be permanently suspended.
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.
11
10
 
12
- Special Thanks:
13
- ![image](https://github.com/SHANKAR-PROJECT/fca-smart-shankar)
11
+ See [below](#projects-using-this-api) for projects using this API.
14
12
 
15
- ## Important !
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
16
19
 
17
- This package require NodeJS 14.17.0 to work properly.
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
+ ```
18
25
 
19
- ## Notification !
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/).
20
28
 
21
- Original Project(Deprecated): https://github.com/SHANKAR-PROJECT/fca-smart-shankar
29
+ ## Example Usage
30
+ ```javascript
31
+ const login = require("fca-smart-shankar");
22
32
 
33
+ // Create simple echo bot
34
+ login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
35
+ if(err) return console.error(err);
23
36
 
24
- SHANKAR-PROJECT(22/11/2024)
37
+ api.listen((err, message) => {
38
+ api.sendMessage(message.body, message.threadID);
39
+ });
40
+ });
41
+ ```
25
42
 
26
- ## Support For :
43
+ Result:
27
44
 
28
- + Support English, India !,
29
- + All bot if using listenMqtt first.
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">
30
46
 
31
- # Api Cho ChatBot Messenger
32
47
 
33
- ```bash
34
- npm i fca-smart-shankar
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
+ });
35
79
  ```
36
- or
37
- ```bash
38
- npm install fca-smart-shankar
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
+ });
39
96
  ```
40
97
 
41
- ```bash
42
- npm install fca-smart-shankard@latest
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
+ });
43
116
  ```
44
- and
45
- ```bash
46
- npm i fca-smart-shankar@latest
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
+ });
47
161
  ```
48
162
 
49
- ## SHANKAR PROJECT
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
+ > ```
50
193
 
51
- ## FACEBOOK
194
+ <a name="projects-using-this-api"></a>
195
+ ## Projects using this API:
52
196
 
53
- FACEBOOK => [Link](https://www.facebook.com/shankar.suman.98622733?mibextid=JRoKGi)
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.
Binary file