Sign inSign up

coolfool/ravager

By coolfool

Updated about 4 years ago

A telegram bot that downloads content and mirrors them 1:1 to google drive

Image
0

10K+

coolfool/ravager repository overview

ravager logo
A telegram bot that sails the high seas and brings treasures from the land unknown

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

  • 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

Environment Variables

To run this project, you will need to set the following environment variables (Click to expand) :

>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
        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
      8. Again On the left side menu,select Credentials and then select Create credentials, then OAuth client ID
      9. 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
      10. Click Create.
      11. Download your client_secret.json from the popup modal or from under OAuth 2.0 Client IDs
    >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

>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

Docker

1) Download [docker-compose.yml](https://github.com/CoolFool/Ravager/blob/main/docker-compose.yml) for running on a server or [docker-compose-local.yml](https://github.com/CoolFool/Ravager/blob/main/docker-compose-local.yml) for running locally with ngrok or other tunneling service for Oauth authentication <br>
2) Open the file in a text editor and fill the environment variables <br>
3) - If `docker-compose-local.yml` is used you have to create a docker network called `ravager_net` <br>
   - 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 https <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. 
4) Execute the following command in the same directory
    ```
    docker-compose up -d
    ```
5) The bot should be up and running <br>
6) For checking the logs you can use `docker logs -f ravager` <br>

(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

Authors

(back to top)

License

MIT

(back to top)

Tag summary

Content type

Image

Digest

Size

87.5 MB

Last updated

about 4 years ago

docker pull coolfool/ravager