Create your own bot
In telegram find Botfather and create your own bot. When you have done, save your bot token.
Deploy aria telegram mirror bot
Connect to your sever with any SSH client you want.
sudo apt install aria2
# Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
# Close and reopen your terminal to start using nvm or run the following to use it now:
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# Install node.js and npm
nvm install --lts
npm install -g typescript
# Clone the repo
git clone https://github.com/out386/aria-telegram-mirror-bot
# Copy the example files
cp src/.constants.js.example src/.constants.js
cp aria.sh.example aria.sh
# Configure the startup script
# ARIA_RPC_SECRET is the secret (password) used to connect to aria2. Set this to whatever you want, and save the file with ctrl + x.
# MAX_CONCURRENT_DOWNLOADS is the number of download jobs that can be active at the same time. Note that this does not affect the number of concurrent uploads. There is currently no limit for the number of concurrent uploads.
# You can see the following section for detailed constants.js configuration
# Compile the project
if you encounter the following problem:
Try to increase the memory allocated to Node to temporarily bypass this. Values of max-old-space-size can be: [1024, 2048, 4096, 8192, 16384] etc
- TOKEN: This is the Telegram bot token that you will get from Botfather in step 1 of Pre-installation.
- ARIA_SECRET: This is the password used to connect to the aria2 RPC. You will get this from step 4 of Installation.
- ARIA_DOWNLOAD_LOCATION: This is the directory that aria2 will download files into, before uploading them. Make sure that there is no trailing "/" in this path. The suggested path is /path/to/aria-telegram-mirror-bot/downloads
- ARIA_DOWNLOAD_LOCATION_ROOT: This is the mountpoint that contains ARIA_DOWNLOAD_LOCATION. This is used internally to calculate the space available before downloading.
- ARIA_FILTERED_DOMAINS: The bot will refuse to download files from these domains. Can be an empty list.
- ARIA_FILTERED_FILENAMES: The bot will refuse to completely download (or if already downloaded, then upload) files with any of these substrings in the file/top level directory name. Can be an empty list or left undefined.
- ARIA_PORT: The port for the Aria2c RPC server. If you change this, make sure to update your aria.sh as well. Safe to leave this at the default value unless something else on your system is using that port.
- GDRIVE_PARENT_DIR_ID: This is the ID of the Google Drive folder that files will be uploaded into. You will get this from step 4 of Pre-installation.
- SUDO_USERS: This is a list of Telegram user IDs. These users can use the bot in any chat. Can be an empty list, if AUTHORIZED_CHATS is not empty.
- AUTHORIZED_CHATS: This is a list of Telegram Chat IDs. Anyone in these chats can use the bot in that particular chat. Anyone not in one of these chats and not in SUDO_USERS cannot use the bot. Someone in one of the chats in this list can use the bot only in that chat, not elsewhere. Can be an empty list, if SUDO_USERS is not empty.
- STATUS_UPDATE_INTERVAL_MS: Set the time in milliseconds between status updates. A smaller number will update status messages faster, but Telegram will rate limit the bot if it sends/edits more than around 20 messages/minute/chat. As that quota includes messages other than status updates, do not decrease this number if you get rate limit messages in the logs.
DRIVE_FILE_PRIVATE: Files uploaded can either be visible to everyone (public), or be private.
- ENABLED: Set this to true to make the uploaded files private. false makes uploaded files public.
- EMAILS: An array of email addresses that read access will be granted to. Set this to  to grant access only to the Drive user the bot is set up with.
DOWNLOAD_NOTIFY_TARGET: The fields here are used to notify an external web server once a download is complete. See the section on notifications below for details.
- enabled: Set this to true to enable this feature.
- host: The address of the web server to notify.
- port: The server port ¯\_(ツ)_/¯
- path: The server path ¯\_(ツ)_/¯
COMMANDS_USE_BOT_NAME: The fields here decide whether to append the bot's usename to the end of commands or not. This works only for group chats, and gets ignored if you PM the bot.
- ENABLED: If true, all bot commands have to have the bot's username (as below) appended to them. For example, /mirror https://someweb.site/resource.tar will become /mirror@botName_bot https://someweb.site/resource.tar. The only exception to this is the /list command, which will not have the bot's name appended. This allows having multiple non-conflicting mirror bots in the same group, and have them all reply to /list.
- NAME: The username of the bot, as given in BotFather. Include the leading "@".
- IS_TEAM_DRIVE: Set to true if you are mirroring to a Shared Drive.
Set up OAuth:
- Visit the Google 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 that file to the root of aria-telegram-mirror-bot, and rename it to
Enable the Drive API
- Visit the Google API Library page.
- Search for Drive.
- Make sure that it's enabled. Enable it if not.
Start the program
Authorize the bot
Open the telegram and send the following message to your bot
Now back to your terminal and visit the website it's shown and login with your Google account and copy the authorization code to the terminal and press ENTER.
Running the program in background mode
apt install tmux
tmux new -s tgbot