npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fca-sakibin-new

v1.1.8

Published

New fca after update

Downloads

99

Readme


fca-sakibin-new Facebook

A new Facebook Chat API for bots and automation! 🚀

🔗 Admin: Sakibin | Telegram Support | API


Install

If you want to use fca-sakibin-new, run this command:

npm install fca-sakibin-new

This will download lmw-api-fb from NPM repositories.


Bleeding Edge

To test new features or submit bug reports using the latest version from GitHub, use this command:

npm install tataJubjang/lmw-api-fb

Testing Your Bots

To test your bots without creating a new Facebook account, use Facebook Whitehat Accounts.


API Usage 📘

Create an Echo Bot Example

const login = require("fca-sakibin-new");

login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
    if(err) return console.error(err);

    api.listen((err, message) => {
        api.sendMessage(message.body, message.threadID);
    });
});

Here's how it looks when your bot responds:

Echo Bot Screenshot


Main Functionality ✨

Sending a Message

api.sendMessage(message, threadID, [callback], [messageID])

Messages can be:

  • Text: Set body to the desired message.
  • Sticker: Set sticker to the sticker ID.
  • File/Image: Set attachment to a readable stream or array of streams.
  • URL: Set url to the desired URL.
  • Emoji: Set emoji and emojiSize (small, medium, large).

Example: Sending a Basic Message

const login = require("fca-sakibin-new");

login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
    if(err) return console.error(err);

    const yourID = "000000000000000";
    const msg = "Hey!";
    api.sendMessage(msg, yourID);
});

Example: Sending a File

const login = require("fca-sakibin-new");
const fs = require("fs");

login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
    if(err) return console.error(err);

    const yourID = "000000000000000";
    const msg = {
        body: "Hey!",
        attachment: fs.createReadStream(__dirname + '/image.jpg')
    };
    api.sendMessage(msg, yourID);
});

Save Session 🛠️

To avoid logging in every time, save AppState (cookies, etc.) to a file.

Example: Saving AppState

const fs = require("fs");
const login = require("fca-sakibin-new");

const credentials = {email: "FB_EMAIL", password: "FB_PASSWORD"};

login(credentials, (err, api) => {
    if(err) return console.error(err);

    fs.writeFileSync('appstate.json', JSON.stringify(api.getAppState()));
});

You can also use c3c-fbstate to get fbstate.json.


Listen to a Chat 🧏‍♂️

Use api.listenMqtt(callback) to listen for chat messages.

Example: Simple Echo Bot

const fs = require("fs");
const login = require("fca-sakibin-new");

login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
    if(err) return console.error(err);

    api.setOptions({listenEvents: true});

    const stopListening = api.listenMqtt((err, event) => {
        if(err) return console.error(err);

        api.markAsRead(event.threadID, (err) => {
            if(err) console.error(err);
        });

        switch(event.type) {
            case "message":
                if(event.body === '/stop') {
                    api.sendMessage("Goodbye…", event.threadID);
                    return stopListening();
                }
                api.sendMessage("TEST BOT: " + event.body, event.threadID);
                break;
            case "event":
                console.log(event);
                break;
        }
    });
});

For more detailed documentation, check out the Docs.