Skip to content

Latest commit

Β 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

 β–ˆβ–ˆβ•—  β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
 β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ•β•β–ˆβ–ˆβ•”β•β•β•    β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•‘       β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘
 β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β•šβ•β•β•β•β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘       β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘
 β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘       β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•   β–ˆβ–ˆβ•‘
 β•šβ•β•  β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β•β•   β•šβ•β•       β•šβ•β•β•β•β•β•  β•šβ•β•β•β•β•β•    β•šβ•β•

  πŸ›‘οΈ  TELEGRAM GROUP MANAGEMENT BOT  πŸ›‘οΈ

typing

Stars License Python


✨ Features

Feature Description
πŸ›‘οΈ Full Moderation ban, tban, kick, mute, tmute, warn, promote, demote
⚠️ Warning System Auto-ban at configurable warn threshold
🎯 Content Locks Lock links, media, stickers, polls, forwards per-group
🚫 Blacklist Word blacklist with auto-delete & auto-warn
πŸ“ Notes System Save & retrieve notes with #name triggers (FallenRobot-style)
πŸ”€ Custom Filters Keyword auto-reply filters stored per-group
πŸ‘‹ Welcome Messages Customizable with {name} {id} {title} placeholders
πŸ€– Captcha Verification Math captcha on join with auto-kick timeout
πŸ“Œ Pin Management pin, unpin, unpinall, purge ranges, cleanup
⏱️ Slowmode Set message cooldown via /slowmode <seconds>
πŸŽ‰ Fun Commands roll, flip, 8ball, hug, slap, pat, kiss, meme, quote, poll
πŸ“Š Statistics Group stats, user lookup, admin list
πŸ—„οΈ MongoDB Per-group persistent settings, warnings, notes, filters
⚑ Webhook-based Raw HTTP + Flask β€” no polling, instant updates
πŸ”§ Modular 9 clean modules, easy to extend or disable

πŸ“ Project Structure

KustRobot/
β”œβ”€β”€ main.py                  ← Flask app + webhook dispatcher
β”œβ”€β”€ config.py                ← Environment variables & constants
β”œβ”€β”€ requirements.txt         ← Flask, requests, pymongo
β”œβ”€β”€ database/
β”‚   └── mongo.py             ← MongoDB collections manager
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ api.py               ← Raw HTTP Telegram API helper with retries
β”‚   └── helpers.py           ← is_admin, resolve_target, get/set_chat_setting
└── modules/
    β”œβ”€β”€ admin.py             ← ban, kick, mute, warn, promote, demote
    β”œβ”€β”€ greetings.py         ← welcome messages, captcha verification
    β”œβ”€β”€ rules.py             ← setrules, rules, clearrules
    β”œβ”€β”€ filters.py           ← lock/unlock, custom keyword filters
    β”œβ”€β”€ notes.py             ← save, get, #triggers (FallenRobot-style)
    β”œβ”€β”€ blacklist.py         ← word blacklist with auto-warn
    β”œβ”€β”€ pins.py              ← pin, unpin, purge, cleanup, slowmode
    β”œβ”€β”€ fun.py               ← roll, 8ball, hug, slap, meme, quote
    └── misc.py              ← start, help, id, whois, stats

πŸš€ Quick Deploy

Fork this repo first before deploying!

Deploy on Render Deploy on Railway Deploy on Heroku Deploy on Koyeb


πŸ”§ Environment Variables

Set these on your platform or in a .env file:

Variable Required Description
BOT_TOKEN βœ… Your Telegram bot token from @BotFather
WEBHOOK_SECRET βœ… Any random secret string for webhook security
MONGO_URI βœ… MongoDB connection string (local or Atlas)
ADMIN_IDS βœ… Your Telegram user ID(s), comma-separated
DB_NAME ❌ Database name (default: kustrobot)
PORT ❌ Server port (default: 5000)

πŸ“¦ Platform-Specific Deployment

☁️ Render (Recommended)

  1. Fork this repo
  2. Go to render.com β†’ New Web Service
  3. Connect your forked repo
  4. Set Build Command: pip install -r requirements.txt
  5. Set Start Command: python main.py
  6. Add environment variables in the dashboard
  7. Deploy β€” Render gives you a public HTTPS URL
  8. Set your webhook:
curl -X POST "https://api.telegram.org/bot<BOT_TOKEN>/setWebhook" \
     -d "url=https://your-app.onrender.com/webhook/<WEBHOOK_SECRET>"

πŸš‚ Railway

  1. Fork this repo
  2. Go to railway.app β†’ New Project β†’ Deploy from GitHub
  3. Connect your forked repo
  4. Add environment variables under Variables
  5. Add a MongoDB plugin from Railway's marketplace (or use Atlas)
  6. Railway auto-detects Python and deploys β€” grab your public URL
  7. Set your webhook using the Railway URL

🟣 Heroku

  1. Fork this repo
  2. Go to heroku.com β†’ New App
  3. Connect your GitHub fork under Deploy tab
  4. Set environment variables under Settings β†’ Config Vars
  5. Set buildpack to heroku/python
  6. Enable Automatic Deploys or deploy manually
  7. Set your webhook using https://your-app.herokuapp.com/webhook/<SECRET>

Note: Add a Procfile if not present:

web: python main.py

