This is a telegram bot which supports torrent file,magnet uri as well as direct download links,it uses aria2 as a backend for downloading the content and uploads it to google drive. It can be deployed to heroku free dyno or on a server.
- Easy-to-use heroku one click deploy
- Support for multiple telegram chats (group and private) and Google accounts with built-in oauth support
- Preserves the directory structure of uploaded content and doesn't require any archiving.
- Support for Personal and Shared Drive and changing them on the fly
- Flexible in terms deploying and installing options
- Single multi-arch docker image
- Recover from failed upload
- Download once upload multiple times
- Admin interface for getting logs and other system info
- Multiple optimisations for running on heroku free dyno
To run this project, you will need to set the following environment variables :
Core Environment Variables
- Open the Google Cloud Console.
- At the top-left, click Menu > IAM & Admin > Create a Project.
- In the Project Name field, enter a descriptive name for your project.
Optional: To edit the Project ID, click Edit. The project ID can't be changed after the project is created, so choose an ID that meets your needs for the lifetime of the project.
In the Location field, click Browse to display potential locations for your project. Then, click Select - Click Create. The console navigates to the Dashboard page and your project is created within a few minutes.
- Open the Google Cloud Console Dashboard and select your project
- At the top-left, click Menu > APIs & Services
- On the left side menu,Select Library/
- Search for Google Drive in the search bar the API library and Select and Enable Google Drive API
- Again at the top-left, click Menu > APIs & Services
- On the left side menu,Select Credentials, select Create credentials, then OAuth client ID.
- You may be prompted to set a product name on the Consent screen; if so, click Configure consent screen, supply the requested information following the notes below, and click Save to return to the Credentials screen
- Select user type as external
- Fill the required details
- In the scopes page,Click on Add or Remove Scopes
- Search and Add /auth/drive and /auth/drive.metadata scopes and click on update
- You should see the scopes added in Your Sensitive Scopes Section
- Click on Save and Continue for rest of the sections
- On the OAuth consent screen Click on Publish App and Confirm
- Ignore Needs verification warning for the time being,the users will only see the warning while authorizing but please note there's a limit to number of users for unverified apps
- Again On the left side menu,select Credentials and then select Create credentials, then OAuth client ID
- Select Web Application for the Application Type. Follow the instructions to enter JavaScript origins, redirect URIs, or both.
- In Javascript Origins add your domain name which should be APP_URL
- In Authorized redirect URIs Add your redirect uri which should be APP_URL/oauth_handler
- Click Create.
- Download your client_secret.json from the popup modal or from under OAuth 2.0 Client IDs
- Open client_secret.json and copy the whole config as CLIENT_CONFIG
APP_URL
The url where the app will be hosted i.e for heroku it will be https://{appname}.herokuapp.com or for self-hosted server it will be https://{hostname_or_ip}:{port} where port is usally 8443
CLIENT_CONFIG
BOT_TOKEN
The bot token for telegram bot, for more info on how to create a bot and get a token visit How to create a telegram bot
STATE_SECRET_KEY
A random alphanumeric text used as a salt in generating state for oauth authorization.
Not required in heroku caused generator is used while deploying
BOT_URL
The telegram bot url,this is usually in the form https://t.me/{bot_username}
ALLOWLIST
Should there be a filter where password is required for access to the bot
Set as "True" or "False"
GROUP_PASSWORD
Password used for allowing a group chat access to the bot,should be set if "ALLOWLIST" is enabled
USER_PASSWORD
Password used for allowing a user access to the bot,should be set if "ALLOWLIST" is enabled
Environment Variables for Heroku only
KEEP_HEROKU_ALIVE
The application hosted in heroku free dyno sleeps after 20 minutes of no activity,to conteract this the application
can ping itself every 5 minutes and keep itself alive.
Should be set to either "True" or "False"
HEROKU_API_TOKEN
Heroku dynos are restarted every 24 hours + random(0-216)minutes,but if there is a restart before that the restart time is reset.
The bot can give you the approx restart time and restart itself when no activity occurs for 4 hours if it has the Platform API Token
The token can be found here
Optional Environment Variables
DATABASE_URL
The DATABASE URI for custom SQL Database
REDIS_URL
The URL for connecting to custom redis instance
LOG_LEVEL
The log level to be displayed in console,all the log levels can be found here
Only numeric value is supported
PORT
Custom port for hosting the application,but only Ports supported by telegram should be used when the application is not hosted behind a reverse proxy
- Ravager can be deployed and used in the following ways
- Click and fill the environment variables accordingly.
- If the addons section is empty in the app dashboard on heroku add the following addons:
- Heroku Postgres with plan Hobby-Dev:Free
- Heroku Redis with plan Hobby-Dev:Free
- Restart the app
-
- Download docker-compose.yml for running on a server or docker-compose-local.yml for running locally with ngrok or other tunneling service for oauth authentication
- Open the file in a text editor and fill the environment variables
-
- If
docker-compose-local.yml
is used you have to create a docker network calledravager_net
- Forward the connection for
ravager_net
with port8443
using ngrok or some other tunneling service. - Get the ip for
ravager_net
using the commanddocker inspect ravager_net
- For ngrok the command should be as follows:
./ngrok http <ravager_net_ip>:8443
- The url from ngrok will be used as telegram bot webhook and oauth endpoint
- Add the ngrok url and the oauth endpoint
ngrok_url/oauth_handler
to google's oauth api authorized domain.
- If
- Execute the following command in the same directory
docker-compose up -d
- The bot should be up and running
- For checking the logs you can use
docker logs -f ravager
/start
: Start the authorization flow for google drive access/add_drive
: Set default drive either personal or shared drive through the menu/download
: Add download task/upload
: Upload content if a download fails you can reply to the source message or upload multiple times/abort
: Abort an ongoing task/admin_interface
: Admin interface access (only available in private chat and for admins)/revoke
: Revoke and delete your Google account on the bot/help
: See all the commands
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request