A modular Telegram UserBot built on telethon. integrates Gemini LLM for context-aware automation, Edge-TTS for localized voice synthesis, and a custom media stack.
Installation Β· System Core Β· Modules Manual Β· Troubleshooting
Project Akasha solves the problem of "dumb" auto-replies. Unlike static userbots, it uses a Neural engine (Google Gemini) to generate responses that actually fit the conversation context, mimicking your typing style.
it includes a TTS Wrapper for amharic/english voice notes, a Two-Stage Music Downloader to save RAM, and various administration tools. The codebase is structured for easy deployment on local machines or cloud instances (Heroku/Railway).
ensure your directory matches this tree. The bot relies on relative paths for fonts and database persistence.
.
βββ .env # API keys & configuration
βββ config.py # settings loader
βββ main.py # event loope entry point
βββ requirements.txt # python dependencies
βββ docker-compose.yml
βββ Dockerfile # docker container configuration
βββ Procfile # cloud deployment instructions
βββ setup.sh # linux VPS automated setup
βββ LICENSE # Legal Usage Permissions
βββ core
β βββ database.py # JSON/Mongo handler
βββ plugins
βββ admin_tools.py # group management
βββ ai.py # LLM & vision Logic
βββ creative.py # pillow-based image manipulation
βββ master_voice.py # edge-TTS & FFmpeg filters
βββ music.py # yt-dlp audio wrapper
βββ security.py # TTL capture
βββ system.py # auto-reply logic
follow these steps to deploy. we use environment variables to prevent credential leaks.
1. Environment Prerequisites
Required: Python 3.9+ and FFmpeg (for audio conversion).
Ubuntu/Debian:
sudo apt update && sudo apt install python3 python3-pip ffmpeg -yWindows:
- Install Python from python.org.
- Install FFmpeg and add it to System PATH.
2. Install Dependencies
pip install -r requirements.txt3. Configuration (.env)
Create a .env file in the root directory. copy the structure below.
Note: the bot supports API key rotation to bypass free tier rate limits. You can use a single list (GEMINI_KEYS) or individual variables (GEMINI_KEY1...).
# ---telegram core---
# get from my.telegram.org
API_ID=123456
API_HASH=your_api_hash
SESSION=1BVts... # telethon session
# --- AI engine ---
# method 1: single list
# Separate keys with commas (,)
GEMINI_KEYS=AIzaSy1...,AIzaSy2...,AIzaSy3...
# Method 2: individual variables
GEMINI_KEY1=AIzaSyD...
GEMINI_KEY2=AIzaSyF...
GEMINI_API_KEY=AIzaSy... # fallback
# --- database ---
# leave empty for local JSON
MONGO_URL=β οΈ security: never commit your
.envorSESSIONstring to public repositories.
4. Execution
python main.pyTriggers Config.check_integrity() on startup to validate keys.
for Render, Railway, or Heroku, skip the .env file. Inject these variables directly into the dashboard's environment settings:
API_IDAPI_HASHSESSIONGEMINI_KEYS(paste all your keys here, separated by commas. Example:Key1,Key2,Key3).
managed by plugins/system.py. handles the "Away State" logic.
controls the reply engine.
| Command | Logic |
|---|---|
.auto ai |
neural mode: fetches context from the last 5 messages and generates a response via Gemini. |
.auto static |
static mode: replies with a pre set string (e.g., "Busy"). |
.auto off |
passthrough: disables all automation. |
.auto [text] |
updates the static mode variable. |
injects specific system prompts into the AI to alter tone.
sleep- short, groggy responses.work- professional, concise.gaming- dismissive/short.default- standard conversational style.
to prevent bot detection:
- read delay: random
1-3ssleep before marking as read. - typing: calculates
len(response) * 0.1sto simulate human typing speed.
standard group administration.
- Whois:
.whois @user. generates a user profile card (ID, DC, Scam Status, Bio). - Translator:
Text //lang_code. replaces the message with the translation (e.g.,Hey //am->α°αα). - moderation:
.purge: deletes messages recursively..ban / .mute: standard user restrictions..zombies: Scans for deleted accounts and cleans them to fix member counts.
Caution
Rate Limits: massive purges or zombie cleaning can trigger telegram's floodWait. use sparingly.
direct wrapper for Microsoft Edge TTS. supports SSML tags for pitch/rate control.
Command: .say [text] [flags]
- auto detect: switches between
Mekdes(Amharic) andJenny(English) based on scrip.
Flags (FFmpeg Filters):
| Flag | Filter Applied |
|---|---|
.f / .m |
Force Female/Male model. |
.echo |
aecho filter (Hall effect). |
.radio |
High-pass/Low-pass filter chain. |
.demon |
Pitch shift -400Hz. |
.kid |
Pitch shift +400Hz. |
Shortcut: .whisper applies .slow + low volume.
pillow based image manipulation.
- Meme Gen:
.meme [Top];[Bottom].- logic: auto-fetches
NotoSansEthiopic-BoldorNotoSansArabicif the text script requires it. caches fonts locally.
- logic: auto-fetches
- Sticker Kang:
.kang. converts media to512pxWebP and appends to your sticker pack.- Limit: Skips files >5MB to prevent memory leaks on VPS.
uses yt-dlp for soundCloud/youtube extraction.
Workflow:
- Search:
.song [Query]. fetches metadata onlys. Caches result in RAM (SEARCH_STATE). - Select: Reply
1 to 5. - Process: Downloads -> converts to MP3 192kbps (FFmpeg) -> writes id3 tags -> uploads.
Note
Hard Limit: files >50MB are rejected to avoid telegram upload timeouts.
- Generative:
.ai [prompt]. uses the rotated API key pool. - Vision: reply to an image with
.ai explain. Downloads image to memory buffer -> sends to Gemini Vision API. - Image Search:
.imgor.imgs(Gallery). scrapes DuckDuckGo for images.
status: disabled by default.
- function: hooks into the
MessageMediaevent. Ifttl_period > 0:- Downloads media to temp.
- Forwards to "Saved Messages".
- Appends "κ vault capture" tag.
.hack @user: edits a message repeatedly to simulate a terminal breach. purely prank.
1. FFmpeg Error:
FileNotFoundError: ensure Ffmpeg is in your System PATH or installed via apt.
2. API Key Limits:
If .ai fails, check if your Gemini keys are valid. the bot auto rotates, but if all are exhausted, it will return an error.
3. Dependency Issues:
force reinstall: pip install --force-reinstall -r requirements.txt.
Licensed under the MIT License.
Project Akasha v1.0
Built for the Unknown purpose βοΈ.

