Baileys library was originally a project for CS-2362 at Ashoka University and is in no way affiliated with or endorsed by WhatsApp. Use at your own discretion. Do not spam people with this. We discourage any stalkerware, bulk or automated messaging usage.
WhatsApp Erha is a WhatsApp bot framework built with TypeScript using the Baileys library. This framework provides an easy-to-use command system with decorator pattern, supports various message types, and includes admin management features.
- π§ Decorator-based Command System - Easy command creation with decorators
- π± Multi-message Support - Supports text, image, video, audio, sticker, location, etc.
- π₯ Admin System - Admin system with permission management
- ποΈ MongoDB Integration - Database support for data storage
- π QR Code Authentication - Login using QR code
- β‘ PM2 Process Management - Production-ready with PM2
- π― TypeScript Support - Full TypeScript support with type safety
- Node.js v16.14.2 or higher
- Yarn package manager
- MongoDB (optional, for database features)
- Install Yarn (if not already installed):
npm install -g yarn- Clone repository:
git clone https://github.com/rayenking/whatsapperha.git
cd whatsapperha- Install dependencies:
yarn install- Install Baileys library:
yarn install-baileys- Setup environment variables:
cp .env.example .envEdit the .env file with appropriate configurations:
# Database
MONGODB_URL=mongodb://localhost:27017/whatsapperha
# Logging
LOG_LEVEL=info
# Data paths
DATA_DIR=./data/baileys
STORE_PATH=./data/baileys/store.json
AUTH_PATH=./data/baileys/auth
# Admin numbers (comma separated)
ADMINS=6281234567890,6289876543210# Normal mode (QR code authentication)
yarn dev
# Pairing code mode
yarn dev -- --pairing-code# Build project
yarn build
# Start with Node.js
yarn start
# Start with PM2 (recommended for production)
yarn start:erha# Restart application
yarn restart
# Stop application
yarn stopwhatsapperha/
βββ commands/ # Command modules
β βββ auto/ # Auto-response commands
β βββ dialog/ # Dialog/interactive commands
β βββ help/ # Help and utility commands
β βββ owners/ # Owner/admin commands
βββ lib/ # Core library files
β βββ client.ts # WhatsApp client implementation
β βββ hook.ts # Decorator system
β βββ message.ts # Message parsing
β βββ types.ts # TypeScript type definitions
βββ models/ # Database models
βββ helpers/ # Helper utilities
βββ main.ts # Application entry point
Create a new folder inside commands/ and create a .ts file for your command:
import { RhClient } from "@rhook/rh";
import { commands, entity, hook } from "@rhook/hook";
import { ParseMessage } from "@rhook/types";
class MyCommand {
@commands('hello')
@entity({ignoreSelf: false})
@hook('text')
async hello(client: RhClient, message: ParseMessage): Promise<void> {
await client.sendMessage(message.parse.to, `Hello ${message.pushName}!`);
}
}- command: String command or array of commands
- type:
'startswith'|'contains'|'exact'|'endswith'|'regex'(default:'startswith') - prefix: Custom prefix (default:
'!')
@entity({
case_sensitive: false, // Case sensitive matching
chat_type: 'all', // 'all' | 'group' | 'private'
ignoreSelf: true, // Ignore own messages
ignorePublic: false, // Only respond to self messages
isAdmin: false // Admin only command
})Available types:
'text'- Text messages'image'- Image messages'video'- Video messages'audio'- Audio messages'location'- Location messages'sticker'- Sticker messages'caption'- Image/video captions'listResponse'- List response messages'buttonResponse'- Button response messages'join'- Group join events'leave'- Group leave events'contact'- Contact messages
@commands('ping')
@entity({ignoreSelf: false})
@hook('text')
async ping(client: RhClient, message: ParseMessage): Promise<void> {
await client.sendMessage(message.parse.to, `PONG! ${message.pushName}`);
}@commands('restart')
@entity({isAdmin: true})
@hook('text')
async restart(client: RhClient, message: ParseMessage): Promise<void> {
await client.sendMessage(message.parse.to, `Restarting...`);
await client.restart(message.parse.to);
}@commands('caption')
@entity({ignoreSelf: false})
@hook('caption')
async handleCaption(client: RhClient, message: ParseMessage): Promise<void> {
await client.sendMessage(message.parse.to, `Caption: ${message.parse.text}`);
}| Variable | Description | Default |
|---|---|---|
MONGODB_URL |
MongoDB connection string | - |
LOG_LEVEL |
Logging level | info |
DATA_DIR |
Data directory path | ./data/baileys |
STORE_PATH |
Store file path | ./data/baileys/store.json |
AUTH_PATH |
Auth directory path | ./data/baileys/auth |
ADMINS |
Admin phone numbers (comma separated) | - |
The default prefix is !. To change the prefix globally:
import { setDefaultPrefix } from "@rhook/rh";
setDefaultPrefix('.'); // Change prefix to '.'| Script | Description |
|---|---|
yarn dev |
Run in development mode with hot reload |
yarn dev -- --pairing-code |
Run in development mode with pairing code authentication |
yarn build |
Build TypeScript to JavaScript |
yarn start |
Start compiled application |
yarn start:erha |
Start with PM2 process manager |
yarn restart |
Restart PM2 process |
yarn stop |
Stop PM2 process |
yarn install-baileys |
Install latest Baileys library |
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the ISC License.
- Ryns - GitHub
- Whiskeysockets - Baileys library
- Baileys Community - For the amazing WhatsApp library
This project is for educational purposes only. Please use responsibly and in accordance with WhatsApp's Terms of Service. The authors are not responsible for any misuse of this software.