fca-nknp
v1.0.0
Published
Stub / mock Facebook Chat API (FCA) for development and testing. Not a real Facebook connector.
Maintainers
Readme
fca-nknp
Stub / Mock Facebook Chat API for Node.js.
⚠️ This is NOT a real Facebook / Messenger connector.
It only provides the same public interface (login, sendMessage, listenMqtt, …) so you can develop and test bots without risking your account or depending on Facebook’s changing APIs.
Install
npm install fca-nknp
# or from local folder
npm install /path/to/fca-nknpQuick Start
const login = require('fca-nknp');
login({ appState: [] }, { listenEvents: true }, (err, api) => {
if (err) return console.error(err);
console.log('UID:', api.getCurrentUserID());
api.sendMessage('Hello from stub!', 'THREAD_ID');
api.listenMqtt((err, event) => {
if (err) return console.error(err);
if (event.type === 'message') {
api.sendMessage(`Echo: ${event.body}`, event.threadID);
}
});
});Promise style also works
const api = await login({ appState: require('./appstate.json') });
await api.sendMessage('Hi', threadID);Available methods (stub)
| Method | Description |
|--------|-------------|
| getCurrentUserID() | Returns mock UID |
| getAppState() | Returns fake cookie array |
| sendMessage(msg, threadID[, cb]) | Logs & returns fake messageID |
| sendTypingIndicator(threadID) | Log only |
| markAsRead / markAsDelivered | Log only |
| setMessageReaction | Log only |
| unsendMessage / editMessage | Log only |
| getThreadInfo / getThreadList | Returns mock data |
| getUserInfo / getFriendsList | Returns mock data |
| listen / listenMqtt | Starts “listening” (emits nothing by default) |
| logout | Log only |
| setOptions / getOptions | Store options |
All methods support both callback and Promise.
Special option
login({ appState }, { emitFakeEvent: true }, (err, api) => {
// After ~2 seconds a fake message event will be emitted
});Project structure
fca-nknp/
├── package.json
├── index.js # main entry (login)
├── lib/
│ └── api.js # mock API object
├── example.js # runnable demo
├── test.js # self-test
├── README.md
└── LICENSEWhy a stub?
- Develop bot logic without real Facebook connection
- Unit-test command handlers safely
- Placeholder while waiting for a maintained real FCA
- Avoid account bans during development
License
MIT
