Skip to content

Latest commit

 

History

History
231 lines (205 loc) · 12.3 KB

README.md

File metadata and controls

231 lines (205 loc) · 12.3 KB
ravager logo

A telegram bot that downloads content in the form of torrent and direct download links and mirrors them 1:1 to google drive

Contents

Introduction

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.

Features

  • 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

Environment Variables

To run this project, you will need to set the following environment variables :

Core Environment Variables
    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

      To create a Google Cloud project:

      1. Open the Google Cloud Console.
      2. At the top-left, click Menu > IAM & Admin > Create a Project.
      3. 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
      4. Click Create. The console navigates to the Dashboard page and your project is created within a few minutes.

      Configure the Project:

      1. Open the Google Cloud Console Dashboard and select your project
      2. At the top-left, click Menu > APIs & Services
      3. On the left side menu,Select Library/
      4. Search for Google Drive in the search bar the API library and Select and Enable Google Drive API
      5. Again at the top-left, click Menu > APIs & Services
      6. On the left side menu,Select Credentials, select Create credentials, then OAuth client ID.
      7. 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
      8. OAuth consent screen Configuration:

        1. Select user type as external
        2. Fill the required details
        3. In the scopes page,Click on Add or Remove Scopes
        4. Search and Add /auth/drive and /auth/drive.metadata scopes and click on update
        5. You should see the scopes added in Your Sensitive Scopes Section
        6. Click on Save and Continue for rest of the sections
        7. On the OAuth consent screen Click on Publish App and Confirm
        8. 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
      9. Again On the left side menu,select Credentials and then select Create credentials, then OAuth client ID
      10. Select Web Application for the Application Type. Follow the instructions to enter JavaScript origins, redirect URIs, or both.
        1. In Javascript Origins add your domain name which should be APP_URL
        2. In Authorized redirect URIs Add your redirect uri which should be APP_URL/oauth_handler
      11. Click Create.
      12. Download your client_secret.json from the popup modal or from under OAuth 2.0 Client IDs
      13. Open client_secret.json and copy the whole config as 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

(back to top)

Installation

  • Ravager can be deployed and used in the following ways

Heroku

  • Click Deploy 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

(back to top)

Docker

  • Docker Compose

    1. 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
    2. 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 called ravager_net
      • Forward the connection for ravager_net with port 8443 using ngrok or some other tunneling service.
      • Get the ip for ravager_net using the command docker 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.
    3. Execute the following command in the same directory
      docker-compose up -d
      
    4. The bot should be up and running
    5. For checking the logs you can use docker logs -f ravager

(back to top)

Telegram Bot Commands

  • /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

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Authors

(back to top)

License

MIT

(back to top)