A simple Facebook Messenger Bot using personal account with framework NestJs
$ git clone https://github.com/bossvirus03/Pangolin.git
and then
$ npm install
- Download c3c fbstate to get fbstate
- Add that extension to chrome or any browse
- Log in to your Facebook account, remember not to use your main account
- Copy fbstate and paste into the appstate.json file located in the root directory
- Instructional video Here
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
- This is a messenger chat bot using a personal account, using facebook-chat-api and this is not supported from Facebook, so its use may result in the account being locked due to spam or some other reason.
- i'm 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.
import { IPangolinRun } from "src/types/type.pangolin-handle";
async run({
api,
event,
client,
args,
UserData,
ThreadData,
UserInThreadData,
getLang,
pangolin,
}: IPangolinRun) {
// logic here
}
import { IPangolinHandleEvent } from "src/types/type.pangolin-handle";
async handleEvent({
api,
event,
client,
UserData,
ThreadData,
UserInThreadData,
getLang,
pagolin,
}: IPangolinHandleEvent) {
// logic
}
import { IPangolinNoprefix } from "src/types/type.pangolin-handle";
async noprefix({
api,
event,
client,
args,
UserData,
ThreadData,
UserInThreadData,
getLang,
pangolin,
}: IPangolinNoprefix) {
// logic
}
- From functions handle command
async run({
api,
event,
client,
args,
UserData,
ThreadData,
UserInThreadData,
getLang,
pangolin,
}: IPangolinRun){}
In the code above
Example: send a message
api.sendMessage("hello world", event.ThreadID);
To see detail you need to Here
Some event you need to know
- event.type
- event.messageID
- event.threadID
- event.isGroup
- event.body
- event.senderID
- ...Here
If you receive a message which is "nguyen van a", then args[0] = "nguyen", args[1] = "van", args[2] = "a"
Example get a user
const user = await UserData.get("61556745520442");
console.log(user);
//response
/*
User {
uid: "",
name: "",
exp: 0,
money: 0,
prefix: ""
}
*/
Example get a thread
const thread = await ThreadData.get("47923492740238");
console.log(thread);
//response
/*
Thread {
name: "",
tid: "",
prefix: "",
rankup: false,
resend: false,
}
*/
Example get a user in group
const userInThread = await UserInThreadData.get(
"61556745520442",
"47923492740238",
);
console.log(userInThread);
//response
/*
UserInThread {
name: "",
uid: "",
uniqueId: "",
tid: "",
countMessageOfDay: 0,
lastDayUpdate: "",
countMessageOfWeek:0,
lastWeekUpdate: ""
}
*/
To get all config of current bot
const config = pangolin;
console.log(config);
// response
/*
{
"botname": "heloo",
"admins": [
"100049732817959",
"100000113681117"
],
"prefix": ";",
"commands": {
"youtube_search_api": ""
},
"access_token": "",
"log_event": false,
"help_paginate": false
}
*/
- Author - bossvirus03 along with contributions from Nguyenblur and dev-ndk