Extremely simple Telegram bot I made to get some basic info about the currently active torrents on my home Raspberry, using the qBittorrent WebUI APIs (v4.1+) through the python-qBittorrent library.
Only a small set of features of the qBittorrent web API has been implemented:
- see a list of torrents based on their downloading status
- add torrents by magnet link/torrent file
- manage a torrent (pause/resume, set force-start, increase priority, force re-check, delete)
- enable/disable/change your alternative speed limits
- see your qBittorrent settings
- see a pretty overview of your speed, queueing and share rateo settings
- export your torrents list as a json file
For a list of commands, use /help
Requires Python >= 3.6.2
- enable qBittorrent's Web UI
- copy
config.example.toml
toconfig.toml
- edit
config.toml
in the following way:
[telegram]
section: place your API token intoken
and your user ID inadmins
[qbitttorrent]
section: fill theurl
,login
andsecret
values according to your qBittorrent WebUI settings- all the other values in the config file are optional, and their function is described in
config.example.toml
. Make sure your config file contains all the keys in the example file (the bot won't start if some are missing, but it will tell you which), and that their type is correct
- install the rquirements via
pip install -r requirements.txt
By default, only admins are allowed to use the bot (users listed under telegram.admins
in config.toml
), but thereare some values in the permissions.json
file (default_permissions.json
if you have not started the bot yet) that can be toggled to set who can use the bot:
read
: whentrue
, anyone can use read-only commands (viewing the torrents list, the torrents' info etc.)write
: whentrue
, anyone can add torrents by magnet link/file/link. Only works ifread
istrue
edit
: whentrue
, anyone can manage a torrent's settings and qbittorrent's setting. Only works ifread
istrue
admins_only
: nobody can use the bot except for the users listed asadmins
, which can do anything. Whentrue
, this setting has the priority over the read/write/edit settings (they will be ignored and the bot will only work for the admins)
You can see and change the current permissions configuration from the bot's chat, using the /permissions
and /pset
commands
Docker is only tested on Linux. It will most likeyly work on macOS too, but not on Windows: Docker doesn't create the docker0
network interface
- clone the source code
- copy
config.example.toml
toconfig.toml
- edit
config.toml
in the following way:
[telegram]
section: place your API token intoken
and your user ID inadmins
[qbitttorrent]
section: fill the three values according to your qBittorrent WebUI settings. IMPORTANT read the config file comment about docker0 network!
- build your image with
docker build . -t {YOUR_TAG}
- run docker
docker run -d -v ${PWD}/config.toml:/app/config.toml {YOUR_TAG}
- download
config.example.toml
to your directory of choice, such as/etc/qbbot/config.toml
- edit
config.toml
in the following way:
[telegram]
section: place your API token intoken
and your user ID inadmins
[qbitttorrent]
section: fill the three values according to your qBittorrent WebUI settings. IMPORTANT read the config file comment about docker0 network!
- pull the image:
docker pull 0one2/qbittorrent-bot
- run docker
docker run -d -v ${PWD}/config.toml:/app/config.toml 0one2/qbittorrent-bot
I made this bot to be able to manage what I'm downloading on my Raspberry running Raspbian (using qBittorrent's headless version), and that's the only environment I've tested this thing in. There's also the systemd file I'm using, qbtbot.service
(which assumes you're going to run the bot in a python3 virtual environment)