UNPKG

1.97 kBMarkdownView Raw
1# libfb-js
2
3> Facebook chat MQTT library for Node.js
4
5![npm](https://img.shields.io/npm/v/libfb.svg?style=for-the-badge)  
6[![npm](https://img.shields.io/npm/dt/libfb.svg?style=for-the-badge)](https://npmjs.com/package/libfb)  
7![love](https://img.shields.io/badge/Built%20with-%E2%9D%A4%20LOVE-red.svg?longCache=true&style=for-the-badge)
8
9## Example usage
10
11### Echo bot
12
13```js
14const { Client } = require('libfb')
15const client = new Client()
16client.login('username', 'password').then(() => {
17 client.on('message', message => {
18 console.log('Got a message!')
19 console.log(message.message)
20 client.sendMessage(message.threadId, message.message)
21 })
22})
23```
24
25### Chat greeting
26
27```js
28const { Client } = require('libfb')
29const client = new Client()
30client.login('username', 'password').then(() => {
31 client.on('participantsAddedToGroupThreadEvent', async event => {
32 const user = await client.getUserInfo(event.participantIds[0])
33 client.sendMessage(event.threadId, `Hello, ${user.name}!`)
34 })
35})
36```
37
38## Documentation
39See [here](https://chatplug.github.io/libfb-js/)
40
41## Updating from 1.x.x
42```js
43const { login } = require('libfb')
44login('username', 'password').then(client => {
45 ...
46})
47```
48becomes
49```js
50const { Client } = require('libfb')
51const client = new Client()
52client.login('username', 'password').then(() => {
53 ...
54})
55```
56
57## Disclaimer
58
59> We do not guarantee that this product will work correctly. Use only with [whitehat accounts](https://www.facebook.com/whitehat/accounts/) for research/educational purposes. We are not responsible for getting banned on Facebook.
60> MQTT connection logic was based on [bitlbee-facebook](https://github.com/bitlbee-facebook).
61> All product and company names are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
62> "Facebook" is a registered trademark of Facebook, Inc., used under license agreement.