Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/1dev-hridoy/nexalo
A powerful Node.js Telegram bot offering advanced moderation, fun commands, music downloads, and MongoDB integration for data persistence.
https://github.com/1dev-hridoy/nexalo
api automation chatbot communitysupport customcommands database devtools funcommands javascript mitlicense moderation mongodb musicbot nodejs opensource telegrambot tgbot utilities
Last synced: 19 days ago
JSON representation
A powerful Node.js Telegram bot offering advanced moderation, fun commands, music downloads, and MongoDB integration for data persistence.
- Host: GitHub
- URL: https://github.com/1dev-hridoy/nexalo
- Owner: 1dev-hridoy
- License: mit
- Created: 2024-11-08T17:23:15.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-12-01T09:19:04.000Z (about 2 months ago)
- Last Synced: 2024-12-01T09:30:55.501Z (about 2 months ago)
- Topics: api, automation, chatbot, communitysupport, customcommands, database, devtools, funcommands, javascript, mitlicense, moderation, mongodb, musicbot, nodejs, opensource, telegrambot, tgbot, utilities
- Language: JavaScript
- Homepage: https://t.me/NexaloBot
- Size: 1.93 MB
- Stars: 5
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
Nexalo - Advanced Telegram Bot
A feature-rich Telegram bot built with Node.js that provides various utility, moderation, and entertainment commands.
## Table of Contents
- [Features](#features)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Configuration](#configuration)
- [Command Structure](#command-structure)
- [Creating Commands](#creating-commands)
- [Available Commands](#available-commands)
- [Database Setup](#database-setup)
- [Contributing](#contributing)
- [License](#license)## 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](https://t.me/BotFather))
- Basic knowledge of JavaScript/Node.js## Installation
1. Clone the repository:
```bash
git clone https://github.com/1dev-hridoy/Nexalo.git
cd nexalo
```2. Install dependencies:
```bash
npm install
```3. Rename a `example.env` To `.env` file in the root directory:
```env
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:
```bash
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:
```javascript
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:
```javascript
// 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:
```javascript
// commands/remind.js
module.exports = {
name: 'remind',
adminOnly: false,
ownerOnly: false,
category: 'Utility',
description: 'Set a reminder',
guide: 'Use /remindconst 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:
```javascript
{
userId: String,
username: String,
chatId: String,
reason: String,
timestamp: Date
}
```Settings Collection:
```javascript
{
chatId: String,
welcomeMessage: String,
antiSpam: Boolean,
maxWarnings: Number
}
```## Mongo DB Add Balance To User Account
```javascript
const { ObjectId } = require('mongodb');module.exports = {
name: 'addCoins',
adminOnly: false, // Set to true if only admins should use this command
ownerOnly: false, // Set to true if only the bot owner should use this command
category: 'Economy',
description: 'Add coins to a user\'s balance',
guide: 'Use /addCoins to add coins to your account',
execute: async (bot, msg, args, db) => {
const userId = msg.from.id;
const chatId = msg.chat.id;
const coinAmount = 10; // Amount to addtry {
const user = await db.collection('users').findOne({ userId });if (user) {
await db.collection('users').updateOne(
{ userId },
{ $inc: { balance: coinAmount } }
);
} else {
await db.collection('users').insertOne({
userId,
balance: coinAmount,
lastDaily: new Date(0) // Initialize lastDaily if not needed immediately
});
}bot.sendMessage(chatId, `10 coins have been added to your balance!`);
} catch (error) {
console.error('Error in addCoins command:', error);
bot.sendMessage(chatId, 'An error occurred while processing your request.');
}
}
};```
## Use User Account Balance/Coin
```javascript
const { ObjectId } = require('mongodb');module.exports = {
name: 'usecoin',
adminOnly: false,
ownerOnly: false,
category: 'Economy',
description: 'Use 10 coins for a special action!',
guide: 'Use /usecoin to spend 10 coins on an action',
execute: async (bot, msg, args, db) => {
const userId = msg.from.id;
const chatId = msg.chat.id;
const coinCost = 10; // Cost of the action in coinstry {
// Check user balance
const user = await db.collection('users').findOne({ userId });
if (!user || user.balance < coinCost) {
return bot.sendMessage(chatId, `Insufficient balance. You need at least ${coinCost} coins to perform this action.`);
}// Perform the action (e.g., sending a confirmation message)
await bot.sendMessage(chatId, 'You have successfully used 10 coins for this special action!');// Deduct 10 coins from user's balance
await db.collection('users').updateOne(
{ userId },
{ $inc: { balance: -coinCost } }
);bot.sendMessage(chatId, `${coinCost} coins have been deducted from your account.`);
} catch (error) {
console.error('Error in usecoin command:', error);
bot.sendMessage(chatId, 'An error occurred while processing your request. Please try again later.');
}
}
};```
## Contributing
1. Fork the repository
2. Submit 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](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
Discord
Telegram
YouTube
Eliana Support Server
BD_NOOBRA
HridoyCode
Hridoy Code
Made with ❤️ by Hridoy