Skip to content
Β 
Β 

Repository files navigation

Rose Bot - Multi-Platform Group Management Bot

Made with Python

A modular group management bot that works on both Telegram and WhatsApp. Originally designed for Telegram, it now features a platform-independent architecture that allows seamless operation on WhatsApp Web.

🌟 Features

  • Multi-Platform Support: Works on both Telegram and WhatsApp
  • Modular Architecture: Clean separation between bot logic and platform connection
  • Group Management: Ban, kick, mute, and warn users
  • Auto Moderation: Anti-flood, blacklist, and spam protection
  • Custom Commands: Create custom filters and auto-responses
  • Welcome Messages: Greet new members automatically
  • Admin Tools: Comprehensive admin commands for group management
  • Easy to Extend: Simple adapter pattern for adding new platforms

πŸ“š Documentation

πŸš€ Quick Start

For WhatsApp

  1. Install Dependencies:
# Python dependencies
pip install -r requirements.txt

# Node.js dependencies
npm install
  1. Configure the Bot:
# Go to WhatsApp bot directory
cd bots/whatsapp

# Copy and edit configuration
cp sample_config.py wa_config.py
# Edit wa_config.py with your settings
  1. Run Automated Setup (Recommended):
python scripts/setup.py
  1. Or Start Manually:
# Terminal 1: Start WhatsApp Bridge
node bots/whatsapp/bridge.js

# Terminal 2: Start Bot
python bots/whatsapp/bot.py
  1. Scan QR Code:
    • QR code will appear in terminal
    • Scan with WhatsApp on your phone
    • Bot is ready!

For Telegram

The original Telegram bot still works!

python -m bots.telegram

See below for Telegram-specific configuration.

πŸ—οΈ Architecture

bot_core/                    # Platform-independent core
β”œβ”€β”€ models/                  # Abstract models (User, Chat, Message)
β”œβ”€β”€ adapters/               # Platform adapters
β”‚   β”œβ”€β”€ base_adapter.py     # Abstract adapter interface
β”‚   β”œβ”€β”€ telegram_adapter.py # Telegram implementation
β”‚   └── whatsapp_adapter.py # WhatsApp implementation
└── whatsapp_bridge_client.py # Python client for WhatsApp bridge

whatsapp_bridge.js          # Node.js server for WhatsApp Web API
tg_bot/                     # Telegram-specific bot code
tests/                      # Test suite

πŸ“¦ Requirements

For WhatsApp:

  • Python 3.6+
  • Node.js 14+
  • Dependencies in requirements.txt and package.json

For Telegram:

  • Python 3.6+
  • Dependencies in requirements.txt

βš™οΈ Configuration

WhatsApp Configuration

Create wa_config.py from sample_wa_config.py:

class WhatsAppConfig:
    OWNER_ID = "1234567890@c.us"  # Your WhatsApp ID
    OWNER_NAME = "Your Name"
    SESSION_NAME = "whatsapp-bot-session"
    PLATFORM = "whatsapp"
    SQLALCHEMY_DATABASE_URI = "sqlite:///bot.db"
    # ... more settings

Telegram Configuration

Create config.py in tg_bot/ folder:

from tg_bot.sample_config import Config

class Development(Config):
    OWNER_ID = 254318997
    OWNER_USERNAME = "YourUsername"
    API_KEY = "your_bot_token"
    SQLALCHEMY_DATABASE_URI = 'postgresql://user:pass@localhost:5432/dbname'
    # ... more settings

πŸ§ͺ Testing

Run the test suite:

python tests/test_bot_core.py

All tests should pass before deployment.

πŸ“– Available Modules

The bot includes many modules for group management:

  • Admin: Admin-only commands
  • Bans: Ban and unban users
  • Muting: Temporarily silence users
  • Warns: Warning system with auto-kick
  • Filters: Custom auto-responses
  • Notes: Save and retrieve information
  • Welcome: Welcome new members
  • Rules: Set and display group rules
  • Blacklist: Block specific words
  • Antiflood: Prevent message spam
  • Locks: Lock specific message types
  • And more!

πŸš€ Deployment Options

Method 1: Systemd Service (Linux)

python setup.py
# Follow prompts to create systemd services

Method 2: Docker

python setup.py
# Choose Docker option
docker-compose up -d

Method 3: Heroku (Telegram only)

Deploy to Heroku

πŸ“ Module Development

Creating Custom Modules

  1. Create a new .py file in tg_bot/modules/
  2. Import the dispatcher:
    from tg_bot import dispatcher
  3. Add handlers:
    dispatcher.add_handler(CommandHandler("mycommand", my_function))

Module Load Order

Configure in your config.py or wa_config.py:

LOAD = []  # Empty = load all modules
NO_LOAD = ['translation', 'rss']  # Modules to skip

If a module appears in both LOAD and NO_LOAD, it won't be loaded.

πŸ—„οΈ Database Setup

For database-dependent modules (locks, notes, filters, etc.):

PostgreSQL (Recommended)

# Install PostgreSQL
sudo apt-get update && sudo apt-get install postgresql

# Create user
sudo su - postgres
createuser -P -s -e YOUR_USER

# Create database
createdb -O YOUR_USER YOUR_DB_NAME

# Connection URI
postgresql://YOUR_USER:password@localhost:5432/YOUR_DB_NAME

SQLite (Development)

SQLALCHEMY_DATABASE_URI = "sqlite:///bot.db"

πŸ”§ Environment Variables

For deployment without config files (e.g., Heroku):

ENV=1  # Enable env mode
TOKEN=your_bot_token
OWNER_ID=your_telegram_id
OWNER_USERNAME=your_username
DATABASE_URL=your_database_url
LOAD=module1 module2
NO_LOAD=module3 module4
SUDO_USERS=user_id1 user_id2
# ... more variables

See sample_config.py for all available options.

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests: python tests/test_bot_core.py
  5. Submit a pull request

See CONTRIBUTING.md for details.

πŸ“„ License

See LICENSE for details.

πŸ’‘ Support

For help and support:

⚠️ Disclaimer

This bot is provided as-is. WhatsApp Web automation may violate WhatsApp's Terms of Service. Use at your own risk.

πŸ™ Credits

Originally based on the Rose Bot for Telegram. Extended to support WhatsApp with a modular architecture.

Assigning the __help__ variable to a string describing this modules' available commands will allow the bot to load it and add the documentation for your module to the /help command. Setting the __mod_name__ variable will also allow you to use a nicer, user friendly name for a module.

The __migrate__() function is used for migrating chats - when a chat is upgraded to a supergroup, the ID changes, so it is necessary to migrate it in the db.

The __stats__() function is for retrieving module statistics, eg number of users, number of chats. This is accessed through the /stats command, which is only available to the bot owner.

About

Telegram BoT

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages