A feature-rich Facebook Messenger bot built with ws3-fca
, designed to provide a variety of commands and utilities for group chats. The bot includes a web dashboard to monitor its status, uptime, and console logs in real-time.
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- Web Dashboard
- Commands
- Creating a New Command
- Contributing
- License
- Contact
- Changelog
- Interactive Commands: Over 30 commands for fun, utility, and media generation (e.g.,
sing
,copilot
,fbcover
,palestine
, etc.). - Event Handling: Supports group events like member joins and leaves with customizable messages.
- Social Media Downloader: Download media from social platforms (handled by the
socialMediaDownloader
event). - Web Dashboard: Monitor the bot’s status, uptime, and console logs in real-time via a web interface.
- Multi-Language Support: Supports multiple languages with a configurable language file.
- Auto-Update Check: Automatically checks for updates from the GitHub repository.
- Customizable Prefix: Configure the bot’s command prefix via
config.json
. - Admin-Only Commands: Restrict certain commands to admin users.
- Node.js: Version 20.17.0 or higher.
- PM2: Process manager for running the bot in the background.
- Facebook Account: A Facebook account to log in and generate an
appState.json
file. - Server Access: A server (local or virtual) to host the bot and web dashboard.
- Port Access: Ensure port
28140
(or your configured port) is open for the web dashboard.
-
Clone the Repository:
git clone https://github.com/1dev-hridoy/Messenger-NexaloSIM-Bot.git cd Messenger-NexaloSIM-Bot
-
Install Dependencies:
npm install
-
Install PM2 Globally (if not already installed):
npm install -g pm2
-
Generate
appState.json
:- Log in to your Facebook account using a tool like
facebook-chat-api
or a similar method to generate anappState.json
file. - Place the
appState.json
file in the project root directory.
- Log in to your Facebook account using a tool like
-
Configure the Bot:
- See the Configuration section below to set up
config.json
.
- See the Configuration section below to set up
-
Start the Bot:
pm2 start index.js --name bot
The bot’s configuration is managed via the config.json
file in the project root. Below is an example configuration:
{
"botName": "NexaloSIM-Bot",
"prefix": ".",
"language": "en",
"adminUIDs": ["your-facebook-uid-here"]
}
botName
: The name of your bot (displayed in logs and messages).prefix
: The command prefix (e.g.,.help
).language
: The language code for messages (e.g.,en
for English). Language files are located in thelanguages
directory.adminUIDs
: An array of Facebook user IDs allowed to use admin-only commands.
Language files are located in the languages
directory (e.g., en.lang
). You can add new languages by creating a new .lang
file and updating the language
field in config.json
.
-
Start the Bot:
pm2 start index.js --name bot
-
Check Bot Status:
pm2 list
-
View Logs:
pm2 logs bot
-
Interact with the Bot:
- Add the bot to a Facebook Messenger group.
- Use commands by typing the prefix followed by the command name (e.g.,
.help
).
-
Access the Web Dashboard:
- Open your browser and navigate to
http://<your-server-ip>:28140
(e.g.,http://ip.ozima.cloud:28140
). - The dashboard will display the bot’s status, uptime, and console logs in real-time.
- Open your browser and navigate to
The bot includes a web dashboard to monitor its status:
- Status: Shows whether the bot is
running
orstopped
. - Uptime: Displays the bot’s uptime in hours, minutes, and seconds.
- Console Logs: Streams console logs in real-time, with color-coded entries for
log
(white),error
(red), andwarn
(yellow).
- Ensure the bot is running.
- Navigate to
http://<your-server-ip>:28140
. - If the port is not accessible, check your server’s firewall settings and ensure port
28140
is open:sudo ufw allow 28140
Here are some of the available commands (use .help
in a chat to see the full list):
Command | Description | Usage Example |
---|---|---|
.help |
Displays the list of commands | .help |
.sing |
Plays a song in the chat | .sing |
.copilot |
AI assistant for answering questions | .copilot |
.fbcover |
Generates a Facebook cover image | .fbcover1 |
.palestine |
Creates a Palestine-themed image | .palestine1 |
.ping |
Checks the bot’s response time | .ping |
.uptime |
Shows the bot’s uptime | .uptime |
Some commands are restricted to admin users (defined in config.json
under adminUIDs
).
You can easily add new commands to the bot by creating a new JavaScript file in the scripts/commands
directory. Below is an example of how to create a simple hello
command that responds with a greeting.
- Navigate to the
scripts/commands
directory. - Create a new file named
hello.js
. - Add the following code to
hello.js
:
module.exports.config = {
name: "hello",
aliases: ["hi"],
version: "1.0",
author: "YourName",
countDown: 0,
adminOnly: false,
description: "A simple command to greet the user",
category: "General",
guide: "{pn}hello - Say hello to the bot",
usePrefix: true
};
module.exports.run = async function({ api, event, getText }) {
const { threadID, messageID } = event;
try {
api.sendMessage("Hello! How can I assist you today? 😊", threadID, messageID);
} catch (err) {
console.error("[Hello Command Error]", err.message);
api.sendMessage(getText("hello", "error", err.message), threadID, messageID);
}
};
The hello
command uses the getText
function for error messages. You need to add the corresponding text to the language file.
- Open the
languages/en.lang
file. - Add the following line:
hello.error=⚠️ An error occurred: %1
- Save the file.
- Restart the bot to load the new command:
pm2 restart bot
- In a Facebook Messenger group, type:
.hello
- The bot should respond with:
Hello! How can I assist you today? 😊
config
: Defines the command’s metadata (name, aliases, description, etc.).name
: The command name (e.g.,hello
).aliases
: Alternative names for the command (e.g.,hi
).adminOnly
: Set totrue
to restrict the command to admins.usePrefix
: Set totrue
to require the bot’s prefix (e.g.,.hello
).
run
: The function that executes when the command is called.api
: Thews3-fca
API for interacting with Facebook Messenger.event
: The event object containing message details (e.g.,threadID
,messageID
).getText
: A function to retrieve localized text from the language file.
You can create more complex commands by following this structure and adding your desired functionality.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature
). - Make your changes and commit them (
git commit -m "Add your feature"
). - Push to your branch (
git push origin feature/your-feature
). - Open a pull request.
Please ensure your code follows the project’s coding style and includes appropriate documentation.
This project is licensed under the ISC License. See the LICENSE file for details.
For questions, suggestions, or issues, feel free to reach out:
- GitHub Issues: Open an issue
- Email: [email protected]
See the CHANGELOG.md file for a detailed history of changes and updates to the project.
Happy chatting with Messenger-NexaloSIM-Bot! 🚀