Features • Installation • Configuration • Commands • Support
- Features
- Installation
- Configuration
- Commands
- Creating Custom Commands
- Database System
- Hosting
- Support
- Contributing
- License
- 🚀 Modular Command System - Easy-to-use command handler with aliases and cooldowns
- 🎭 Event Handling - Support for group events (welcome, leave, etc.)
- 💾 Dual Database Support - JSON and MongoDB options
- 🔐 Role-Based Permissions - Three-tier permission system (User, Admin, Owner)
- 📊 User Statistics - Track user activity, levels, and messages
- 🎨 Rich Message Formatting - HTML/Markdown support with utilities
- 🔄 Auto-Update System - Built-in update checker and installer
- 🛡️ Auto Package Installation - Automatically installs missing dependencies
- 📈 Level System - User experience and leveling system
- 💰 Economy System - Built-in money and daily rewards
git clone https://github.com/sheikhtamimlover/STG-BOT.git && cp -r STG-BOT/. . && rm -rf STG-BOT
npm install
npm start-
Clone the repository
git clone https://github.com/sheikhtamimlover/STG-BOT.git cd STG-BOT -
Install dependencies
npm install
-
Configure the bot
- Edit
config.jsonand add your bot token - Get your bot token from @BotFather
- Edit
-
Start the bot
npm start
Edit config.json to customize your bot:
{
"prefix": "/", // Command prefix
"usePrefix": true, // Require prefix for commands
"adminUID": ["YOUR_USER_ID"], // Bot administrator user IDs
"onlyAdmin": false, // Restrict bot to admins only
"timezone": "Asia/Dhaka", // Bot timezone
"ownerName": "Sheikh Tamim", // Bot owner name
"botName": "STG BOT", // Bot display name
"token": "YOUR_BOT_TOKEN", // Telegram bot token (REQUIRED)
"allowInboxMode": true, // Allow private messages
"autoRestart": true, // Auto-restart on crash
"database": {
"type": "json", // Database type: "json" or "mongodb"
"uriMongodb": "", // MongoDB connection URI (if using MongoDB)
"autoSyncWhenStart": false, // Auto-sync on startup
"autoRefreshThreadInfoFirstTime": true
},
"levelSystem": {
"enabled": true, // Enable level system
"expPerMessage": 5, // EXP gained per message
"expToLevelUp": 100 // EXP needed per level
},
"reactionUnsend": {
"enabled": true, // Enable admin unsend via reaction
"emoji": "", // Custom unsend emoji
"likeEmoji": "❤️", // Like emoji
"allowAnyUser": false // Allow any user to unsend
}
}- Start a chat with your bot
- Send any message
- Use the
/uidcommand to get your user ID - Add your ID to
adminUIDinconfig.json
/help- List all available commands/help <command>- Get detailed help for a specific command/ping- Check bot response time and statistics/userinfo [@user]- View user information/rank- View your level and rank
/daily- Claim daily rewards (24-hour cooldown)
/admin add <user_id>- Add bot administrator/admin remove <user_id>- Remove administrator/admin list- List all administrators
/restart- Restart the bot/update- Check and install updates/eval <code>- Execute JavaScript code/shell <command>- Execute shell commands/cmd load/unload/reload <name>- Manage commands/events load/unload <name>- Manage events/dmaor/dmapproval- Manage DM approval requests/gaor/groupapproval- Manage group approval requests
/userdb [@user]- View user database information/threaddb- View group/thread database information
STG BOT includes powerful approval systems to control who can use the bot in DMs and which groups the bot can operate in.
When enabled in config.json, users must request approval before using the bot in private messages.
How it works:
- User sends first DM: When a non-approved user sends a message to the bot in DM, they receive a notification that approval is required
- Automatic approval request: The bot automatically creates an approval request and notifies the user to wait
- Admin review: Bot owners can use
/dmato view all pending approval requests - Admin actions:
- View pending:
/dma- Shows list of users waiting for approval - View approved:
/dma approved- Shows list of approved users - Approve user: Reply with
a <number>(e.g.,a 1approves first user) - Reject user: Reply with
r <number>(e.g.,r 1rejects and bans first user) - Revoke approval: In approved list, reply with
r <number>to revoke and ban
- View pending:
Configuration:
In config.json, set:
{
"dmApproval": {
"enabled": true,
"note": "When enabled, users need approval to use bot in DM"
}
}When enabled, the bot requires admin approval before it can operate in new groups.
How it works:
- Bot added to group: When someone adds the bot to a new group, it sends a notification that approval is required
- Automatic approval request: The bot creates an approval request with group details
- Admin review: Bot owners can use
/gato view all pending group approvals - Admin actions:
- View pending:
/ga- Shows list of groups waiting for approval - View approved:
/ga approved- Shows list of approved groups - Approve group: Reply with
a <number>(e.g.,a 1approves first group) - Reject group: Reply with
r <number>(e.g.,r 1rejects and leaves first group) - Revoke approval: In approved list, reply with
r <number>to revoke and leave group
- View pending:
Configuration:
In config.json, set:
{
"groupApproval": {
"enabled": true,
"note": "When enabled, bot will require admin approval when added to groups"
}
}Benefits:
- ✅ Prevent spam and abuse
- ✅ Control bot usage
- ✅ Review who's using your bot
- ✅ Maintain quality user/group base
- ✅ Easy management with simple commands
Create a new file in scripts/cmds/ directory:
module.exports = {
config: {
name: "mycommand", // Command name
aliases: ["mc", "mycmd"], // Command aliases
author: "Your Name", // Your name
version: "1.0", // Command version
cooldown: 5, // Cooldown in seconds
role: 0, // 0=Everyone, 1=Admin, 2=Owner
description: "My custom command",
category: "general",
usePrefix: true
},
// Main command handler
ST: async function ({ event, api, args, message, userId, chatId }) {
await message.reply("Hello from my command!");
},
// Optional: Trigger on any message
onChat: async function ({ event, api, message }) {
// React to specific keywords
},
// Optional: Handle replies to bot messages
onReply: async function ({ event, api, Reply, message }) {
// Handle user replies
},
// Optional: Handle callback queries (button clicks)
onCallback: async function ({ event, api, Callback }) {
// Handle button clicks
},
// Optional: Handle reactions
onReaction: async function ({ event, api, Reaction }) {
// Handle user reactions
},
// Optional: Called when command is loaded
onLoad: async function ({ api }) {
// Initialize command resources
}
};The message object provides these useful methods:
Reply to the user's message:
await message.reply("Hello!");
await message.reply("Formatted text", { parse_mode: 'Markdown' });Send a message to any chat:
await message.send("Hello!", chatId);
await message.send("Message", null, { parse_mode: 'HTML' });Delete a message:
await message.unsend(messageId);React to a message:
await message.react("❤️");
await message.react("👍", messageId);Edit a message:
await message.edit("Updated text", messageId);Send media files:
// Send photo
await message.sendAttachment({
body: "Caption text",
attachment: "/path/to/photo.jpg"
});
// Send video
await message.sendAttachment({
body: "Video caption",
attachment: "/path/to/video.mp4"
});
// Send audio
await message.sendAttachment({
body: "Audio caption",
attachment: "/path/to/audio.mp3"
});Get attachments from message:
const photo = message.getAttachment('photo');
const video = message.getAttachment('video');
const any = message.getAttachment('any');Download attachments:
const attachment = message.getAttachment('photo');
const path = await message.downloadAttachment(attachment, './photo.jpg');The /eval command allows you to execute JavaScript code (Owner only):
// Example 1: Get bot statistics
/eval return {
commands: global.ST.commands.size,
events: global.ST.events.size,
uptime: process.uptime()
}
// Example 2: Get user data
/eval return await global.db.getUser("USER_ID")
// Example 3: Send message to chat
/eval await global.bot.sendMessage("CHAT_ID", "Hello!")
// Example 4: Get all users
/eval return await global.db.getAllUsers()
// Example 5: Update user data
/eval return await global.db.updateUser("USER_ID", { money: 1000 })
// Example 6: Clear cooldowns
/eval global.ST.cooldowns.clear(); return "Cooldowns cleared"Create interactive buttons:
const sentMsg = await message.reply("Choose an option:", {
reply_markup: {
inline_keyboard: [
[{ text: "Option 1", callback_data: "option_1" }],
[{ text: "Option 2", callback_data: "option_2" }]
]
}
});
// Store callback data
global.ST.onCallback.set(sentMsg.message_id, {
commandName: 'mycommand',
author: userId,
data: { /* your data */ }
});Handle callback in onCallback:
onCallback: async function ({ event, api, Callback }) {
const query = event;
// Check if user is authorized
if (query.from.id !== Callback.author) {
return api.answerCallbackQuery(query.id, {
text: "Not authorized!",
show_alert: true
});
}
// Handle callback
const action = query.data;
if (action === 'option_1') {
await api.sendMessage(query.message.chat.id, "You chose option 1");
}
}STG BOT supports two database systems:
- Lightweight and easy to use
- No external dependencies
- Stored in
database/data/directory - Recommended for small to medium bots
- Scalable and powerful
- Recommended for large-scale bots
- Requires MongoDB connection URI
To switch to MongoDB:
- Set
"type": "mongodb"in config.json - Add your MongoDB URI to
"uriMongodb" - Restart the bot
- Import from GitHub: https://replit.com/github/sheikhtamimlover/STG-BOT
- Add your bot token in
config.json - Click "Run" button
- Keep your Repl always online with Replit Core
- Create new Web Service
- Connect your GitHub repository
- Set build command:
npm install - Set start command:
npm start - Add environment variables from
config.json
The bot can run on any Node.js hosting platform:
- Heroku
- Railway
- Fly.io
- VPS/Cloud servers
Requirements:
- Node.js 18 or higher
- 512MB RAM minimum
- Persistent storage for database
STG-BOT/
├── bot/ # Bot core files
│ ├── handler/ # Event and command handlers
│ └── login/ # Bot login logic
├── database/ # Database systems
│ ├── jsondb.js # JSON database
│ └── mongodb.js # MongoDB database
├── logger/ # Logging utilities
├── scripts/
│ ├── cmds/ # Command files
│ └── events/ # Event files
├── tmp/ # Temporary files
├── config.json # Configuration file
├── package.json # Dependencies
├── ST.js # Main bot file
├── utils.js # Utility functions
└── README.md # This file
- Telegram Group: STG BOT GC
- GitHub Issues: Report Issues
- GitHub: @sheikhtamimlover
- Instagram: @sheikh.tamim_lover
- Add more built-in commands
- Implement plugin system
- Add web dashboard
- Multi-language support
- Enhanced analytics
- AI integration
Contributions are welcome! Please feel free to submit a Pull Request.
- 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 MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2024 Sheikh Tamim
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- Thanks to all contributors who have helped this project grow
- Telegram Bot API for their excellent documentation
- The Node.js community for amazing tools and libraries
Made with ❤️ by Sheikh Tamim
⭐ Star this repository if you find it useful!







