Built with Baileys β’ Powered by Yoshida-APIs β’ Completely Free
π 100% Free | No hidden costs, completely open-source |
π Plug & Play | Modular architecture for easy customization |
β‘ Lightning Fast | Built on Baileys for optimal performance |
πΎ Hybrid Storage | PostgreSQL + JSON for optimal performance |
π‘οΈ Reliable | Stable connection with advanced error handling |
π― Easy Deploy | Multiple deployment options available |
π¦ yoshida-bot/
βββ π library/ # Core logic & helper modules
βββ π plugins/ # Command-based plugin modules
βββ π system/ # Internal system logic
βββ π sessions/ # WhatsApp session files (JSON)
βββ π database/ # Local database files (JSON)
βββ π index.js # Main application entry point
βββ π machine.js # State management logic
βββ βοΈ ecosystem.config.js # PM2 deployment configuration
βββ π .env # Environment variables
βββ π package.json # Project dependencies
Component | Version | Required |
---|---|---|
Node.js | 16.x or higher | β |
npm/yarn | Latest | β |
Git | Latest | β |
FFmpeg | Latest | β |
ImageMagick | Latest | β |
PostgreSQL | 12.x or higher |
Required Buildpacks (Add in this order):
# 1. Node.js buildpack
heroku buildpacks:add heroku/nodejs
# 2. Python buildpack
heroku buildpacks:add heroku/python
# 3. FFmpeg buildpack
heroku buildpacks:add https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git
# 4. ImageMagick buildpack
heroku buildpacks:add https://github.com/DuckyTeam/heroku-buildpack-imagemagick.git
Alternative using app.json:
{
"buildpacks": [
{ "url": "heroku/nodejs" },
{ "url": "heroku/python" },
{
"url": "https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git"
},
{ "url": "https://github.com/DuckyTeam/heroku-buildpack-imagemagick.git" }
]
}
Download and install the following software:
Software | Download Link | Purpose |
---|---|---|
Git | Download here | Version control & cloning |
Node.js | Download here | JavaScript runtime |
FFmpeg | Download here | Media processing |
ImageMagick | Download here | Image processing |
Installation Steps:
-
Install Git
- Download Git from the official website
- Run the installer with default settings
- Verify:
git --version
-
Install Node.js
- Download LTS version from nodejs.org
- Run the installer (includes npm)
- Verify:
node --version
andnpm --version
-
Install FFmpeg
- Download the Windows build
- Extract to
C:\ffmpeg\
- Add
C:\ffmpeg\bin
to your system PATH - Verify:
ffmpeg -version
-
Install ImageMagick
- Download Windows installer
- Run with default settings
- Verify:
magick -version
Ubuntu/Debian:
# Update package list
sudo apt update
# Install required packages
sudo apt install -y git nodejs npm ffmpeg imagemagick
# Verify installations
node --version
npm --version
ffmpeg -version
convert -version
CentOS/RHEL:
# Install NodeJS
curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum install -y nodejs
# Install other packages
sudo yum install -y git ffmpeg ImageMagick
# Verify installations
node --version
npm --version
ffmpeg -version
convert -version
# Clone the repository
git clone https://github.com/yuurahz/yoshida.git
# Navigate to project directory
cd yoshida
# Install dependencies
npm install
Create a .env
file in the root directory:
# Time Zone Configuration
TZ=Asia/Jakarta
# Pairing Configuration
PAIRING_STATE=true
PAIRING_NUMBER= (e.g 628xxx)
#setup
DATABASE_NAME= /** local or postgres (default local) */
DATABASE_STATE=
SESSION_NAME=
SESSION_TYPE= /** local or postgres (default local) */
#postgresql config (visit here: https://console.aiven.io)[recommended]
POSTGRES_HOST=
POSTGRES_PASSWORD=
POSTGRES_USER=
POSTGRES_DATABASE=
POSTGRES_PORT=
POSTGRES_SSL=""
Choose your preferred method:
# Development Mode
npm start
# Production Mode with PM2
npm run pm2
# Manual PM2 Setup
pm2 start ecosystem.config.js
module.exports = {
// Plugin metadata
help: ["ping", "test"],
tags: ["tools"],
command: /^(ping|test)$/i,
// Main plugin logic
run: async (m, { conn }) => {
try {
const startTime = Date.now();
await conn.reply(m.chat, "π Pong!", m);
const endTime = Date.now();
await conn.reply(m.chat, `β‘ Response time: ${endTime - startTime}ms`, m);
} catch (error) {
return conn.reply(m.chat, `β Error: ${error.message}`, m);
}
},
// Plugin permissions
group: false, // Works in groups
admin: false, // Requires admin
limit: false, // Uses command limit
premium: false, // Premium only
botAdmin: false, // Bot needs admin
owner: false, // Owner only
};
module.exports = {
async before(m, { conn }) {
try {
// Pre-processing logic
if (m.text && m.text.includes("hello")) {
await conn.reply(m.chat, "π Hello there!", m);
}
} catch (error) {
console.error("Event handler error:", error);
}
return true;
},
};
module.exports = {
apps: [
{
name: "yoshida-bot",
script: "./index.js",
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: "1G",
node_args: "--max-old-space-size=2048",
env: {
NODE_ENV: "production",
},
env_development: {
NODE_ENV: "development",
},
},
],
};
Yoshida-Bot uses a hybrid storage system for optimal performance and reliability:
ποΈ PostgreSQL | Primary database for persistent data |
π JSON Local | Local file storage for sessions & cache |
// Multiple session storage options
const postgreSQLConfig = {
user: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
host: process.env.POSTGRES_HOST,
port: parseInt(process.env.POSTGRES_PORT),
database: process.env.POSTGRES_DATABASE,
ssl: {
rejectUnauthorized: true,
ca: process.env.POSTGRES_SSL.replace(/"""/g, ""),
},
},
// Local JSON
// PostgreSQL connection example
const { Pool } = require("pg");
const pool = new Pool({
user: process.env.POSTGRES_USER,
host: process.env.POSTGRES_HOST,
database: process.env.POSTGRES_DATABASE,
password: process.env.POSTGRES_PASSWORD,
port: process.env.POSTGRES_PORT,
ssl: {
rejectUnauthorized: true,
ca: process.env.POSTGRES_SSL.replace(/"""/g, ""),
},
});
// Local JSON storage
class Local {
/**
* Initializes the LocalDB instance with the provided file path.
* @param {string} [filePath] - The path to the JSON file where the database will be stored. Defaults to 'database.json'.
*/
constructor(filePath) {
this.filePath = filePath ? filePath + ".json" : process.env.DATABASE_NAME;
this.queue = [];
this.initDB();
}
/**
* Initializes the database by checking if the file exists.
* If the file does not exist, it creates an empty JSON file.
* @returns {Promise<void>}
*/
initDB = async () => {
try {
await fs.access(this.filePath);
} catch (err) {
await this.write({});
}
};
/**
* Validates if the provided data is a valid JSON object.
* @param {any} data - The data to be validated.
* @returns {boolean} - Returns true if the data is valid JSON, otherwise false.
*/
validateJSON = (data) => {
try {
JSON.stringify(data, null);
return true;
} catch (err) {
return false;
}
};
/**
* Adds data to the internal queue to be saved later.
* @param {object} data - The data to be added to the queue.
*/
enqueue = (data) => this.queue.push(data);
/**
* Write the valid data from the queue to the file.
* If the data is valid JSON, it will be written to the file.
* @param {object} data - The data to be saved to the file.
* @returns {Promise<void>}
*/
write = async (data) => {
this.enqueue(data);
const validData = this.queue.filter(this.validateJSON);
this.queue = [];
if (validData.length > 0) {
try {
await fs.writeFile(
this.filePath,
JSON.stringify(validData[0], null),
"utf8",
);
} catch (err) {
console.log(`Failed to save data: ${err.message}`);
}
} else {
console.log("No valid data to save");
}
};
/**
* Read the data from the JSON file and returns it.
* @returns {Promise<object|null>} - The parsed data from the file, or null if an error occurred.
*/
read = async () => {
try {
const data = await fs.readFile(this.filePath, "utf8");
return JSON.parse(data);
} catch (err) {
console.log(`Failed to fetch data: ${err.message}`);
return null;
}
};
}
We welcome contributions! Here's how you can help:
- π΄ Fork the repository
- π Create a feature branch (
git checkout -b feature/amazing-feature
) - πΎ Commit your changes (
git commit -m 'Add amazing feature'
) - π€ Push to the branch (
git push origin feature/amazing-feature
) - π Open a Pull Request
MIT License - Free for personal and commercial use
β Please star this repository if you find it useful!
- β Free to use and modify
- β Commercial use allowed
- β Private use allowed
β οΈ Must include license and copyright notice- β No warranty provided
Role | Contributor | Links |
---|---|---|
Developer | yuurahz | GitHub |
Library Provider | @yoshx/func | npm |
API Provider | Yoshida-APIs | Try it |
Made with β€οΈ by the Yoshida-Bot Team
Building the future of WhatsApp automation