Package: tgchizu
Description:A Telegram Bot written in Python language to mirror files on the internet to Google DriveCredits:This repository is a fork-clone of the following repositories.ksssomesh's tg-mirror-botlzzy12's python-aria-mirror-botafdulfauzan's python-aria-mirror-botmagneto261290's magneto-python-ariabreakdowns's slam-mirrorbotAll credits goes to the maintainers of the above repositories.Few useful additional features have been implemented on top of them.This repository utilises trackers for torrent/magnet downloads fromTrackerslist Website.Supported Features:From Source ReposMirror TorrentsMirror Direct LinksMirror Telegram FilesUpload Files after Archiving/UnarchivingDownload and Upload Progress, Speeds and ETAsDocker SupportUploading To Team DrivesIndex Link SupportShortener SupportService Account SupportMirror 'youtube-dl' Supported LinksAdditional FeaturesDynamic Config Support, to facilitate easier and streamlined experience for editing config files.Sync Config Files at every /restart command.Edit values of environment variables in 'config.env' from within the bot using InlineKeyboardButtons.'aria2c' daemon starts as a subprocess from within the 'bot' python module, facilitating better handling of processes. This also results in both 'aria2c' daemon and the 'bot' python module restarting with every '/restart' command.Support for using custom tracker list formatted as a text file, as required by 'aria2c' daemon.Supported Archive File TypesZIP RAR TAR 7Z ISO WIM CAB GZIP BZIP2 APM ARJ CHM CPIO CramFS DEB DMG FAT HFS LZH LZMA LZMA2 MBR MSI MSLZ NSIS NTFS RPM SquashFS UDF VHD XAR ZDevelopment Status:To-DosAdd option to select files for torrent/magnet downloads.NOTE:All the above to-dos are aimed at achieving zero human-intervention after initial deploy to Heroku.Info of Branchesmaster: most stable environment for production deploys.staging: testing new features, fixes or better implementations of already existing ones.dev: major feature updates that are under development - currently, added support for 'mega-dl'.Deploying:PrerequisitesInstall Python3.sudo apt install python3Cloning and Setting Up Config FileDownload and Extract theLatest Release Package:mkdir ~/Downloads/deploy_heroku
mv ~/Downloads/deploy_release_v* ~/Downloads/deploy_heroku
cd ~/Downloads/deploy_heroku
tar xzvf deploy_release_v*
rm -v deploy_release_v*Copy and Edit the Config file:cp config_sample.env config.env
nano config.envRemove the first line saying:_____REMOVE_THIS_LINE_____=TrueFill up rest of the fields. The description of each field is given below.Required FieldsBOT_TOKEN: The telegram bot token that you get from@BotFather.GDRIVE_FOLDER_ID: This is the folder ID of the Google Drive folder to which you want to upload all the mirrors.DOWNLOAD_DIR: The path to the folder where the downloads will be downloaded locally, before uploading to Google Drive.OWNER_ID: The Telegram user ID (not username) of the owner of the bot.DOWNLOAD_STATUS_UPDATE_INTERVAL: A short interval of time in seconds after which the Mirror progress message is updated (5 seconds at least).AUTO_DELETE_MESSAGE_DURATION: Interval of time (in seconds), after which the bot deletes its message (and command message) which is expected to be viewed instantly (set to '-1' to never automatically delete messages).TELEGRAM_API: This is to authenticate to your telegram account for downloading Telegram files. You can get this fromhere.TELEGRAM_HASH: This is to authenticate to your telegram account for downloading Telegram files. You can get this fromhere.MAX_DOWNLOAD_SPEED: Set the maximum download speed. By default, it is set to '0' (unlimited).MAX_CONCURRENT_DOWNLOADS: Set the maximum concurrent downloads. By default, it is set to '3'.TRACKERSLIST: Set the URL of the trackerslist text file. By default, it is set to 'https://trackerslist.com/all_aria2.txt'.USE_TELEGRAPH: Set to "true" to use Telegra.ph for search results from '/list' bot command, or else set to "false".NOTE:The trackerslist text file must contain tracker URLs in a single line, separated by commas, as required by 'aria2c'.Optional Fields (leave empty if unsure)IS_TEAM_DRIVE: Set to "true" if GDRIVE_FOLDER_ID is from a Team Drive, or else set to "false" or leave it empty.USE_SERVICE_ACCOUNTS: Whether to use service accounts or not. For this to work see  "Using service accounts" section below.STOP_DUPLICATE_MIRROR: Set this to "true", if you want to check for duplicate files (using file name, and not file hash) in Google Drive matching the requested download and stop the download if found any.INDEX_URL: Refer toGDIndex repo. The URL should not have any trailing '/'.SHORTENER: URL of the Shortener.SHORTENER_API: API Key of the Shortener.Supported Shorteners:

  > exe.io
  > gplinks.io
  > shrinkme.io
  > urlshortx.com
  > shortzon.com

  Additionally, some other shorteners are also supported unofficially.Getting Google OAuth API Credential FileVisit theGoogle Cloud Console.Go to the OAuth Consent tab, fill it, and save.Go to the Credentials tab and click Create Credentials -> OAuth Client ID.Choose Other and Create.Use the download button to download your credentials.Move the downloaded file to the 'deploy_heroku' folder, and rename it to 'credentials.json'.VisitGoogle API Library.Search for Drive and enable it if it is disabled.SetupInstall Requirements:pip3 install -r requirements.txtUse 'pipenv' for better compatibility (optional):pipenv install -r requirements.txt
