Deployment

This Userbot can be deployed with four different ways. Which are Heroku, Docker, Zeet and Legacy way.

Termux - Run the Userbot in Termux (mobile).

Docker - Run the Userbot in an isolated application that doesn’t interfere to the system but uses your same system hardware and internet. You Just have to fill mandatory vars and 2-3 line commands to Run Userge on Docker.

Legacy-Method - Using Python and all those packages which are required to Run this bot. You can also say a Manual way to deploy a userbot.

Deploying with Docker 🐳

1. Install Docker

Follow the official Docker Installation Guide

You need to clone userge repository first by running:

git clone https://github.com/UsergeTeam/Userge.git

Note: You can add -b flag to select branch which you want to be cloned

Example branch master cloning code:

git clone -b master https://github.com/UsergeTeam/Userge.git

Go to the working directory by running:

$ cd Userge

Open & set all the necessary config.env For example the config.env is in config.env.sample

$ mv config.env.sample config.env

Then edit config.env with your favorite text editor and save it!

Build docker image by running:

$ docker build . -t userge

Run container by:

$ docker run -d --restart on-failure --name userge_1 userge

Explanation of the command flags above :

  1. -d: (detach) This will make your docker running even if you exit your console

  2. --restart on-failure: Docker container will automatically restart if there is a failure on the running system

  3. --name userge_1: Custom name for your container, instead of using the container id , this makes it easier for you to find it

To stop docker container run:

$ docker container stop userge_1

To get container logs:

$ docker logs userge_1 

Run userge with docker-compose 🐋

1. Install Docker-Compose

The easiest way to install docker-compose is:

$ sudo pip install docker-compose

OR also you can check other official methods of installing docker-compose here

2. Run Userge

We don’t need to clone the repo (yeah Docker-compose does that for us)

Setup configs (Download the sample config file)

$ mkdir userge && cd userge
wget https://raw.githubusercontent.com/UsergeTeam/Userge/alpha/config.env.sample -O config.env
vim config.env

Download the yml file for docker-compose

$ wget https://raw.githubusercontent.com/UsergeTeam/Userge/alpha/resources/docker-compose.yml

Finally, start the bot

$ docker-compose up -d

The bot should be running now. Check logs with

$ docker-compose logs -f

Q. How to Stop the Bot?

To stop the running bot in Docker use this Stop Command

$ docker-compose stop

This will just stop the containers. Built images won’t be removed. So next time you can start with this command

$ docker-compose start

It won’t take time for building from scratch.

To delete the built image of Bot. Use this Down command

$ docker-compose down

You can stop and delete the built images also. So next time you have to do this to start the bot.

$ docker-compose up -d

Q. How to Update the Bot?

$ docker-compose up -d

Changes will be fetched from git repo. You can change repo url from docker-compose.yml file.

Deploying with Legacy Method

Requirements:

1. Install required package

$ sudo apt install tree wget2 p7zip-full jq ffmpeg wget git
$ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
$ sudo apt install ./google-chrome-stable_current_amd64.deb

Notes: Recommended FFMPEG version is 4.3 or above

2. Clone the Repository

$ git clone https://github.com/UsergeTeam/Userge.git && cd Userge

3. Install Requirements

$ pip install -r requirements.txt

4. Create config.env as given config.env.sample and Fill that

$ cp config.env.sample config.env

5. Get String Session and Add it to config.env

$ bash genStr

OR you can use this @genStr_bot to get the string.

6. Finally Run the Userge

$ bash run

Config Vars / Setting Up Vars

Config vars are basically the variables which configure or modify userbot’s to function. which are the basic necessities of plugins or code to work. You have to set the proper mandatory vars to make it functional and to start the basic feature of bot.

You can leave non mandatory vars for now and can add them later.

List of Available Vars in Userge

Click on any var from the list below to get its detailed description and setup guide.

Mandatory Vars:

  1. API_ID and API_HASH

  2. DATABASE_URL

  3. LOG_CHANNEL_ID

  4. Vars Defined for your Mode

Note: These are the minimum required vars need to setup to make userbot functional.

