This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This is an extensively detailed guide to deploying the bot, lets get started 🐱💻
For deploying on Heroku, you have two way:
-
Deploy via your PC (assuming you have Windows/Linux)
-
Deploy via Goorm IDE (a free online CLI/terminal).
For deploying on VPS, proprietary steps, if any, are shown. Most of the steps are common.
0. Prerequisites
• PC/VPS
1. Python (don't forget to add it to PATH)
2. Git (download here, install with default options)
3. Heroku CLI (for WSL, use this method) and Heroku account
4. WSL (if you have Windows)
• Goorm IDE (easy way)
1. Goorm account (here)
2. Heroku account (here)
1. Getting things ready
a) On PC
-
Navigate to the folder in which you would like to clone the repo. Right click and choose 'Git Bash Here'. Now run the command
git clone https://github.com/anasty17/mirror-leech-telegram-bot mirrorbot && cd mirrorbot
Use your own fork/clone link if you want to make changes or want to use
UPSTREAM_REPO
var
b) On Goorm IDE
-
Go to ide.goorm.io and make a new account if you don't have one
-
Then go to dashboard, press 'New Container'
-
Use any name, any server region, make it private, and select 'Python' stack, and create (Ignore other configs)
-
Wait until it's done, then run the container
-
A new tab will be opened, click here to open terminal
-
Now, to clone the repo to the container, run this command
git clone https://github.com/anasty17/mirror-leech-telegram-bot
c) For VPS
-
Clone this repo:
git clone https://github.com/anasty17/mirror-leech-telegram-bot mirrorbot/ && cd mirrorbot
-
For Debian based distros
sudo apt install python3
Install Docker by following the official Docker docs or by commands below.
sudo apt install snapd sudo snap install docker
-
For Arch and it's derivatives:
sudo pacman -S docker python
-
Install dependencies for running setup scripts:
pip3 install -r requirements-cli.txt
2. Getting credentials.json
-
Firstly, goto Google Cloud Console using the right Google account
-
Then select 'Create Project' and name it whatever you want and create.
-
On the left menu, go to the 'OAuth consent screen', Press 'External', and create
-
Fill app name whatever you want
-
Fill your gmail in 'User support email' and 'Developer contact information', and ignore other fields, then press 'Save and Continue'
-
Press 'Save and Continue' again to skip the scopes step
-
Press 'Add Users' and add your gmail as tester, press 'Save and Continue'
-
Press 'Back to Dashboard'
-
Now on the left menu go to 'Credentials' tab, then 'Create Credentials', then 'OAuth client ID'
-
In application type, select 'Desktop app' and name it whatever you want and create
-
This will appear, download it and rename it as 'credentials.json'
Pro Tip:
The URL of this page will have something like
project=cool-arch-335412
. Here,cool-arch-335412
is the Project ID, if you ever need it.
3. Setting up Config File
-
Rename
config_sample.env
toconfig.env
-
Remove first two lines saying
# Remove this line before deploying _____REMOVE_THIS_LINE_____=True
-
Fill up rest of the fields. Meaning of each field is discussed below:
1. Required Fields
Click here for more details
Variable Description BOT_TOKEN
The Telegram bot token that you get from @BotFather. GDRIVE_FOLDER_ID
This is the Folder/TeamDrive ID of the Google Drive Folder to which you want to upload all the mirrored items. OWNER_ID
The Telegram User ID (not username) of the Owner of the bot. DOWNLOAD_DIR
The path to the local folder where the downloads should be kept. DOWNLOAD_STATUS_UPDATE_INTERVAL
A short interval of time in seconds after which the Mirror progress/status message is updated. (Recommended to keep it 10
seconds at least)AUTO_DELETE_MESSAGE_DURATION
Interval of time (in seconds), after which the bot deletes it's message and command message which is expected to be viewed instantly.
(NOTE: Set to-1
to disable auto message deletion)IS_TEAM_DRIVE
>
(bool)If you entered TD ID or folder ID of folder which belongs to a TD, in GDRIVE_FOLDER_ID
, thenTrue
, elseFalse
.TELEGRAM_API
This is to authenticate your Telegram account for downloading Telegram files. You can get this here.
(NOTE: DO NOT put this in quotes)TELEGRAM_HASH
This is to authenticate your Telegram account for downloading Telegram files. You can get this here. 2. Optional Fields
Click here for more details
Variable Description DATABASE_URL
Your Database URL. Follow this Generate Database to generate database. Data saved in Database: auth and sudo users, leech settings including thumbnails for each user and rss data.
(NOTE: If deploying on heroku and using heroku postgresql delete this variable from config.env file.DATABASE_URL
will be grabbed from heroku variables.)AUTHORIZED_CHATS
Fill user_id (not username) and chat_id of groups/users you want to authorize. Separate them by space. SUDO_USERS
Fill user_id (not username) of users whom you want to give sudo permission. Separate them by space. IGNORE_PENDING_REQUESTS
(bool)If you want the bot to ignore pending requests after it restarts, set this to True
.USE_SERVICE_ACCOUNTS
(bool)Whether to use Service Accounts or not. For this to work see Using Service Accounts section below. INDEX_URL
Refer Here. STATUS_LIMIT
Limit the no. of tasks shown in status message with buttons.
(NOTE: Recommended limit is4
tasks.)STOP_DUPLICATE
(bool)If this field is set to True
, bot will check file in Drive, if it is present in Drive, mirroring/cloning will be stopped.
(NOTE: File will be checked using filename not file hash, so this feature is not perfect yet)UPTOBOX_TOKEN
Uptobox token to mirror uptobox links. Get it from Uptobox Premium Account. UPSTREAM_REPO
Your github repository link, if your repo is private add https://username:{githubtoken}@github.com/{username}/{reponame}
format. Get token from Github settings. So you can update your appllication from filled repository on each restart.
(NOTE: Any change in docker or requirements you need to deploy/build again with updated repo to take effect. DON'T delete .gitignore file.)TG_SPLIT_SIZE
Split size of leeched files (in bytes), leave it empty for max size of 2GB
.AS_DOCUMENT
(bool)Default Telegram file type upload. Empty or False
means as media.EQUAL_SPLITS
(bool)Split files larger than TG_SPLIT_SIZE
into equal parts size (Not working with zip cmd).CUSTOM_FILENAME
Add custom word to leeched file's name. BASE_URL_OF_BOT
Valid BASE URL where the bot is deployed (to use qbittorrent web selection). Format of URL should be http://myip
, wheremyip
is the IP/Domain (public) of your bot or if you have chosen port other than80
so write it in this formathttp://myip:port
(http
and nothttps
).
This var is optional on VPS and required for Heroku specially to avoid app sleeping/idling. For Heroku, fillhttps://yourappname.herokuapp.com
. Still got idling? You can use Cron Job to ping your Heroku app.
(NOTE: Don't add slash at the end)IS_VPS
(bool)(Only for VPS) Don't set this to True
even if you are using VPS, unless facing error with web server.SERVER_PORT
Only For VPS even if IS_VPS
isFalse
, which is theBASE_URL_OF_BOT
Port.WEB_PINCODE
(bool)If empty or False
means no pincode required while qbit web selection.QB_SEED
(bool)If True
QB torrent will be seeded after and while uploading until reaching specific ratio or time, editMaxRatio
and/orGlobalMaxSeedingMinutes
from qbittorrent.conf (`-1` means no limit, but you can cancel manually by gid).
(NOTE: Don't changeMaxRatioAction
. This only works with/qbmirror
and/qbzipmirror
.)
(Qbittorrent Note: To auto cancel dead torrents after specific time, edit these two numbers (999999) in seconds. 1st for metadata download timeout and 2nd for stalled download timeout.)RSS_DELAY
Time in seconds for RSS refresh interval. Recommended 900
seconds at least. Empty means 900s (default time).RSS_COMMAND
Choose command for incoming links from RSS. RSS_CHAT_ID
Chat ID where bot will send the RSS links. USER_STRING_SESSION
To send RSS links from your telegram account instead of adding bot to channel then linking channel to group to get RSS link, since bot will not read command from itself or other bot. To generate string session use this command python3 generate_string_session.py
after mounting repo folder.Note for RSS DATABASE_URL
andRSS_CHAT_ID
is required, otherwise all RSS commands will not work.ACCOUNTS_ZIP_URL
Only if you want to load your Service Account externally from an Index Link or by any direct download link NOT webpage link. Archive the accounts folder to ZIP file. Fill this with the direct download link of zip file. If index need authentication so add direct download as shown below:
https://username:password@example.workers.dev/...
TOKEN_PICKLE_URL
Only if you want to load your token.pickle externally from an Index Link. Fill this with the direct link of that file. MULTI_SEARCH_URL
Check drive_folder
setup here. Writedrive_folder
file here. Open the raw file of that gist, it's URL will be your required value. Should be in this form after removing commit id:
https://gist.githubusercontent.com/username/gist-id/raw/drive_folder
YT_COOKIES_URL
YouTube authentication cookies. Check setup here. Use gist raw link and remove commit id from the link, so you can edit it from gists only. NETRC_URL
.netrc file contains authentication for aria2c and yt-dlp. Use gist raw link and remove commit id from the link, so you can edit it from gists only.
(NOTE: After editing .nterc you need to restart the docker or if deployed on heroku so restart dyno in case your edits related to aria2c authentication)Note for ACCOUNTS_ZIP_URL
,TOKEN_PICKLE_URL
,MULTI_SEARCH_URL
,YT_COOKIES_URL
,NETRC_URL
All these url variables used incase you want edit them in future easily without deploying again or if you want to deploy from public fork. If deploying using cli or private fork you can leave these variables empty add token.pickle, accounts folder, drive_folder, .netrc and cookies.txt directly to root but you can't update them without rebuild OR simply leave all above variables and use private UPSTREAM_REPO
.MEGA_API_KEY
Mega.nz API key to mirror mega.nz links. Get it from Mega SDK page. MEGA_EMAIL_ID
E-Mail ID used premium mega.nz account
(NOTE: You can use free account too, but download will be limited to 5GB per 6hrs.)MEGA_PASSWORD
Password for that mega.nz account. BLOCK_MEGA_FOLDER
(bool)If you want to remove mega.nz folder support, set it to True
.BLOCK_MEGA_LINKS
(bool)If you want to remove all mega.nz links support, set it to True
.SHORTENER
Pick any one which you want to use.
Supported URL Shorteners:
exe.io, gplinks.in, shrinkme.io, urlshortx.com, shortzon.com, bit.ly, shorte.st, linkvertise.com , ouo.ioSHORTENER_API
Fill that Shortener's API key. PHPSESSID
andCRYPT
Cookies for gdtot google drive link generator. Follow these steps. TORRENT_DIRECT_LIMIT
To limit the Torrent/Direct download mirror size. Don't add unit, the default unit is GB. ZIP_UNZIP_LIMIT
To limit the size of zip and unzip commands. Don't add unit, the default unit is GB. CLONE_LIMIT
To limit the size of Google Drive folder/file which you can clone. Don't add unit, the default unit is GB. MEGA_LIMIT
To limit the size of Mega download. Don't add unit, the default unit is GB. VIEW_LINK
(bool)View Link button to open file Index Link in browser instead of direct download link. You can figure out if it's compatible with your Index code or not, open any video from you Index and check if its URL ends with ?a=view
, if yes make itTrue
. Compatible with Bhadoo Index Code.BUTTON_FOUR_NAME
BUTTON_FOUR_URL
BUTTON_FIVE_NAME
BUTTON_FIVE_URL
BUTTON_SIX_NAME
BUTTON_SIX_URL
Three buttons are already added including Drive Link, Index Link, and View Link, you can add extra buttons, if you don't know what are these entries, simply leave them empty. SEARCH_API_LINK
Search API app link. Get your API from deploying this repository.
Supported Sites:
1337x, YTS, Eztv, Torrent Galaxy, Torlock, Piratebay, Nyaasi, Rarbg, Ettv, Zooqle, KickAss, Bitsearch, Glodls, MagnetDLSEARCH_PLUGINS
List of qBittorrent search plugins (github raw links). I have added some plugins, you can remove/add plugins as you want.
Main Source: qBittorrent Search Plugins (Official/Unofficial).
4.1 - Running Helper Script (for Heroku)
-
Then we have to make the helper script executable. So run this command in the Terminal
chmod +x helper.sh
-
Now you can execute the helper script by running this command, and it will guide you further
bash helper.sh
If you get error like this 👇,
then run this and try again:
sed -i 's/\r//' helper.sh
If you get error like this 👇,
then you are probably using WSL, so remove heroku bin folder from PATH in environment variables and then run this in your linux shell, and try again:
curl https://cli-assets.heroku.com/install.sh | sh
4.2 - Deploying on VPS
IMPORTANT NOTES:
You must set
SERVER_PORT
variable to80
or any other port you want to use.To clear the container (this will not affect on the image):
sudo docker container prune
To delete the images:
sudo docker image prune -a
Check the number of processing units of your machine with
nproc
cmd and times it by 4, then editAsyncIOThreadsCount
in qBittorrent.conf.Use
anasty17/mltb-oracle:latest
for oracle or if u faced problem with arm64 docker run.• Tutorial Video for Deploying on Oracle VPS:
Thanks to Wiszky
No need to use sudo su, you can also use sudo before each cmd
• Deploying on VPS Using Docker
-
Start Docker daemon (skip if already running):
sudo dockerd
-
Note: If not started or not starting, run the command below then try to start.
sudo apt install docker.io
-
Build Docker image:
sudo docker build . -t mirror-bot
-
Run the image:
sudo docker run -p 80:80 mirror-bot
-
To stop the image:
sudo docker ps
sudo docker stop id
• Deploying on VPS Using docker-compose
NOTE: If you want to use port other than 80, change it in docker-compose.yml also.
sudo apt install docker-compose
-
Build and run Docker image:
sudo docker-compose up
-
After editing files with nano for example (nano start.sh):
sudo docker-compose up --build
-
To stop the image:
sudo docker-compose stop
-
To run the image:
sudo docker-compose start
-
Tutorial video from Tortoolkit repo for docker-compose and checking ports