-
Notifications
You must be signed in to change notification settings - Fork 116
Installation
Caution
Don't install the userbot on recent registered accounts
| Variable | Importance | Description | Source / Link | Default value |
|---|---|---|---|---|
API_ID |
Required | Your Telegram API ID. | my.telegram.org | 2040 |
API_HASH |
Required | Your Telegram API Hash. | my.telegram.org | b18441a1ff607e10a989891a5462e627 |
STRINGSESSION |
Required* | Pyrogram session string. Necessary for Docker/Cloud. |
Use Script OR |
— |
DATABASE_TYPE |
Required | Set to sqlite3 or mongodb. |
— | — |
DATABASE_NAME |
Required | File name for sqlite3 (e.g., db.sqlite3) or Mongo DB name. |
— | — |
DATABASE_URL |
Optional | Your MongoDB connection URL (only if using Mongo). | MongoDB Atlas | — |
PM_LIMIT |
Optional | Number of warnings before Anti-PM kicks in. | — | 4 |
MODULES_REPO_BRANCH |
Optional | Default custom modules repo branch | - | main |
SECOND_SESSION |
Optional | Session string for the Music Bot feature. | — | — |
GEMINI_KEY |
Plugin | API Key for Gemini AI features. | Google AI Studio | — |
APIFLASH_KEY |
Plugin | API Key for taking web screenshots. | ApiFlash | — |
RMBG_KEY |
Plugin | API Key for the removebg background remover. |
remove.bg | — |
VT_KEY |
Plugin | API Key for the VirusTotal file scanner. | VirusTotal | — |
COHERE_KEY |
Plugin | API Key for Cohere AI features. | Cohere Dashboard | — |
-
Database: If you are using
sqlite3, you can leaveDATABASE_URLblank. -
Sessions: If
STRINGSESSIONis not provided, the bot will attempt to generate one at startup via the terminal, but this is not recommended for headless environments like Heroku or Docker.
| Koyeb | Heroku | Render |
|---|---|---|
- YT Video [How to deploy on Koyeb]: https://youtu.be/2m_yB7EllYc
- YT Video by a user [How to deploy on Koyeb]: https://youtu.be/AmlFBZ26tY4?si=3buw5OCJ2wEz3tVJ
For most people above instrunctions are enough to deploy Moon-Userbot. Though if you still haven't been able to understand or deploy Moon-Userbot or maybe you're reading type person (like me), then continue reading.
- Go to Koyeb and sign up. Remember to use your real Gmail or your Github for it.
- Now you need to create a string session, watch this video to know how to create a string session.
- Now click on this link
- You'll be redirected to Koyeb's Deploy page. It'll look like this:
| PC | Mobile |
|---|---|
![]() |
![]() |
- Now time to configue our environment variable:
- Click on
Environment Variables:
- Choose "Raw Editor":
- Now copy and paste this to the editor.
- Edit the variables with your own values.
⚠️ Do not remove any variable.⚠️ Just leave it blank if you don't want to use an optional variable.
- After that we need to also add one more variable for
PORTwith 8080 as value.
Verify that you've 15 variables configured:
- Now comes builder part, for that we've two options: 1. Dockerfile 2. Buildpacks.
-
Dockerfile:
- Click on
Dockerfile:
- and override Dockerfile location:
- Click on
-
Buildpacks:
- Click on
Buildpacksand override the run command as below:
- Click on
- Choose region as Washingtion DC:
- Change Exposed Port to 8080:
- Now click on
Deployand wait for the build to finish. And 🥳 you're done.
- Click on
If you're a premium user of Render, you can easily deploy Moon-Userbot on Render by clicking on the "Deploy to Render" icon above. The Moon repository contains a render.yaml file that is compatible with Render and has all the necessary settings. All you need to do is add a file in the environment section with the name .env and configure your variables in it.
Here are the detailed steps:
- You'll be redirected to Render's Deploy page.
- Now, you need to add your environment variables. Click on the "New Environment Variable" button.
- Copy and paste the contents of this file into the editor. This file contains all the necessary variables.
- Edit the variables with your own values.
⚠️ Do not remove any variable.⚠️ Just leave it blank if you don't want to use an optional variable. - After adding all the variables, click on "Add" to save them.
- Now, Render will automatically build and deploy your Moon-Userbot.
- Once the deployment is complete, you're done.
Heroku is no longer free. But you can still deploy Moon-Userbot on Heroku if you're paid user of it. Since we don't have any paid Heroku account, we can't provide you with a detailed guide. Feel free to contribute if you have a paid Heroku account and can help us with the guide.
You can either use docker run or docker compose.
- Docker
- Docker Compose (version 1.x for
docker-compose.yml, version 2.x forcompose.yml) - Put your environment vars in
.envfile check .env.dist for example format
We also push images to Docker Hub, so you can use the following commands to start and update the service:
- Start:
- If you want to use normal image:
docker run --env-file ./.env -d qbtaumai/moonuserbot:latest
- If you want to use image with web (only recommended for heroku/koyeb/render etc.):
docker run --env-file ./.env -d qbtaumai/moonubcloud:latest-cloud
- Updating:
then re-run the start command
docker stop $(docker ps -q)
If you're using Docker Compose version 1.x, use the following commands to start and update the service:
- Start:
docker-compose -f docker-compose.yml up -d
- Updating & running:
docker-compose -f docker-compose.yml down && docker-compose -f docker-compose.yml pull && docker-compose -f docker-compose.yml up -d
If you're using Docker Compose version 2.x, use the following commands to start and update the service:
- Start:
docker compose -f compose.yml up -d
- Updating & running:
docker compose -f compose.yml down && docker compose -f compose.yml pull && docker compose -f compose.yml up -d
Important
Make Sure you add appropriate env vars
There are instructions for installing on several different Unix distributions on the Git website, at https://git-scm.com/download/linux
git clone https://github.com/The-MoonTg-project/Moon-Userbot.gitcd Moon-Userbot
chmod +x install.sh
./install.shInstaller tested on:
- Arch
- Debian
- Ubuntu
- WSL (APT based distros)
Feel free to test on other distros and let us know!
- Download and install termux from f-droid (click (https://f-droid.org/en/packages/com.termux/))
- Copy this command and paste in termux:
curl -L# https://raw.githubusercontent.com/The-MoonTg-project/Moon-Userbot/master/termux-install.sh -o t-moonub.sh && bash t-moonub.sh-
Termux may ask permission to work in the background, you should allow it
-
Wait for the "Enter API_ID and API_HASH" message in the terminal. If you aren't a developer and do not understand what it means, just press Enter. Afterwards proceed with the follow up vars it asks for.
-
When it'll ask about database type ("Choose database type"), enter 2 and press Enter
-
Now you need to authorize your Telegram account. Just follow instructions that you'll see - literally enter your Telegram's phone number and press enter.
-
When it'll ask "Is correct? (y/N)", enter 'y'
-
You'll receive a message from Telegram with a confirmation code. You should copy it and enter it to the terminal when it asks "Enter confirmation code".
- If your account has a 2fa password, you'll be asked to enter it
-
Congrats! Userbot installed successfully. To start userbot, enter this command in shell:
cd Moon-Userbot/ && python main.py -
Switch to Telegram and enjoy 🎉
- Copy this command and paste it to Terminal:
sudo apt update && sudo apt upgrade -y && sudo apt install git && git clone https://github.com/The-MoonTg-project/Moon-Userbot.git && cd Moon-Userbot/ && sudo bash install.sh-
Wait for the "Enter API_ID and API_HASH" message in the terminal. If you aren't a developer and do not understand what it means, just press Enter.
-
When it'll ask about database type ("Choose database type"), enter sqlite option and press Enter
- Those who know How-to's if want mongodb then they can use 1 option too
-
Now you need to authorize your Telegram account. Just follow instructions that you'll see - literally enter your Telegram's phone number and press enter.
-
When it asks Is correct? (y/N) > enter 'y'
-
You'll receive a message from Telegram with a confirmation code. You should copy it and enter it to the terminal when it asks "Enter confirmation code".
- If your account has a 2fa password, you'll be asked to enter it
-
Congrats! Userbot installed successfully. To start userbot, enter this command in shell:
cd Moon-Userbot / && python main.py
- Switch to Telegram and enjoy :)
-
You need WSL feature enabled and install any WSL distro of your choice
-
Follow the steps mentioned in Linux section.
Moon-Userbot: Elevate Your Telegram Journey Beyond Limits!