pipenv shellRun 'setup.py', and authorize the AppFlow to generate 'token.pickle':python3 setup.pyEnter the appropriate choice in the input prompt, to use static/dynamic config.In case of static config, the setup is complete here.In case of dynamic config, continue to the next section.Dynamic Config (optional)If you are running this setup script for the first time, enter the appropriate choice in the input prompt and continue to the next step.Create a new folder in your personal Google Drive, irrespective of the folder you use for uploading files with this bot (no constraints at all).Change the permissions of this newly created folder to 'Anyone on the Internet with this link can view'.Enter the FolderId of the newly created folder in the input prompt, and continue with the setup.For 'DL_WAIT_TIME' reference, see below:DL_WAIT_TIME: Time to wait for aria2c to download the config files. By default it's set to '5' seconds, which is more than enough for deploying the bot to Heroku. If 'DL_WAIT_TIME' lapses, and the config files are not downloaded due to any reason, the bot exits with exit code (1).The config files will be uploaded to Google Drive, and then deleted, except for 'dynamic.env'.The setup script will exit with 'Setup Completed' message.Now, the docker image can be deployed with 'dynamic.env' file.NOTE:If you have already run this setup script and want to update the existing config files in drive, enter the appropriate choice in the input prompt. In the next step, enter the FileId of the existing 'dynamic.env' in the input prompt, and the updated files will be uploaded to Google Drive. Now, you can choose to keep the old config files or delete them.Deploy to Heroku:Creating a Heroku AppCreate afree Heroku Account.Install Heroku CLI:sudo snap install --classic herokuLogin into your Heroku Account:heroku loginVisitHeroku Dashboardand create a new app with any name (for our reference, your-mirror-bot) and with any region you prefer, for your app to be served from.In the Deploy tab of your app dashboard, select  'Heroku Git' in Deployment Method.Change the Stack for the App using Heroku CLI:heroku stack:set container --app your-mirror-botInitialise the project files as a Git Repository, push the Repo to 'Heroku Git' and build the Docker Image:cd ~/Downloads/deploy_heroku
git init
git add .
git commit -m "initial commit"
heroku git:remote --app your-mirror-bot
git push heroku masterIf the Docker Image Build succeeds, then, your push to the remote repository will succeed, otherwise, your push to the remote repository is rejected as the Docker Image Build fails.Run/Terminate the AppYou can run/terminate the app by allocating/deallocating dynos to the app.Using DashboardIn the app dashboard, under resources tab, use the 'Edit Dyno Formation' button in Dynos section to change the working state of the app.Using CLITo Run:heroku ps:scale worker=1 --app your-mirror-botTo Terminate:heroku ps:scale worker=0 --app your-mirror-botTo Check Status:heroku ps --app your-mirror-botTo Tail App Logs:heroku logs --tail --app your-mirror-botBot Commands:start- Start the botmirror- Mirror the provided link to Google Driveunzipmirror- Mirror the provided link and if the file is in archive format, it is extracted and then uploaded to Google Drivetarmirror- Mirror the provided link and upload in archive format (.tar) to Google Drivecancel- Reply with this command to the source message, and the download will be cancelledcancelall- Cancels all running tasks (downloads, uploads, archiving, unarchiving)list- Searches the Google Drive folder for any matches with the search term and presents the search results in a Telegraph pagestatus- Shows the status of all downloads and uploads in progressauthorize- Authorize a group chat or, a specific user to use the botunauthorize- Unauthorize a group chat or, a specific user to use the botping- Ping the botrestart- Restart the botstats- Shows the stats of the machine that the bot is hosted onhelp- To get the help messagelog- Sends the log file of the bot and the log file of 'aria2c' daemon (can be used to analyse crash reports, if any)clone- Clone folders in Google Drive (owned by someone else) to your Google Drivewatch- Mirror through 'youtube-dl' to Google Drivetarwatch- Mirror through 'youtube-dl' and upload in archive format (.tar) to Google Drivedelete- Delete files in Google Drive matching the given stringconfig- Edit 'config.env' fileNOTE:The above listed command descriptions can be copied and pasted in 'edit bot commands' section, when editing the bot settings with@BotFather.