Non-Mandatory Vars:

  1. LOAD_UNOFFICIAL_PLUGINS

  2. CUSTOM_PLUGINS_REPO

  3. ASSERT_SINGLE_INSTANCE

  4. WORKERS

  5. RSS_CHAT_ID

  6. G_DRIVE_CLIENT_ID & G_DRIVE_CLIENT_SECRET

  7. G_DRIVE_IS_TD

  8. G_DRIVE_INDEX_LINK

  9. DOWN_PATH

  10. PREFERRED_LANGUAGE

  11. CURRENCY_API

  12. OCR_SPACE_API_KEY

  13. WEATHER_DEFCITY

  14. USERGE_ANTISPAM_API

  15. SPAM_WATCH_API

  16. OPEN_WEATHER_MAP

  17. REMOVE_BG_API_KEY

  18. G_DRIVE_PARENT_ID

  19. CMD_TRIGGER

  20. SUDO_TRIGGER

  21. UPSTREAM_REPO

  22. FINISHED_PROGRESS_STR

  23. UNFINISHED_PROGRESS_STR

  24. CUSTOM_PACK_NAME

  25. ALIVE_MEDIA

  26. HEROKU_API_KEY

  27. HEROKU_APP_NAME

  28. MAX_DURATION

 UserGe has many non-mandatory vars which are used for Extra features. 

1. API_ID and API_HASH

  1. Go to my.telegram.org then Enter your Phone Number with your country code.

  2. After, you are logged in click on API Development Tools.

  3. Enter Anything as App name and App short name, Enter my.telegram.org in url section

  4. That’s it, You”ll get your API_ID and API_HASH Var.

2. DATABASE_URL

This

This

This

Tips: Select the Nearest server from your location so it won't take long time to connect

This

You have to wait for some time at this Page while your Database is being created. 

This

 Wait until the Status changes from Pending to Active 
Note: Don't use Special character in your Password like @#$% etc. 
mongodb+srv://<username>:<password>@mongos0.example.com/<dbname>?retryWrites=true&w=majority

That’s it. You have got your DATABASE_URL Var value.

3. LOG_CHANNEL_ID

Here, You need Log Channel Id to get all logs and Traceback errors of your UserBot.

For more information… Watch this Video

—- [Optional] —-

Instead of making Channel You can also create a Group to get your logs and This is the very easy way to get. Let’s Do it

Note: Changing Group Type to Public may give you an issue in Userbot. To Fix this, Put Public group id in var.

Non-Mandatory Vars

1. LOAD_UNOFFICIAL_PLUGINS

Userge has a plugin repository where extra plugins are available. A place collection of all the plugins for Userge UserBot made by awesome people who are not in Userge dev team. We saying this as Unofficial Plugins.

LOAD_UNOFFICIAL_PLUGINS = True

To load these all Plugins you have to set the var value "True" while deploying userbot. Alphabets case must be or lower case.

2. CUSTOM_PLUGINS_REPO

Fork this Repo. Now just the add your’s desired Custom plugins you want to install while starting the userge. Copy your repo link and use it as value of above var. This way you haven’t need to fork and edit unofficial plugins repo anymore.

3. ASSERT_SINGLE_INSTANCE

This will assert that there is only one running Userge instance to prevent from AUTH_KEY_DUPLICATED error.

4. WORKERS

Set the number of workers count you want, Defaults are currently depends on CPU Cores, Basically, It’s the number of CPU Core.

5. RSS_CHAT_ID

Telegram chat id for post updates of rss feeds if you have added feed urls.

6. G_DRIVE_CLIENT_ID & G_DRIVE_CLIENT_SECRET

This Vars is used for Google Drive Feature. If you want to download or upload your files and document into Google Drive. You must set this var value.

So, Let’s Start

gdrive client id and secret var

gdrive project name

create credential

oAuth consent screen

gdrive oauth

publish your app

crendentials

oauth client id

Select Desktop App

id created

7. G_DRIVE_IS_TD

If you are using Team Drive (TD) then set this value as True. Otherwise leave as it is default. To know more about TD, You can find it on Web.

If you have created Google Drive Index, You can use it as well to output the Index Link after Uploading the file to Google Drive. Just fill your url into the value.

eg. https://example.example.workers.dev

9. DOWN_PATH

You can rename the directory of your downloads folder. by default all your files will be downloaded in “downloads” folder.

10. PREFERRED_LANGUAGE

Select your Preferred language. For example: If English value will be

en

11. CURRENCY_API

This var is used for Currency converter & Exchange Rate in Plugin. If you don’t want this you can leave this var value blank.

Free api

currency api key

That’s It… Check your Email, You have received the API Key there. Confirm your Email Address and Fill the API Key in Value.

12. OCR_SPACE_API_KEY

