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

chatbox-fca-remake

v4.0.8

Published

Unofficial Facebook Chat API

Downloads

1,677

Readme


Chatbox-FCA-Remake - Unofficial Facebook Chat API

Chatbox-FCA-Remake is a fork of the original fca-unofficial repository. This version includes new features and updates that are integrated faster than the main repository. Please note that while new features offer added functionality, they may also introduce bugs.


Overview

The Chatbox-FCA-Remake API allows you to automate Facebook chat functionalities by emulating the browser's GET/POST requests. Unlike the official API, it does not use an authentication token and instead requires the AppState (session information) from a previously authenticated Facebook session, which can be obtained using third-party tools.


Important Notes

Login via Credentials No Longer Supported

Due to recent updates, logging in using credentials (email and password) directly through the API is no longer supported. You can no longer use the old login method based on email and password.

AppState Support

To use the API, you need to provide an AppState from a previously authenticated session. You can retrieve and even update your AppState with the api.getAppState() function after logging in.

  • Kiwi Browser & c3c-ufc-utility Extension: Use the Kiwi Browser along with the c3c-ufc-utility extension to extract the AppState after logging into Facebook manually.

Once you have the AppState, load it into the API to authenticate. You can also use api.getAppState() to update the AppState during your session.

Please use the API responsibly to avoid account bans, which may result from excessive automation or spamming.


New Features

1. Bypass Automatic Behavior Detection

This feature helps bypass Facebook's behavior detection mechanisms, reducing the likelihood that your bot's activity will be flagged as automated.

2. Auto Refresh for fb_dtsg Token

The AutoRefreshFbDtsg feature automatically refreshes the fb_dtsg token, ensuring your session remains active without needing to log in again. This is especially useful as fb_dtsg tokens expire periodically.

Example 1 Example 2

If other FCAs lack this feature, they may encounter errors, as shown below: Error Example


How to Obtain AppState

Kiwi Browser & c3c-ufc-utility Extension

  1. Install the Kiwi Browser.
  2. Add the c3c-ufc-utility extension to the browser.
  3. Use the extension to extract your AppState (session cookies) after manually logging into Facebook.
  4. Save the AppState as a appstate.json file and load it into your API configuration.

For detailed instructions, refer to the official c3c-ufc-utility GitHub release.


Installation

To install chatbox-fca-remake, run the following npm command:

npm install chatbox-fca-remake

For the latest development version directly from GitHub:

npm install git+https://github.com/your/repository.git

Example Usage

Here’s an example of bot and how to log in using your AppState:

const fs = require("fs");
const login = require("chatbox-fca-remake");

// Simple bot that responds when you say "test" or "/stop"
login({
    appState: JSON.parse(fs.readFileSync('test.json', 'utf8'))  // Load AppState from the saved JSON file
}, (err, api) => {
    if (err) return console.error(err);  // Handle login errors

    // Set the bot's options for its behavior and connection
    api.setOptions({
        forceLogin: true,  // Force login even if the session is active
        listenEvents: true,  // Enable event listening
        logLevel: "silent",  // Set log level to silent (no logs)
        updatePresence: true,  // Keep the presence (status) updated
        selfListen: false,  // Do not listen to the bot's own messages
        userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:118.0) Gecko/20100101 Firefox/118.0",  // Set custom user agent for the bot
        online: false,  // Keep the bot offline or Set it to true if you want to see bots online status.
        autoMarkDelivery: false,  // Disable auto marking of delivery status
        autoMarkRead: false  // Disable auto marking of messages as read
    });

    // Start listening for incoming messages and events
    const stopListening = api.listenMqtt((err, event) => {
        if (err) return console.error(err);  // Handle any errors while listening

        // Switch case to handle different types of events
        switch (event.type) {
            case "message":
                if (event.body === '/stop') {  // If the message is "/stop"
                    api.sendMessage("Goodbye…", event.threadID);  // Send "Goodbye" message
                    return stopListening();  // Stop listening to events
                }
                if (event.body.toLowerCase() === 'test') {  // If the message is "test" (case-insensitive)
                    api.sendMessage("TEST BOT: " + event.body, event.threadID);  // Send a test response
                }
                break;
            case "event":
                console.log(event);  // Log any other event type
                break;
        }
    });
});

Main Functionality

  • Sending Messages:

    • Text Messages
    • Sticker Messages
    • Image/File Attachments
    • URLs
    • Emojis
  • Listening for Messages:

    • Real-time message listening
    • Event listeners for actions like user joining or leaving a chat

FAQ

  1. How do I log in without credentials?

    • After logging into Facebook manually, extract your AppState using the c3c-ufc-utility extension. This is the only supported authentication method.
  2. Can I listen for messages from the bot?

    • Yes, the bot can listen to incoming messages and automatically respond. You can customize the responses based on message content.
  3. Can I send media like images or files?

    • Yes, you can send images or files as attachments, as demonstrated in the example usage.
  4. How do I keep my session alive?

    • Once your AppState is saved, you can reuse it to authenticate without needing to log in again.

Projects Using This API

  • c3c - A customizable bot with Facebook and Discord support.
  • Messenger-CLI - Command-line interface for Facebook Messenger.

License

This project is licensed under the MIT License. See the LICENSE file for more details.


Contact & Community

For support or inquiries, contact:

Join our ChatBot Community:


Note: This project is an unofficial Facebook chat API. Please use it responsibly and in accordance with Facebook's terms of service.