Skip to content
Hridoy edited this page Nov 11, 2024 · 1 revision

Nexalo - Advanced Telegram Bot

Welcome to the Nexalo wiki! This page provides comprehensive information about setting up, configuring, and using the Nexalo Telegram bot.

Table of Contents

Features

  • 🛡️ Advanced group moderation (kick, ban, mute, warn)
  • 🎵 Music and video downloads
  • 🎮 Fun commands and games
  • 🔧 Utility functions
  • 📊 MongoDB integration for data persistence
  • ⚡ Fast and efficient command handling

Prerequisites

  • Node.js v16.x or higher
  • MongoDB v4.x or higher
  • A Telegram Bot Token (get it from @BotFather)
  • Basic knowledge of JavaScript/Node.js

Installation

  1. Clone the repository:
    git clone https://github.com/1dev-hridoy/Nexalo.git
    cd nexalo
  2. Install dependencies:
    npm install
  3. Rename example.env to .env in the root directory and fill in your details:
    BOT_TOKEN=YOUR_BOT_TOKEN
    OWNER_ID=OWNER_ID_HERE
    ADMIN_IDS=comma_separated_admin_ids
    MONGODB_URI=YOUR_MONGODB_URI
  4. Start the bot:
    npm start

Configuration

The bot uses environment variables for configuration. Create a .env file with the following variables:

  • BOT_TOKEN: Your Telegram bot token
  • MONGODB_URI: MongoDB connection string
  • OWNER_ID: Your Telegram user ID (for owner-only commands)

Command Structure

Commands should be created in the commands directory with the following structure:

module.exports = {
  name: 'commandname',
  adminOnly: false,
  ownerOnly: false,
  category: 'Category',
  description: 'Command description',
  guide: 'How to use the command',
  execute: async (bot, msg, args) => {
    // Command logic here
  }
};

Command Properties

  • name: Command name (without the / prefix)
  • adminOnly: Whether the command requires admin privileges
  • ownerOnly: Whether the command is restricted to bot owner
  • category: Command category for help menu organization
  • description: Brief description of what the command does
  • guide: Usage instructions
  • execute: Async function containing command logic

Creating Commands

Here's a step-by-step guide to creating new commands:

  1. Create a new file in the commands directory:
    // commands/hello.js
    module.exports = {
      name: 'hello',
      adminOnly: false,
      ownerOnly: false,
      category: 'Fun',
      description: 'Sends a greeting',
      guide: 'Use /hello to receive a greeting',
      execute: async (bot, msg, args) => {
        await bot.sendMessage(msg.chat.id, 'Hello! 👋');
      }
    };
  2. The command will be automatically loaded by the bot.

Advanced Command Example

Here's an example of a more complex command with argument handling and error checking:

// commands/remind.js
module.exports = {
  name: 'remind',
  adminOnly: false,
  ownerOnly: false,
  category: 'Utility',
  description: 'Set a reminder',
  guide: 'Use /remind <time> <message>',
  execute: async (bot, msg, args) => {
    if (args.length < 2) {
      return bot.sendMessage(msg.chat.id, 'Please provide time and message');
    }
const time = parseInt(args[0]);
const message = args.slice(1).join(' ');

if (isNaN(time)) {
  return bot.sendMessage(msg.chat.id, 'Please provide a valid time in minutes');
}

setTimeout(() => {
  bot.sendMessage(msg.chat.id, `Reminder: ${message}`);
}, time * 60000);

await bot.sendMessage(msg.chat.id, `Reminder set for ${time} minutes from now`);

} };

Database Setup

The bot uses MongoDB for data persistence. Here's how to set up your database:

  1. Create a MongoDB database
  2. Set up collections:
    • warnings: Store user warnings
    • settings: Store group settings
    • userdata: Store user-specific data

Database Schema Examples

Warnings Collection:

{
  userId: String,
  username: String,
  chatId: String,
  reason: String,
  timestamp: Date
}

Settings Collection:

{
  chatId: String,
  welcomeMessage: String,
  antiSpam: Boolean,
  maxWarnings: Number
}

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a pull request

Coding Standards

  • Use ES6+ features
  • Maintain consistent error handling
  • Add comments for complex logic
  • Follow the existing command structure
  • Test thoroughly before submitting

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you need help or have questions:

  • Open an issue on GitHub
  • Contact the bot owner through Telegram
  • Check the Wiki for additional documentation

Contact Options

Platform Contact
Discord Eliana Support Server
Telegram BD_NOOBRA
Instagram HridoyCode
YouTube Hridoy Code

Made with ❤️ by Hridoy