tricks-fca
v1.0.2
Published
THE FCA MADE BY MR CHAND TRICKER
Downloads
77
Readme
This repo is a fork from main repo and will usually have new features bundled faster than main repo (and maybe bundle some bugs, too).
Ws3 Facebook Chat API
@NethWs3Dev
If You have a problem with this fca you can contact me by clicking here.
Join our group ChatBot Community
Added features:
- Once the error is detected it will automatically relogin the appstate.
- If the appstate itself is logged out it will automatically logged out and you can resubmit it again, But aside of that, if it has an automated behavior, it will relogin then it will dismiss automatically and refreshes the login
- Added a feature where if the account is locked/suspended, it will stop the login process and shows the information and why it was locked/suspended.
No need to put on listenMqtt.
Also some other features:
- Added api.ws3.relogin()
- Added api.stopListenMqtt()
- Added api.getRegion()
- Added api.setProfileGuard()
- Added api.addFunctions()
- Fixed api functions including api.follow()
- Changed npmlog to normal console.log due to render log issues
- Added a detection if it's locked or suspended (will show the information about the lock/suspension)
- Tested on Mirai/Autobot (try on Xavia or Goat)
Based on hut-chat-api by Jonell Magallanes
Facebook now has an official API for chat bots here.
Session Account Note:
• You can use cookies editor available in kiwi browser, edge and chrome extension for pc and i recommended use Mozila Firefox to less logout or use this website if you have no acess these broswer specially iphone os user this use Appstate Getter https://joncll.serv00.net/apst.html
This API is the only way to automate chat functionalities on a user account. We do this by emulating the browser. This means doing the exact same GET/POST requests and tricking Facebook into thinking we're accessing the website normally. Because we're doing it this way, this API won't work with an auth token but requires the credentials of a Facebook account.
Disclaimer: We are not responsible if your account gets banned for spammy activities such as sending lots of messages to people you don't know, sending messages very quickly, sending spammy looking URLs, logging in and out very quickly... Be responsible Facebook citizens.
See below for projects using this API.
Install
If you just want to use ws3-fca, you should use this command:
npm install ws3-fca@latest
It will download ws3-fca
from NPM repositories
Example Usage
const login = require("ws3-fca");
// Create simple echo bot
login({
appState: []
}, (err, api) => {
if (err) return console.error(err);
api.listenMqtt((err, event) => {
api.sendMessage(event.body, event.threadID);
});
});
Result:
Main Functionality
Sending a message
api.sendMessage(message, threadID[, callback][, messageID])
Various types of message can be sent:
- Regular: set field
body
to the desired message as a string. - Sticker: set a field
sticker
to the desired sticker ID. - File or image: Set field
attachment
to a readable stream or an array of readable streams. - URL: set a field
url
to the desired URL. - Emoji: set field
emoji
to the desired emoji as a string and set fieldemojiSize
with size of the emoji (small
,medium
,large
)
Note that a message can only be a regular message (which can be empty) and optionally one of the following: a sticker, an attachment or a url.
Tip: to find your own ID, you can look inside the cookies. The userID
is under the name c_user
.
Example (Basic Message)
const login = require("ws3-fca");
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
if(err) return console.error(err);
var yourID = "000000000000000";
var msg = "Hey!";
api.sendMessage(msg, yourID);
});
Example (File upload)
const login = require("ws3-fca");
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
if(err) return console.error(err);
// Note this example uploads an image called image.jpg
var yourID = "000000000000000";
var msg = {
body: "Hey!",
attachment: fs.createReadStream(__dirname + '/image.jpg')
}
api.sendMessage(msg, yourID);
});
Saving session.
To avoid logging in every time you should save AppState (cookies etc.) to a file, then you can use it without having password in your scripts.
Example
const fs = require("fs");
const login = require("ws3-fca");
var 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()));
});
Alternative: Use c3c-fbstate to get fbstate.json (appstate.json)
Listening to a chat
api.listenMqtt(callback)
Listen watches for messages sent in a chat. By default this won't receive events (joining/leaving a chat, title change etc…) but it can be activated with api.setOptions({listenEvents: true})
. This will by default ignore messages sent by the current account, you can enable listening to your own messages with api.setOptions({selfListen: true})
.
Example
const fs = require("fs");
const login = require("ws3-fca");
// Simple echo bot. It will repeat everything that you say.
// Will stop when you say '/stop'
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
if(err) return console.error(err);
api.setOptions({listenEvents: true});
var 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;
}
});
});
Projects using this API:
- c3c - A bot that can be customizable using plugins. Support Facebook & Discord.
- Miraiv2 - A simple Facebook Messenger Bot made by CatalizCS and SpermLord.
- hut-chat-api - Based FCA by Jonell.
Projects using this API (original repository, facebook-chat-api):
- Messer - Command-line messaging for Facebook Messenger
- messen - Rapidly build Facebook Messenger apps in Node.js
- Concierge - Concierge is a highly modular, easily extensible general purpose chat bot with a built in package manager
- Marc Zuckerbot - Facebook chat bot
- Marc Thuckerbot - Programmable lisp bot
- MarkovsInequality - Extensible chat bot adding useful functions to Facebook Messenger
- AllanBot - Extensive module that combines the facebook api with firebase to create numerous functions; no coding experience is required to implement this.
- Larry Pudding Dog Bot - A facebook bot you can easily customize the response
- fbash - Run commands on your computer's terminal over Facebook Messenger
- Klink - This Chrome extension will 1-click share the link of your active tab over Facebook Messenger
- Botyo - Modular bot designed for group chat rooms on Facebook
- matrix-puppet-facebook - A facebook bridge for matrix
- facebot - A facebook bridge for Slack.
- Botium - The Selenium for Chatbots
- Messenger-CLI - A command-line interface for sending and receiving messages through Facebook Messenger.
- AssumeZero-Bot – A highly customizable Facebook Messenger bot for group chats.
- Miscord - An easy-to-use Facebook bridge for Discord.
- chat-bridge - A Messenger, Telegram and IRC chat bridge.
- messenger-auto-reply - An auto-reply service for Messenger.
- BotCore – A collection of tools for writing and managing Facebook Messenger bots.
- mnotify – A command-line utility for sending alerts and notifications through Facebook Messenger.