fca-aryan
v0.0.5
Published
Advanced Facebook Chat API (FCA) for Node.js - Automate Facebook Messenger with real-time messaging, AI theme generation, and comprehensive bot features
Maintainers
Readme
Overview
FCA-ARYAN is a powerful, modern Facebook Chat API client built for reliable, real-time, and modular interaction with Facebook Messenger. This project offers full control over Messenger automation through a clean, stable interface.
Installation
Requirements: Node.js v18.0.0 or higher
npm install fca-aryanOr install the latest version:
npm install fca-aryan@latestFeatures
| Feature | Description | |---------|-------------| | Secure Login | Dynamic form scraping with secure token authentication | | Real-time Messaging | Send/receive messages, attachments, stickers, replies | | Message Editing | Edit bot messages in-place | | Typing Indicators | Detect and send typing status | | Message Status | Mark as delivered, read, or seen | | Thread Management | Get thread details, history, lists, pin/unpin messages | | User Info | Access name, ID, profile picture, mutual context | | Sticker API | Search stickers, list packs, AI-generated stickers | | Post Interaction | Comment and reply to public posts | | AI Themes | Generate custom AI-powered chat themes | | Proxy Support | Full support for custom proxies | | Modular Design | Organized into pluggable modules | | Error Handling | Retry logic, logging, graceful failovers |
Security Warning
IMPORTANT:
appstate.jsoncontains your Facebook session credentials!
| Warning | Description |
|---------|-------------|
| Never commit | Do not add appstate.json to version control |
| Never share | Keep your session file private |
| Use .gitignore | Already configured in this project |
| Environment-specific | Use separate credentials for production |
Quick Start
Step 1: Generate appstate.json
Install a cookie export extension:
- Chrome/Edge: C3C FbState or CookieEditor
- Firefox: Cookie-Editor
Log in to Facebook in your browser
Export cookies and save as
appstate.json:
[
{ "key": "c_user", "value": "your-user-id" },
{ "key": "xs", "value": "your-xs-value" }
]Tutorial: Getting AppState Guide
Step 2: Create Your Bot
const fs = require("fs");
const path = require("path");
const { login } = require("fca-aryan");
let credentials;
try {
credentials = { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) };
} catch (err) {
console.error("appstate.json is missing or malformed.", err);
process.exit(1);
}
console.log("Logging in...");
login(credentials, {
online: true,
updatePresence: true,
selfListen: false,
randomUserAgent: false
}, async (err, api) => {
if (err) return console.error("LOGIN ERROR:", err);
console.log(`Logged in as: ${api.getCurrentUserID()}`);
const commandsDir = path.join(__dirname, "modules", "commands");
const commands = new Map();
if (!fs.existsSync(commandsDir)) fs.mkdirSync(commandsDir, { recursive: true });
for (const file of fs.readdirSync(commandsDir).filter(f => f.endsWith(".js"))) {
const command = require(path.join(commandsDir, file));
if (command.name && typeof command.execute === "function") {
commands.set(command.name, command);
console.log(`Loaded command: ${command.name}`);
}
}
api.listenMqtt(async (err, event) => {
if (err || !event.body || event.type !== "message") return;
const prefix = "/";
if (!event.body.startsWith(prefix)) return;
const args = event.body.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
const command = commands.get(commandName);
if (!command) return;
try {
await command.execute({ api, event, args });
} catch (error) {
console.error(`Error executing ${commandName}:`, error);
api.sendMessageMqtt("An error occurred.", event.threadID, event.messageID);
}
});
});AI Features
AI Stickers
const aiStickers = await api.getAiStickers({ limit: 10 });
console.log(aiStickers);AI Themes
const aiThemes = await api.createAITheme("vibrant purple pink ocean sunset");
if (aiThemes && aiThemes.length > 0) {
console.log(`Generated theme ID: ${aiThemes[0].id}`);
await api.setThreadThemeMqtt(threadID, aiThemes[0].id);
console.log("AI theme applied!");
}Standard Themes
const themes = await api.getTheme(threadID);
console.log(`Found ${themes.length} themes`);
await api.setThreadThemeMqtt(threadID, themes[0].id);Check Current Theme
const currentTheme = await api.getThemeInfo(threadID);
console.log(`Thread: ${currentTheme.threadName}`);
console.log(`Color: ${currentTheme.color}`);
console.log(`Emoji: ${currentTheme.emoji}`);API Reference
Core Methods
| Method | Description |
|--------|-------------|
| login(credentials, options, callback) | Login to Facebook |
| api.getCurrentUserID() | Get current user ID |
| api.getAppState() | Get session cookies |
| api.listenMqtt(callback) | Listen for messages |
| api.logout() | Logout from Facebook |
Messaging
| Method | Description |
|--------|-------------|
| api.sendMessage(msg, threadID) | Send a message |
| api.sendMessageMqtt(msg, threadID) | Send via MQTT |
| api.editMessage(text, messageID) | Edit a message |
| api.unsendMessage(messageID) | Unsend a message |
| api.setMessageReaction(reaction, messageID) | React to message |
Thread Management
| Method | Description |
|--------|-------------|
| api.getThreadInfo(threadID) | Get thread info |
| api.getThreadList(limit, timestamp, tags) | List threads |
| api.getThreadHistory(threadID, amount) | Get message history |
| api.changeThreadColor(color, threadID) | Change thread color |
| api.changeGroupImage(image, threadID) | Change group image |
User Management
| Method | Description |
|--------|-------------|
| api.getUserInfo(userID) | Get user info |
| api.getFriendsList() | Get friends list |
| api.addUserToGroup(userID, threadID) | Add user to group |
| api.removeUserFromGroup(userID, threadID) | Remove from group |
Project Structure
fca-aryan/
├── index.js # Main entry point
├── src/
│ ├── nix/ # API methods (70+ functions)
│ ├── storage/ # Session & cache management
│ ├── database/ # Database models
│ ├── engine/ # Login engine
│ ├── types/ # TypeScript definitions
│ └── utils/ # Utility functions
├── examples/ # Usage examples
└── README.mdExamples
Check the examples/ directory:
| File | Description |
|------|-------------|
| simple-bot.js | Basic bot setup |
| test-bot.js | Full-featured test bot |
| apply-ai-theme.js | AI theme generation |
| theme-usage-example.js | Theme management |
Login Options
{
online: true, // Show online status
selfListen: false, // Listen to own messages
listenEvents: true, // Listen to events
updatePresence: true, // Update presence
forceLogin: false, // Force new login
autoMarkDelivery: true, // Auto mark delivered
autoMarkRead: false, // Auto mark read
listenTyping: false, // Listen to typing
proxy: null, // Proxy URL
autoReconnect: true, // Auto reconnect
randomUserAgent: false, // Random user agent
bypassRegion: null // Bypass region
}Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
Credits
- Aryan - Lead Developer
- Aryan Team - Development & Maintenance
License
MIT License - Free to use, modify, and distribute.