πŸ”΅ Koyeb

  1. Fork this repo
  2. Go to koyeb.com β†’ Create App
  3. Select GitHub β†’ connect your fork
  4. Set Run command: python main.py
  5. Add environment variables in the app settings
  6. Koyeb gives a public HTTPS URL β€” set your webhook to it

πŸ–₯️ VPS / Self-Hosted

# 1. Clone your fork
git clone https://github.com/YOUR_USERNAME/KustRobot
cd KustRobot

# 2. Install dependencies
pip install -r requirements.txt

# 3. Set environment variables
export BOT_TOKEN="your_token"
export WEBHOOK_SECRET="your_secret"
export MONGO_URI="mongodb://localhost:27017"
export ADMIN_IDS="your_user_id"

# 4. Run (use tmux or screen to keep it alive)
tmux new -s kustrobot
python main.py
# Press Ctrl+B then D to detach

Set up HTTPS with nginx + Let's Encrypt:

# Install nginx + certbot
sudo apt install nginx certbot python3-certbot-nginx

# Get SSL certificate
sudo certbot --nginx -d yourdomain.com

# Add nginx reverse proxy to port 5000
# Then set webhook to: https://yourdomain.com/webhook/<SECRET>

πŸƒ MongoDB Setup

Option 1 β€” MongoDB Atlas (Cloud, Free):

  1. Go to mongodb.com/atlas
  2. Create a free cluster
  3. Get your connection string: mongodb+srv://user:pass@cluster.mongodb.net/kustrobot
  4. Set this as MONGO_URI

Option 2 β€” Local MongoDB:

# Install MongoDB
sudo apt install mongodb

# Start service
sudo systemctl start mongodb

# Use this URI:
# mongodb://localhost:27017

πŸ“‹ Commands

πŸ›‘οΈ Moderation

Command Description
/ban @user Ban a user
/tban @user 1h Temporarily ban (use s/m/h/d)
/unban @user Unban a user
/kick @user Kick a user
/mute @user Mute a user
/tmute @user 30m Temporarily mute
/unmute @user Unmute a user
/warn @user <reason> Warn a user
/unwarn @user Remove one warning
/warnings @user Check warning count
/clearwarns @user Clear all warnings
/setwarnlimit <n> Set auto-ban threshold
/promote @user Promote to admin
/demote @user Demote admin
/banlist List banned users
/getadmins List all admins

βš™οΈ Settings

Command Description
/setwelcome <msg> Set welcome message ({name} {id} {title})
/welcome on|off Toggle welcome messages
/setcaptcha on|off Toggle captcha for new members
/setrules <text> Set group rules
/rules Show group rules
/clearrules Clear group rules
/setwarnlimit <n> Set warning threshold before auto-ban

πŸ”’ Content Control

Command Description
/lock links|media|stickers|all|forward|polls Lock content type
/unlock <type> Unlock content type
/locks Show current lock status
/filter <keyword> <reply> Add auto-reply keyword filter
/stop <keyword> Remove a filter
/filters List all active filters
/addblacklist <word> Add word to blacklist
/rmblacklist <word> Remove from blacklist
/blacklist List blacklisted words

πŸ“ Notes (FallenRobot-style)

Command Description
/save <name> <content> Save a note
/save <name> (reply) Save replied message as note
#name Retrieve note instantly
/get <name> Get a note by name
/delnote <name> Delete a note
/notes List all saved notes

πŸ“Œ Pins & Cleanup

Command Description
/pin Pin replied message
/unpin Unpin current pinned message
/unpinall Unpin all pinned messages
/purge Delete messages from reply to now
/cleanup <n> Delete last n messages (max 100)
/slowmode <seconds> Set slowmode (0 to disable)

πŸŽ‰ Fun

Command Description
/roll [sides] Roll a dice
/flip or /toss Flip a coin
/8ball <question> Magic 8-ball
/hug [@user] Send a hug
/slap [@user] Slap someone
/pat [@user] Pat someone
/kiss [@user] Send a kiss
/meme Random meme
/quote Inspirational quote
/poll <q>|opt1|opt2 Create a poll
/stickerid Get sticker file ID

ℹ️ Utility

Command Description
/start Bot info and overview
/help Interactive help menu
/id Your user & chat ID
/whois [@user] User info and warnings
/stats Group statistics

πŸ—„οΈ Database Collections

Collection Stores
chat_settings Per-group settings (welcome, rules, locks, warn threshold)
warnings User warnings with timestamps and reasons
banned_users Banned user records per group
captcha_challenges Pending captcha verifications
notes Saved notes (text, photos, videos, stickers, etc.)
blacklist Blacklisted words per group
filters Custom keyword auto-reply filters

βš™οΈ Tech Stack

Component Technology
Language Python 3.7+
Web Framework Flask 2.3.3
Database MongoDB 4.6+ (via pymongo)
HTTP Client Requests 2.31.0
Bot API Raw Telegram HTTP API

πŸ“œ License

GNU General Public License v3.0 β€” See LICENSE


🀝 Contributing

Pull requests are welcome. For major changes, open an issue first.

  1. Fork the repo
  2. Create your branch: git checkout -b feature/my-feature
  3. Commit changes: git commit -m "Added my feature"
  4. Push: git push origin feature/my-feature
  5. Open a Pull Request

πŸ“ž Support

Updates Channel Support Group GitHub Issues


Made with ❀️ by @kustbots

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages