## 📝 **Note** - This is a messenger chat bot using a personal account, using an [unofficial api](https://github.com/ntkhang03/fb-chat-api/blob/master/DOCS.md) ([Origin here](https://github.com/Schmavery/facebook-chat-api)) and this may lead to facebook account being locked due to spam or other reasons. - So, I recommend using a clone account (one that you're willing to throw away at any time) - ***I am not responsible for any problems that may arise from using this bot.*** ## 🚧 **Requirement** - Node.js 16.x [Download](https://nodejs.org/dist/v16.20.0) | [Home](https://nodejs.org/en/download/) | [Other versions](https://nodejs.org/en/download/releases/) - Knowledge of **programming**, javascript, nodejs, unofficial facebook api ## 📝 **Tutorial** Tutorial has been uploaded on YouTube - For mobile phone: https://www.youtube.com/watch?v=grVeZ76HlgA - For vps/windows: https://www.youtube.com/watch?v=uCbSYNQNEwY Summary instructions: - See [here](https://github.com/ntkhang03/Goat-Bot-V2/blob/main/STEP_INSTALL.md) ## 💡 **How it works?** - The bot uses the unofficial facebook api to send and receive messages from the user. - When having a `new event` (message, reaction, new user join, user leave chat box,...) the bot will emit an event to the `handlerEvents`. - The `handlerEvents` will handle the event and execute the command: - `onStart`: - the handler will check if user `call a command or not`. - if yes, it will check if `user banned` or mode `admin box only is turned on` or not, if not, it will execute the command. - next, it will check the `permission` of the user. - next, it will check if the `countdown` of command is over or not. - finally, it will execute the command and `log` information to the console. - `onChat`: - the handler will run `when the user sends a message`. - it will check `permission` of the user. - the handler will `execute` the command, if it return a `function` or `async function` then it willl check `user banned` or mode `admin box only is turned on` or not, if not, it will call the function and `log` information to the console. - `onFirstChat`: - the handler will run `when get the first message` from the chat box since the bot started. - the way it works is like `onChat`. - `onReaction`: - the handler will run when the user `reacts` to a `message has messageID` is set in `GoatBot.onReaction` as follows: ```javascript // example: global.GoatBot.onReaction.set(msg.messageID, { messageID: msg.messageID, commandName, // ... and more }); ``` - the handler will automatically add method `delete`, if this method is called, it will delete the message from the set. - next, it will check `permission` of the user and `execute` if the user has permission and `log` information to the console. - `onReply`: - the handler will run when the user `replies` to a `message has messageID` is set in `GoatBot.onReply` as follows: ```javascript // example: global.GoatBot.onReply.set(msg.messageID, { messageID: msg.messageID, commandName, // ... and more }); ``` - the handler will automatically add method `delete`, if this method is called, it will delete the message from the set. - next, it will check `permission` of the user and `execute` if the user has permission and `log` information to the console. - `onEvent`: - the handler will run `when the user has a new event` type `event` (new user join, user leave chat box, change admin box,...) ```javascript // example: global.GoatBot.onEvent.set(msg.messageID, { messageID: msg.messageID, commandName, // ... and more }); ``` - it will loop through all `onEvent` and get the command determined by the key `commandName` and execute the `onEvent` in that command. - if it return a `function` or `async function` then it will call the function and `log` information to the console. - `handlerEvent`: - the handler will run `when the user has a new event` type `event` (new user join, user leave chat box, change admin box,...) - it will get all the eventCommand set in `GoatBot.eventCommands` (scripts placed in the `scripts/events` folder) - it will loop through all `eventCommands` and run the `onStart` in that command. - if it return a `function` or `async function` then it will call the function and `log` information to the console. ## 🔔 **How to get notification when have new update?** - Click on the `Watch` button in the upper right corner of the screen and select `Custom` and select `Pull requests` and `Releases` and click `Apply` to get notified when there is a new update. ## 🆙 **How to Update** Tutorial has been uploaded on YouTube - on phone/repl: https://youtu.be/grVeZ76HlgA?t=1342 - on vps/computer: https://youtu.be/uCbSYNQNEwY?t=508 ## 🛠️ **How to create new commands** - See [here](https://github.com/ntkhang03/Goat-Bot-V2/blob/main/DOCS.md) ## 💭 **Support** If you have major coding issues with this bot, please join and ask for help. - https://discord.com/invite/DbyGwmkpVY (recommended) - https://www.facebook.com/groups/goatbot - https://m.me/j/Abbq0B-nmkGJUl2C - ~~https://t.me/gatbottt~~ (no longer supported) - ***Please do not inbox me, I do not respond to private messages, any questions please join the chat group for answers. ThankThanks!*** ## 📚 **Support Languages in source code** - Currently, the bot supports 2 languages: - [x] `en: English` - [x] `vi: Vietnamese` - Change language in `config.json` file - You can customize the language in the folder `languages/`, `languages/cmds/` and `languages/events/` ## 📌 **Common Problems**
📌 Error 400: redirect_uri_mismatch
1. Enable Google Drive API: Tutorial
2. Add uri https://developers.google.com/oauthplayground (not https://developers.google.com/oauthplayground/) to Authorized redirect URIs in OAuth consent screen: Tutorial
3. Choose https://www.googleapis.com/auth/drive and https://mail.google.com/ in OAuth 2.0 Playground: Tutorial
📌 Error for site owners: Invalid domain for site key
1. Go to https://www.google.com/recaptcha/admin
2. Add domain repl.co (not repl.com) to Domains in reCAPTCHA v2 Tutorial
📌 GaxiosError: invalid_grant, unauthorized_client
- If you don't publish the project in google console, the refresh token will expire after 1 week and you need to get it back. Tuatorial
📌 GaxiosError: invalid_client
- Check if you have entered your google project client_id correctly Tuatorial
📌 Error 403: access_denied
- If you don't publish the project in google console only the approved accounts added to the project can use it Tuatorial