Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mahmud-fca

A modified & improved Facebook Chat API — Fixed and maintained by @mahmudx7


👤 About

mahmud-fca is a Facebook Chat API modified with bug fixes, stability improvements, and extra features for Facebook Messenger bots.


📦 Install

npm install mahmud-fca

Or install directly from GitHub:

npm install github:mahmudx7/mahmud-fca

🚀 Example Usage

const login = require("mahmud-fca");
const fs = require("fs");

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

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

    if (event.type === "message") {
      api.sendMessage("Echo: " + event.body, event.threadID);
    }
  });
});

✨ Features & Changes

  • Auto relogin — Automatically relogins when an error is detected
  • Auto dismiss behavior — Detects and dismisses Facebook's automated behavior checkpoint
  • Added api.relogin() — Manually trigger relogin
  • Added api.stopListenMqtt() — Stop listening to MQTT
  • Added api.getRegion() — Get the server region
  • Fixed api.follow() and other API functions
  • Replaced npmlog with normal console.log to fix render log issues
  • Supports cookie string, cookie array, and JSON appstate

📖 API Reference

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

Send a message to a thread. Message types:

Type Field
Text body
Sticker sticker
File/Image attachment (readable stream)
URL url
Emoji emoji + emojiSize

api.listenMqtt(callback)

Listen for messages and events. Enable events with:

api.setOptions({ listenEvents: true });

Enable self-listen:

api.setOptions({ selfListen: true });

api.getAppState()

Returns the current appstate (cookies). Save it to avoid logging in every time:

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

api.stopListenMqtt()

Stops listening to MQTT.


api.relogin()

Manually triggers a relogin.


api.getRegion()

Returns the current Facebook server region (e.g. PRN, LLA).


⚙️ Options

Pass options as the second argument to login():

login({ appState: [...] }, {
  selfListen: false,
  listenEvents: true,
  autoMarkRead: true,
  autoMarkDelivery: false,
  userAgent: "Mozilla/5.0 ...",
  online: true,
  autoReconnect: true
}, callback);

💾 Saving Session

const fs = require("fs");
const login = require("mahmud-fca");

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

📬 Contact


⚠️ Disclaimer

This API is not affiliated with or endorsed by Facebook. Misuse may result in account bans. Use responsibly.


📄 License

MIT

About

mahmud-fca is a Facebook Chat API modified with bug fixes, stability improvements, and extra features for Facebook Messenger bots.

Topics

Resources

Stars

17 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages