A powerful, modular Telegram userbot built with Pyrogram and PyTgCalls. HazelUB supports multi-session management, allowing you to run multiple Telegram accounts simultaneously with a single deployment.
- π Multi-Session Support β Run multiple Telegram accounts from one instance.
- π΅ Music & Voice Chat β Play, pause, resume, and queue music in Telegram voice chats with built-in VC tools.
- π Modular Plugin System β Add or remove features by simply dropping
.pyfiles in theMods/folder. No registration needed. - π Sudo User System β Grant trusted users permission to execute commands on your behalf, per-client.
- π Message Repeater β Schedule periodic message broadcasts to groups with pause/resume support.
- ποΈ Dual Database Support β PostgreSQL for production, SQLite as an automatic fallback.
- π Built-in Help Menu β Auto-generated inline help menu from all loaded mods.
- π‘οΈ Admin Utilities β Ban, purge, delete, and manage chats with ease.
- π± Desktop Notifications β Get notified when HazelUB starts (via plyer).
- Python 3.13+
- FFmpeg β required for voice chat / music features
- A Telegram API ID & Hash β get from my.telegram.org
- A Pyrogram session string β generate from telegram.tools
- A Bot Token β get from @BotFather (enable inline mode too)
- PostgreSQL database URL (falls back to SQLite automatically)
- Gemini API Key β for AI features, get from Google AI Studio
git clone https://github.com/DevsBase/HazelUB.git
cd HazelUBYou can configure HazelUB using either config.py or environment variables (.env).
API_ID = "your_api_id"
API_HASH = "your_api_hash"
SESSION = "your_pyrogram_session_string"
BOT_TOKEN = "your_bot_token"
# Optional
DB_URL = "postgresql+asyncpg://user:pass@host/dbname"
OtherSessions = ["session2", "session3"]
PREFIX = [".", "~"]
GEMINI_API_KEY = "your_gemini_key"Copy the example and fill in your values:
cp .env.example .envAPI_ID=your_api_id
API_HASH=your_api_hash
SESSION=your_pyrogram_session_string
BOT_TOKEN=your_bot_token
DB_URL=
OtherSessions=
PREFIX=
GEMINI_API_KEY=Note: Values in
config.pytake priority over environment variables. If a required key is missing from both, you will be prompted interactively.
python -m HazelOn first run, HazelUB will automatically install all required packages from requirements.txt and restart itself.
docker build -t hazelub .
docker run -d --name hazelub hazelub| Key | Required | Default | Description |
|---|---|---|---|
API_ID |
β | β | Telegram API application ID |
API_HASH |
β | β | Telegram API application hash |
SESSION |
β | β | Pyrogram session string for the primary account |
BOT_TOKEN |
β | β | Bot token or bot session string (for the assistant bot) |
DB_URL |
β | "" (SQLite) |
PostgreSQL connection URL. If empty, SQLite (HazelUB.db) is used |
OtherSessions |
β | [] |
List of additional Pyrogram session strings for multi-account |
PREFIX |
β | [".","~","$","^"] |
Command trigger prefixes |
GEMINI_API_KEY |
β | "" |
Google Gemini API key for AI features |
All commands are triggered using your configured prefix (default: .). Here are some built-in commands:
| Command | Description |
|---|---|
.help |
Open the interactive help menu |
.ping |
Check latency & uptime |
.ai <prompt> |
Chat with Gemini AI |
.play <song> |
Play a song in voice chat |
.pause / .resume |
Pause or resume playback |
.ban / .unban |
Ban or unban a user (reply or mention) |
.del |
Delete a replied message |
.purge |
Bulk-delete messages |
.id |
Get user / chat ID |
.ud <word> |
Look up a word on Urban Dictionary |
.eval <code> |
Evaluate Python code (owner only) |
.addsudo <user> |
Grant sudo access |
.delsudo <user> |
Revoke sudo access |
.sudolist |
List all sudo users |
Tip: All prefixes work interchangeably β
.ping,~ping,$ping, and^pingdo the same thing.
Creating a mod is as simple as adding a .py file to the Mods/ folder. Here's a minimal example:
from Hazel import Tele
from pyrogram.client import Client
from pyrogram import filters
from pyrogram.types import Message
@Tele.on_message(filters.command("hello"), sudo=True)
async def hello_command(client: Client, message: Message):
await message.reply("**Hello!** π")
MOD_NAME = "Hello"
MOD_HELP = "**Usage:**\n> .hello - Sends a greeting."π For a detailed guide, see Mods/README.md.
- Files starting with
_are ignored by the loader. - Define
MOD_NAMEandMOD_HELPto appear in the.helpmenu. - Use
sudo=Trueto allow both the owner and sudo users to run the command. - Your handler is automatically registered across all active client sessions.
HazelUB uses SQLAlchemy (async) with support for two backends:
| Backend | When Used | Connection |
|---|---|---|
| PostgreSQL | When DB_URL is set |
asyncpg driver |
| SQLite | Fallback (default) | aiosqlite driver, file: HazelUB.db |
The database is accessed globally via Hazel.SQLClient (an instance of DBClient). Tables are auto-created on first startup.
- Create a new model file in
Database/Tables/(e.g.myTable.py). - Import
BasefromDatabase.Tables.baseand define your model. - The table loader (
Database/Tables/loader.py) auto-discovers all models in theTables/directory.
HazelUB can run multiple Telegram accounts simultaneously:
- Set your primary session in
SESSION. - Add additional session strings to
OtherSessionsinconfig.py. - Each session gets its own Pyrogram
ClientandPyTgCallsinstance. - The
@Tele.on_message()decorator automatically registers handlers on all sessions.
- Fork the repository.
- Create a feature branch (
git checkout -b feature/my-feature). - Commit your changes (
git commit -m "Add my feature"). - Push to the branch (
git push origin feature/my-feature). - Open a Pull Request.
- Use type hints on all function signatures.
- Add docstrings to public functions and classes.
- Follow the existing code style and module structure.
- Test your changes before submitting.
This project is licensed under the MIT License β see the LICENSE file for details.
Made with β€οΈ by DevsBaseβ’ & Otazuki