OCR is used to read text from the images. You can also use OCR to read text from the image on Telegram from your Userbot. It helps you to copy texts from Images.

So, Let’s start getting the value of this var

ocr api

13. WEATHER_DEFCITY

To know Weather detail of your City, State. This value is required with OPEN_WEATHER_MAP var to work, you can also skip it as it is not mandatory.

Add Default city value for weather details,

eg. Delhi, India

14. USERGE_ANTISPAM_API

Get it from @UsergeAntiSpamBot in Telegram.

15. SPAM_WATCH_API

Basically, It has a list of Spammer and they are listed in SpamWatch. If you use this var, It bans the SpamWatch banned users in the groups wherever you are at Admin or Owner post.

16. OPEN_WEATHER_MAP

As, If you are going to use this userbot also for checking Weather detail on your current City, State. Then, this var value is required to be filled with WEATHER_DEFCITY var to work.

api weather

weather api key

api key of weather

open weather api key

17. REMOVE_BG_API_KEY

This API is used for the Removing the Background from Images (removebg module).

So, Let’s start getting the value of this var

remove bg

remove backgroup api

That’s it… You have got your API Key.

18. G_DRIVE_PARENT_ID

You need to enter the Folder Id of Google Drive. If you want to use Google Drive module to Upload or Download files from your Userge userbot.

For detailed Guide for getting this value can be found here.

19. CMD_TRIGGER

Command Trigger needed to trigger your userbot to execute your command. This can be only set as one Symbol (Special Character)

eg. !

20. SUDO_TRIGGER

SUDO Trigger also needed to trigger your userbot to execute command whoever you gave sudo permission to use your userbot or trigger your bot mode. This also can be only set as one Symbol (Special Character) but must be different from CMD_TRIGGER Var value.

eg. $

21. UPSTREAM_REPO

To use your Userge Userbot as default with all regular Updates and Patches also without customizing or modifying as your own choice this must be filled with Userge Main Repository URL in value.

https://github.com/UsergeTeam/Userge

For Customized or Modified Repository

If you plan to use this userbot with your own customized or modified code. You must fill your own Forked Userge Repository URL in UPSTREAM_REPO Var value.

22. FINISHED_PROGRESS_STR

To change the Progress Bar of Download and Uploads. You must fill Single text of filled bar line of character which can be shown in Finish bar.

You can Select any character from these listed sites:

23. UNFINISHED_PROGRESS_STR

To change the Progress Bar of Download and Uploads. You must fill Single text of Unfinished bar line of character which can be shown in Unfinished bar.

You can Select any character from these listed sites:

24. CUSTOM_PACK_NAME

While you use .kang command it will use your @username as Sticker Pack Name. You can set Custom Stick PAck name by filling this var value.

25. ALIVE_MEDIA

You can set your own custom media for .alive command.

Only these formats can be accepted for this Var value.

  1. A link to message (Only Message link)

    https://t.me/theuserge/8
    
  2. Chat and Message id separated by |
    -1001454692938|8
    
  3. A telegraph link
    https://telegra.ph/file/e912739114b56059a8cf3.jpg
    

26. HEROKU_API_KEY

To work some Heroku compatible modules this var value required to Access your account to use .die, .usage and .sleep commands.

You can get this value from:

Heroku Account

27. HEROKU_APP_NAME

You have to Enter the app name which you gave to identify your userbot in Heroku.

28. MAX_DURATION

Custome max audio(music) duration for voice call plugin. set MAX_DURATION in variables with your own time(seconds), Default to 900 seconds.

UserGe Modes

A mode defines the client, whether you want to use Userge on user account or as an Assistant bot.

This both also can be possible, Userge as a userbot and as an Assistant bot. You need to fill all vars for User Mode and Bot Mode. check Dual Mode

1. USER MODE

UserGe as a userbot with a user account requires this var.

HU_STRING_SESSION

You can get this Var value using two ways.

The First Way:

The Second Way:

For more details, check this video: on 11:04 then 19:40 to 23:00

2. BOT MODE

UserGe as an Assistant bot to execute your commands only from the Bot.

BOT_TOKEN & OWNER_ID

Make Sure, you set up these settings while making bot via Bot Father.

  1. Group privacy - Turn this OFF
  2. Allow groups - Turn this ON
  3. Inline mode - Turn this ON
  4. Add bot To your Log Channel

3. DUAL MODE

Use UserGe with both Userbot and Assistant bot.