linuxserver / docker-qbittorrent

GNU General Public License v3.0
1.06k stars 155 forks source link

[FEAT] Add module py3-requests #341

Closed bravo321 closed 3 weeks ago

bravo321 commented 3 weeks ago

Is this a new feature request?

Wanted change

Please add the apk add py3-requests module to the container; it is needed to launch telgram-bot, which notifies you when the download is complete.

Reason for change

import requests
import sys

def send_telegram_message(bot_token, chat_id, message):
    url = f"https://api.telegram.org/bot{bot_token}/sendMessage"
    payload = {
        "chat_id": chat_id,
        "text": message
    }
    response = requests.post(url, json=payload)
    return response.json()

# Replace Telegram Bot token and chat ID
bot_token = "my-token"
chat_id = "my-chat-id"

if __name__ == "__main__":
    if len(sys.argv) > 2:
        # Get external parameters
        torrent_name = sys.argv[1]
        save_path = sys.argv[2]
        torrent_size = round(int(sys.argv[3]) / 1000000,3)
        # Build the message to be sent
        message = f"Торрент завершён!\nИмя Торрента: {torrent_name}\nПуть: {save_path}\nРазмер: {torrent_size} Мб"

        # Call the send message function and pass the message to it
        response = send_telegram_message(bot_token, chat_id, message)
        print(response)

Proposed code change

apk add py3-requests

github-actions[bot] commented 3 weeks ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

Roxedus commented 3 weeks ago

use the package mod. https://github.com/linuxserver/docker-mods/tree/universal-package-install

bravo321 commented 3 weeks ago

use the package mod. https://github.com/linuxserver/docker-mods/tree/universal-package-install

I understand that you can do this yourself, but I wouldn’t want to assemble the container manually every time :)

Roxedus commented 3 weeks ago

That is not what that is. It adds the package on startup if its missing. It does exactly what you want, without having to build the image yourself

bravo321 commented 3 weeks ago

Спасибо! Сделал так, вроде работает :

  environment:
      - DOCKER_MODS=linuxserver/mods:universal-package-install 
      - INSTALL_PACKAGES=py3-requests