naughty-fb-chatify 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/README.md +4 -224
  2. package/index.js +16 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,225 +1,5 @@
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
1
  # Unofficial Facebook Chat API
4
- <a href="https://www.npmjs.com/package/fca-unofficial"><img alt="npm version" src="https://img.shields.io/npm/v/fca-unofficial.svg?style=flat-square"></a>
5
- <img alt="version" src="https://img.shields.io/github/package-json/v/fca-unofficial/fca-unofficial?label=github&style=flat-square">
6
- <a href="https://www.npmjs.com/package/fca-unofficial"><img src="https://img.shields.io/npm/dm/fca-unofficial.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)
8
-
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 fca-unofficial, you should use this command:
21
- ```bash
22
- npm install fca-unofficial
23
- ```
24
- It will download `fca-unofficial` 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 fca-unofficial/fca-unofficial
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("fca-unofficial");
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("fca-unofficial");
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("fca-unofficial");
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("fca-unofficial");
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("fca-unofficial");
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.
2
+ ## Made By Maryam Rajput
3
+ ### Fca For Naughty-Bot-V1
4
+ #### Will Write The Next Garbage Later ):
5
+ ##### FB: facebook.com/naugh7y.dev
package/index.js CHANGED
@@ -1,5 +1,19 @@
1
1
  "use strict";
2
-
2
+ console.log(`┌────────────────────────────────────────────────────────────────────────────────┐
3
+ │ │
4
+ │ │
5
+ │ │
6
+ │ ███╗ ██╗ █████╗ ██╗ ██╗ ██████╗ ██╗ ██╗████████╗██╗ ██╗ │
7
+ │ ████╗ ██║██╔══██╗██║ ██║██╔════╝ ██║ ██║╚══██╔══╝╚██╗ ██╔╝ │
8
+ │ ██╔██╗ ██║███████║██║ ██║██║ ███╗███████║ ██║ ╚████╔╝ │
9
+ │ ██║╚██╗██║██╔══██║██║ ██║██║ ██║██╔══██║ ██║ ╚██╔╝ │
10
+ │ ██║ ╚████║██║ ██║╚██████╔╝╚██████╔╝██║ ██║ ██║ ██║ │
11
+ │ ╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ │
12
+ │ │
13
+ │ │
14
+ │ naughty-fb-chatify │
15
+ │ Version: 1.0.1 │
16
+ └────────────────────────────────────────────────────────────────────────────────┘`);
3
17
  var utils = require("./utils");
4
18
  var cheerio = require("cheerio");
5
19
  var log = require("npmlog");
@@ -599,4 +613,4 @@ function login(loginData, options, callback) {
599
613
  loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
600
614
  return returnPromise;
601
615
  }
602
- module.exports = login;
616
+ module.exports = login;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naughty-fb-chatify",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Fca For Naughty-Bot-V1",
5
5
  "scripts": {
6
6
  "test": "mocha",