Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
trueold89 | d6cd7abdeb |
|
|
trueold89 | 47301c367e |
|
|
trueold89 | 75d67e0c24 |
|
|
trueold89 | bbcb9f3596 |
|
|
trueold89 | ecff3ccf38 |
|
|
trueold89 | cdd1f37f22 |
|
|
trueold89 | e0345df54e |
|
|
trueold89 | d951b22056 |
|
|
trueold89 | 2d39ff4a2d |
|
|
trueold89 | ed5ab7b05e |
|
|
trueold89 | c43d195d35 |
|
|
trueold89 | 50fa098102 |
|
|
trueold89 | 18c670f4c7 |
|
|
trueold89 | fd39f0c48d |
|
|
trueold89 | eb7487a43f |
|
|
@ -1,9 +1,10 @@
|
|||
FROM alpine:latest
|
||||
COPY bot /opt/bot
|
||||
RUN apk update && apk add bash python3 py-pip wget icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib && pip install telebot
|
||||
RUN apk update && apk add tzdata bash python3 py-pip wget icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib && pip install telebot
|
||||
RUN wget https://github.com/fedarovich/qbittorrent-cli/releases/download/v1.7.22315.1/qbt-linux-alpine-x64-1.7.22315.1.tar.gz && \
|
||||
mkdir /opt/qbt && \
|
||||
tar -zxf qbt-linux-alpine-x64-1.7.22315.1.tar.gz -C /opt/qbt && \
|
||||
chmod a+x /opt/qbt/* && \
|
||||
ln -sf /opt/qbt/qbt /bin/qbt && ln -sf /opt/bot/bot.py /bin/bot
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
ENTRYPOINT ["/bin/bot"]
|
||||
|
|
91
Readme.md
91
Readme.md
|
@ -2,45 +2,44 @@
|
|||
|
||||
![](https://cloud.orudo.ru/apps/files_sharing/publicpreview/pgxm2mKT5KHEHFE?file=/&fileId=23795&x=1920&y=1200&a=true&etag=430e9d84364f13b79e42991fede6609a)
|
||||
|
||||
## Telegram бот, предназначенный для удаленного добавление загрузок в очередь на qBitTorrent сервер
|
||||
|
||||
## Telegram bot designed to remotely add downloads to the queue on qBitTorrent server
|
||||
| [**git.orudo.ru**](https://git.orudo.ru/OrudoCA/qBitDownload-Bot) | [**GitHub**](https://github.com/OrudoCA/qBitDownload-Bot) | [**DockerHub**](https://hub.docker.com/r/orudoca/qbitdownload-bot) |
|
||||
| ---------------- | ---------- | ------------- |
|
||||
| [![](https://cloud.orudo.ru/apps/files_sharing/publicpreview/AmggNTQWgR6KkyB?file=/&fileId=23836&x=1920&y=1200&a=true&etag=0ef9694cea6e4d85c05aef9be72b927a)](https://git.orudo.ru/OrudoCA/qBitDownload-Bot) | [![](https://cloud.orudo.ru/apps/files_sharing/publicpreview/ip5qtGcwKHMPMAG?file=/&fileId=23819&x=1920&y=1200&a=true&etag=c540068d990ac47217a31f7450afc0ee)](https://github.com/OrudoCA/qBitDownload-Bot) |[![](https://cloud.orudo.ru/apps/files_sharing/publicpreview/7AEeEAzHYikFd5B?file=/&fileId=23806&x=1920&y=1200&a=true&etag=59894ecdfa7aaa6fb832cc4bf99c418d)](https://hub.docker.com/r/orudoca/qbitdownload-bot) |
|
||||
|
||||
### Для работы бота требуется [**qBitTorrent**](https://www.qbittorrent.org/) сервер
|
||||
### Bot requires [**qBitTorrent**](https://www.qbittorrent.org/) server
|
||||
|
||||
---
|
||||
|
||||
### Текущие фичи:
|
||||
### Current features:
|
||||
---
|
||||
- **Авторизация по паролю**
|
||||
- **Добавление загрузок в очередь через .torrent файлы / Magnet-ссылки**
|
||||
- **Добавление/Удаление директорий для загрузок**
|
||||
- **Authorization by password**
|
||||
- **Adding downloads to the queue via .torrent files / Magnet-links**
|
||||
- **Add/Delete download directories**
|
||||
- **Multiple language support**
|
||||
|
||||
---
|
||||
|
||||
### В образе используется ["fedarovich/qbittorrent-cli"](https://github.com/fedarovich/qbittorrent-cli)
|
||||
### Image uses ["fedarovich/qbittorrent-cli"](https://github.com/fedarovich/qbittorrent-cli)
|
||||
|
||||
---
|
||||
|
||||
[![](https://cloud.orudo.ru/apps/files_sharing/publicpreview/rRcdSnCEaA85tWf?file=/&fileId=23784&x=1920&y=1200&a=true&etag=32928842bc4e76adaba194cdd9ec1351)](https://hub.docker.com/r/orudoca/qbitdownload-bot)
|
||||
|
||||
## Развертывание через Docker:
|
||||
#### 1. Соберите образ или склонируйте образ с [Dockerhub](https://hub.docker.com/r/orudoca/qbitdownload-bot)
|
||||
## Deploy with Docker
|
||||
#### 1. Build image or clone it from [Dockerhub](https://hub.docker.com/r/orudoca/qbitdownload-bot)
|
||||
|
||||
**Склонировать репозиторий и перейти в его директорию**
|
||||
**Clone a repository and go to its directory**
|
||||
```bash
|
||||
git clone https://git.orudo.ru/OrudoCA/qBitDownload-Bot.git && cd qBitDownload-Bot
|
||||
```
|
||||
|
||||
**Сбор образа**
|
||||
**Build image**
|
||||
```bash
|
||||
docker build -t <IMAGE_NAME> .
|
||||
```
|
||||
|
||||
#### 2. Развернуть через docker-cli или docker-compose
|
||||
|
||||
#### 2. Deploy via docker-cli or docker-compose
|
||||
**Docker-cli**
|
||||
```bash
|
||||
docker run \
|
||||
|
@ -50,19 +49,22 @@ docker run \
|
|||
-v /path/to/media:/path/to/media \
|
||||
-e TOKEN="<YOUR_BOT_TOKEN_HERE>" \
|
||||
-e PASS="change_me" \
|
||||
-e QURL="<http://<YOUR_QBIT_SERVER_IP_HERE>:<PORT>" \
|
||||
-e QUSER="<YOUR_QBIT_USERNAME>"
|
||||
-e QPASS="<YOUR_QBIT_PASSWORD>"
|
||||
-d your_image_here
|
||||
-e QURL="http://<YOUR_QBIT_SERVER_IP_HERE>:<PORT>" \
|
||||
-e QUSER="<YOUR_QBIT_USERNAME>" \
|
||||
-e QPASS="<YOUR_QBIT_PASSWORD>" \
|
||||
-e LANG="YOUR_LANG" \
|
||||
-e TZ="Europe/Moscow" \
|
||||
-d -it your_image_here
|
||||
```
|
||||
|
||||
##### или
|
||||
##### or
|
||||
|
||||
**docker-compose**
|
||||
```yml
|
||||
services:
|
||||
qbitdl_bot:
|
||||
image: <YOUR_IMAGE_HERE>
|
||||
tty: true
|
||||
container_name: qbitdl_bot
|
||||
volumes:
|
||||
- /path/to/config:/etc/bot
|
||||
|
@ -71,11 +73,60 @@ services:
|
|||
environment:
|
||||
TOKEN: "<YOUR_BOT_TOKEN_HERE>"
|
||||
PASS: "change_me"
|
||||
QURL: "<http://<YOUR_QBIT_SERVER_IP_HERE>:<PORT>"
|
||||
QURL: "http://<YOUR_QBIT_SERVER_IP_HERE>:<PORT>"
|
||||
QUSER: "<YOUR_QBIT_USERNAME>"
|
||||
QPASS: "<YOUR_QBIT_PASSWORD>"
|
||||
LANG: "<YOUR_LANG>"
|
||||
TZ: "Europe/Moscow"
|
||||
```
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
![](https://cloud.orudo.ru/apps/files_sharing/publicpreview/ffSABnXQ3cQrLZG?file=/&fileId=23851&x=1920&y=1200&a=true&etag=d2d4704b2ab90afe5edee647a19a5540)
|
||||
|
||||
## Run natively:
|
||||
### 1. Install deps:
|
||||
- python3
|
||||
- py3-pip
|
||||
- [qbittorrent-cli](https://github.com/fedarovich/qbittorrent-cli)
|
||||
|
||||
### 2. Install TeleBot lib:
|
||||
```bash
|
||||
pip install telebot
|
||||
```
|
||||
|
||||
### 3. Set system ENV
|
||||
```bash
|
||||
# Linux
|
||||
export TOKEN="YOUR_BOT_TOKEN"
|
||||
export PASS="change_me"
|
||||
export QURL="http://<YOUR_QBIT_SERVER_IP_HERE>:<PORT>"
|
||||
export QUSER="<YOUR_QBIT_USERNAME>"
|
||||
export QPASS="<YOUR_QBIT_PASSWORD>"
|
||||
export LANG="<YOUR_LANG>"
|
||||
|
||||
# Windows PS
|
||||
set TOKEN="YOUR_BOT_TOKEN"
|
||||
set PASS="change_me"
|
||||
set QURL="http://<YOUR_QBIT_SERVER_IP_HERE>:<PORT>"
|
||||
set QUSER="<YOUR_QBIT_USERNAME>"
|
||||
set QPASS="<YOUR_QBIT_PASSWORD>"
|
||||
set LANG="<YOUR_LANG>"
|
||||
```
|
||||
|
||||
#### 3.1 On windows change PATH var in `db.py`
|
||||
|
||||
### 4. Run
|
||||
```bash
|
||||
python3 bot.py
|
||||
```
|
||||
---
|
||||
|
||||
### Available languages:
|
||||
|
||||
##### - **"ENG"** - English
|
||||
##### - **"RU"** - Russian
|
||||
|
|
77
bot/bot.py
77
bot/bot.py
|
@ -1,10 +1,11 @@
|
|||
#!/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
|
||||
import func, telebot, os
|
||||
import func, telebot, os, log, sys
|
||||
from db import PATH
|
||||
from lang import LANG as msg
|
||||
|
||||
TOKEN = os.environ["TOKEN"]
|
||||
TOKEN = os.environ.get('TOKEN','None')
|
||||
bot = telebot.TeleBot(TOKEN)
|
||||
folder_list = []
|
||||
dir = None
|
||||
|
@ -14,15 +15,15 @@ dir = None
|
|||
def welcome(message):
|
||||
id = message.from_user.id
|
||||
if func.auth_check(id):
|
||||
bot.reply_to(message,'Выберите тип загрузки:',reply_markup=home())
|
||||
bot.reply_to(message,str(msg.get('type')),reply_markup=home())
|
||||
else:
|
||||
bot.reply_to(message,'Этот бот запривачен, гнида, блять')
|
||||
bot.reply_to(message,str(msg.get('adeny')))
|
||||
|
||||
# Keyboard: Homepage
|
||||
def home():
|
||||
keyboard = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
|
||||
file = telebot.types.KeyboardButton('Файл')
|
||||
magnet = telebot.types.KeyboardButton('Magnet-ссылка')
|
||||
file = telebot.types.KeyboardButton(str(msg.get('file')))
|
||||
magnet = telebot.types.KeyboardButton(str(msg.get('magnet')))
|
||||
keyboard.add(file,magnet)
|
||||
return keyboard
|
||||
|
||||
|
@ -30,9 +31,10 @@ def home():
|
|||
@bot.message_handler(commands=['login'])
|
||||
def login(message):
|
||||
id = message.from_user.id
|
||||
name = message.from_user.first_name
|
||||
passwd = message.text.replace('/login ', '')
|
||||
f = func.u_auth(id,passwd)
|
||||
if f == 'Вы успешно авторизировались' or f == 'Вы уже авторизированны':
|
||||
f = str(func.u_auth(name,id,passwd))
|
||||
if f == str(msg.get('sucauth')) or f == str(msg.get('alauth')):
|
||||
bot.reply_to(message,f,reply_markup=home())
|
||||
else:
|
||||
bot.reply_to(message,f)
|
||||
|
@ -61,25 +63,27 @@ def folder_menu():
|
|||
@bot.message_handler(commands=['add'])
|
||||
def add(message):
|
||||
id = message.from_user.id
|
||||
name = message.from_user.first_name
|
||||
txt = message.text.split(' ', 2)
|
||||
if len(txt) == 3:
|
||||
key = txt[1]
|
||||
path = txt[2]
|
||||
f = func.add_dir(id,key,path)
|
||||
f = str(func.add_dir(name,id,key,path))
|
||||
else:
|
||||
f = 'Неверные аргументы'
|
||||
f = str(msg.get('aerr'))
|
||||
bot.reply_to(message,f,reply_markup=home())
|
||||
|
||||
# Folder del
|
||||
@bot.message_handler(commands=['del'])
|
||||
def rm(message):
|
||||
id = message.from_user.id
|
||||
name = message.from_user.first_name
|
||||
folder = message.text.replace('/del ', '')
|
||||
f = func.del_dir(id,folder)
|
||||
f = func.del_dir(name,id,folder)
|
||||
bot.reply_to(message,str(f),reply_markup=home())
|
||||
|
||||
# Magnet
|
||||
@bot.message_handler(func=lambda message: message.text == 'Magnet-ссылка')
|
||||
@bot.message_handler(func=lambda message: message.text == str(msg.get('magnet')))
|
||||
def magnet(message):
|
||||
id = message.from_user.id
|
||||
if func.auth_check(id):
|
||||
|
@ -87,14 +91,14 @@ def magnet(message):
|
|||
type = 'magnet'
|
||||
f = folder_menu()
|
||||
if f == None:
|
||||
bot.reply_to(message,'Папок не обнаруженно, воспользуйтесь коммандой /add')
|
||||
bot.reply_to(message,str(msg.get('cff')))
|
||||
else:
|
||||
bot.reply_to(message,'Выберите папку:',reply_markup=f)
|
||||
bot.reply_to(message,str(msg.get('chf')),reply_markup=f)
|
||||
else:
|
||||
bot.reply_to(message,'Этот бот запривачен, гнида, блять')
|
||||
bot.reply_to(message,str(msg.get('adeny')))
|
||||
|
||||
# File
|
||||
@bot.message_handler(func=lambda message: message.text == 'Файл')
|
||||
@bot.message_handler(func=lambda message: message.text == str(msg.get('file')))
|
||||
def file(message):
|
||||
id = message.from_user.id
|
||||
if func.auth_check(id):
|
||||
|
@ -102,16 +106,17 @@ def file(message):
|
|||
type = 'file'
|
||||
f = folder_menu()
|
||||
if f == None:
|
||||
bot.reply_to(message,'Папок не обнаруженно, воспользуйтесь коммандой /add')
|
||||
bot.reply_to(message,str(msg.get('cff')))
|
||||
else:
|
||||
bot.reply_to(message,'Выберите папку:',reply_markup=f)
|
||||
bot.reply_to(message,str(msg.get('chf')),reply_markup=f)
|
||||
else:
|
||||
bot.reply_to(message,'Этот бот запривачен, гнида, блять')
|
||||
bot.reply_to(message,str(msg.get('adeny')))
|
||||
|
||||
# File download
|
||||
@bot.message_handler(content_types=['document'])
|
||||
def download(message):
|
||||
id = message.from_user.id
|
||||
name = message.from_user.first_name
|
||||
if func.auth_check(id):
|
||||
global type, dir, folder_list
|
||||
if dir != None and type == 'file':
|
||||
|
@ -122,41 +127,57 @@ def download(message):
|
|||
file_name = os.path.join(PATH, message.document.file_name)
|
||||
with open(file_name, 'wb') as dl:
|
||||
dl.write(file)
|
||||
f = func.file(id,file_name,dir)
|
||||
f = str(func.file(name,id,file_name,dir))
|
||||
dir, type, folder_list = None,None,[]
|
||||
bot.reply_to(message,f)
|
||||
else:
|
||||
bot.reply_to(message,'Неверное расширение файла')
|
||||
bot.reply_to(message,'Выберите тип загрузки:',reply_markup=home())
|
||||
bot.reply_to(message,str(msg.get('ntorr')))
|
||||
bot.reply_to(message,str(msg.get('type')),reply_markup=home())
|
||||
else:
|
||||
bot.reply_to(message,'Этот бот запривачен, гнида, блять')
|
||||
bot.reply_to(message,str(msg.get('adeny')))
|
||||
|
||||
# Dir choose
|
||||
def dirchoose(message):
|
||||
global dir
|
||||
dir = message.text
|
||||
if type == 'magnet':
|
||||
bot.reply_to(message,'Отправте Magnet-ссылку')
|
||||
bot.reply_to(message,str(msg.get('sendm')))
|
||||
if type == 'file':
|
||||
bot.reply_to(message,'Отправте .torrent файл')
|
||||
bot.reply_to(message,str(msg.get('sendf')))
|
||||
|
||||
# Unknown message
|
||||
@bot.message_handler(func=lambda message: True)
|
||||
def unknown(message):
|
||||
global type, dir, folder_list
|
||||
id = message.from_user.id
|
||||
name = message.from_user.first_name
|
||||
if func.auth_check(id):
|
||||
txt = message.text
|
||||
if txt in folder_list:
|
||||
dirchoose(message)
|
||||
return None
|
||||
if dir != None and type == 'magnet':
|
||||
f = func.magnet(id,txt,dir)
|
||||
f = str(func.magnet(name,id,txt,dir))
|
||||
dir, type, folder_list = None,None,[]
|
||||
bot.reply_to(message,f)
|
||||
bot.reply_to(message,'Выберите тип загрузки:',reply_markup=home())
|
||||
bot.reply_to(message,str(msg.get('type')),reply_markup=home())
|
||||
else:
|
||||
bot.reply_to(message,'Этот бот запривачен, гнида, блять')
|
||||
bot.reply_to(message,str(msg.get('adeny')))
|
||||
|
||||
def run():
|
||||
if os.path.exists(PATH) == False:
|
||||
os.mkdir(PATH)
|
||||
log.start()
|
||||
try:
|
||||
func.qbt()
|
||||
except:
|
||||
log.errqbt()
|
||||
sys.exit(1)
|
||||
try:
|
||||
bot.polling()
|
||||
except:
|
||||
log.errtelebot()
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
|
|
50
bot/func.py
50
bot/func.py
|
@ -1,8 +1,9 @@
|
|||
#!/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
|
||||
import db, os
|
||||
import db, os, log, subprocess
|
||||
from db import *
|
||||
from lang import LANG as msg
|
||||
|
||||
def qbt():
|
||||
url = os.environ['QURL']
|
||||
|
@ -11,24 +12,27 @@ def qbt():
|
|||
commands = [
|
||||
f"qbt settings set url {url}",
|
||||
f"qbt settings set username {username}",
|
||||
f"echo {password} | qbt settings set password --no-warn"
|
||||
f"echo {password} | qbt settings set password --no-warn",
|
||||
f"qbt server info "
|
||||
]
|
||||
for command in commands:
|
||||
os.system(f"bash -c '{command}'")
|
||||
output = subprocess.run(command, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
|
||||
def u_auth(id,passwd):
|
||||
def u_auth(name,id,passwd):
|
||||
list = []
|
||||
if db.check('obj',AUTH_FILE):
|
||||
list = db.read(AUTH_FILE)
|
||||
if id in list:
|
||||
return 'Вы уже авторизированны'
|
||||
return msg.get('alauth')
|
||||
else:
|
||||
if passwd == os.environ['PASS']:
|
||||
list.append(id)
|
||||
db.write(list,AUTH_FILE)
|
||||
return 'Вы успешно авторизировались'
|
||||
log.auth(name,id)
|
||||
return msg.get('sucauth')
|
||||
else:
|
||||
return 'Неверный пароль'
|
||||
return msg.get('wrauth')
|
||||
|
||||
def auth_check(id):
|
||||
if db.check('obj',AUTH_FILE):
|
||||
|
@ -38,21 +42,22 @@ def auth_check(id):
|
|||
if id in list:
|
||||
return True
|
||||
|
||||
def add_dir(id,dir,path):
|
||||
def add_dir(name,id,dir,path):
|
||||
if auth_check(id):
|
||||
if os.path.exists(path) == False:
|
||||
return f"Директории '{path}' не сушествует на сервере"
|
||||
return str(msg.get('pne')).format(path)
|
||||
if db.check('obj',DIR_FILE):
|
||||
dict = db.read(DIR_FILE)
|
||||
else:
|
||||
dict = {}
|
||||
dict.setdefault(dir,path)
|
||||
db.write(dict,DIR_FILE)
|
||||
return f"Папка {dir} успешно добавлена"
|
||||
log.add(name,id,dir,path)
|
||||
return str(msg.get('fsa')).format(dir)
|
||||
else:
|
||||
return 'Этот бот запривачен, гнида, блять'
|
||||
return msg.get('adeny')
|
||||
|
||||
def del_dir(id,dir):
|
||||
def del_dir(name,id,dir):
|
||||
if auth_check(id):
|
||||
if db.check('obj',DIR_FILE):
|
||||
dict = db.read(DIR_FILE)
|
||||
|
@ -61,32 +66,35 @@ def del_dir(id,dir):
|
|||
if dir in dict:
|
||||
del dict[dir]
|
||||
db.write(dict,DIR_FILE)
|
||||
return f"Папка {dir} успешно удалена"
|
||||
log.rm(name,id,dir)
|
||||
return str(msg.get('frm')).format(dir)
|
||||
else:
|
||||
return f"Папки {dir} не существует"
|
||||
return str(msg.get('fne')).format(dir)
|
||||
else:
|
||||
return 'Этот бот запривачен, гнида, блять'
|
||||
return msg.get('adeny')
|
||||
|
||||
def magnet(id,link,dir):
|
||||
def magnet(name,id,link,dir):
|
||||
if auth_check(id):
|
||||
dict = db.read(DIR_FILE)
|
||||
path = dict[dir]
|
||||
command = f'''qbt torrent add url "{link} -f {path}"'''
|
||||
command = f'''qbt torrent add url "{link}" -f "{path}"'''
|
||||
os.system(f"bash -c '{command}'")
|
||||
return 'Torrent добавлен в очередь'
|
||||
log.addmagnet(name,id,link)
|
||||
return msg.get('add')
|
||||
else:
|
||||
return 'Этот бот запривачен, гнида, блять'
|
||||
return msg.get('adeny')
|
||||
|
||||
def file(id,file,dir):
|
||||
def file(name,id,file,dir):
|
||||
if auth_check(id):
|
||||
dict = db.read(DIR_FILE)
|
||||
path = dict[dir]
|
||||
command = f'''qbt torrent add file "{file}" -f {path}'''
|
||||
os.system(f"bash -c '{command}'")
|
||||
os.remove(file)
|
||||
return 'Torrent добавлен в очередь'
|
||||
log.addfile(name,id,file)
|
||||
return msg.get('add')
|
||||
else:
|
||||
return 'Этот бот запривачен, гнида, блять'
|
||||
return msg.get('adeny')
|
||||
|
||||
def dirlist():
|
||||
dirs = {}
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
|
||||
import os
|
||||
|
||||
langs = ['ENG','RU']
|
||||
|
||||
# Russian
|
||||
RU = {
|
||||
'alauth': 'Вы уже авторизированны',
|
||||
'sucauth': 'Вы успешно авторизировались',
|
||||
'wrauth': 'Неверный пароль',
|
||||
'pne': "Директории '{}' не сушествует на сервере",
|
||||
'fsa': "Папка '{}' успешно добавлена",
|
||||
'frm': "Папка '{}' успешно удалена",
|
||||
'fne': "Папки '{}' не существует",
|
||||
'add': 'Torrent добавлен в очередь',
|
||||
'type': 'Выберите тип загрузки:',
|
||||
'magnet': 'Magnet-ссылка',
|
||||
'file': 'Файл',
|
||||
'aerr': 'Неверные аргументы',
|
||||
'cff': 'Папок не обнаруженно, воспользуйтесь коммандой /add',
|
||||
'chf': 'Выберите папку:',
|
||||
'ntorr': 'Неверное расширение файла',
|
||||
'sendm': 'Отправте Magnet-ссылку',
|
||||
'sendf': 'Отправте .torrent файл',
|
||||
'adeny': 'Этот бот запривачен, гнида, блять',
|
||||
# Logs
|
||||
'l_create': "Log Файл '{}' создан",
|
||||
'l_start': 'Запуск бота...',
|
||||
'l_auth': "Пользователь '{} ({})' успешно авторизировался",
|
||||
'l_add': "Пользователь '{} ({})' добавил папку '{}' по пути '{}'",
|
||||
'l_rm': "Пользователь '{} ({})' удалил папку '{}'",
|
||||
'l_file': "Пользователь '{} ({})' добавил в очередь файл '{}'",
|
||||
'l_magnet': "Пользователь '{} ({})' добавил в очередь ссылку '{}'",
|
||||
'l_errqbt': "Ошибка подключения к qBitTorrent",
|
||||
'l_errtele': "Ошибка подключения к Telegram API, проверьте ваш токен",
|
||||
}
|
||||
|
||||
# English
|
||||
ENG = {
|
||||
'alauth': 'You are already authorized',
|
||||
'sucauth': 'You have successfully logged in',
|
||||
'wrauth': 'Wrong password',
|
||||
'pne': "The '{}' directory does not exist on the server",
|
||||
'fsa': "The '{}' folder has been successfully added",
|
||||
'frm': "The '{}' folder has been successfully deleted",
|
||||
'fne': "The '{}' folder does not exist",
|
||||
'add': 'Torrent has been added to the queue',
|
||||
'type': 'Select the download type:',
|
||||
'magnet': 'Magnet',
|
||||
'file': 'File',
|
||||
'aerr': 'Wrong arguments',
|
||||
'cff': 'No folders found, use the /add command',
|
||||
'chf': 'Select folder:',
|
||||
'ntorr': 'Incorrect file extension',
|
||||
'sendm': 'Send Magnet link',
|
||||
'sendf': 'Send .torrent file',
|
||||
'adeny': "You do not have access, first authorize '/login <password>'",
|
||||
# Logs
|
||||
'l_create': "Log File '{}' created",
|
||||
'l_start': 'Start bot polling...',
|
||||
'l_auth': "User '{} ({})' successfully authorized",
|
||||
'l_add': "User '{} ({})' added a folder '{}' with the path '{}'",
|
||||
'l_rm': "User '{} ({})' deleted '{}' folder",
|
||||
'l_file': "User '{} ({})' added file '{}' to the queue",
|
||||
'l_magnet': "User '{} ({})' added the link '{}' to the queue",
|
||||
'l_errqbt': "Error connecting to qBitTorrent",
|
||||
'l_errtele': "Error connecting to Telegram API, check your token"
|
||||
}
|
||||
|
||||
for i in langs:
|
||||
if i == os.environ.get('LANG','ENG'):
|
||||
LANG = globals()[i]
|
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
|
||||
import os, uuid
|
||||
from datetime import datetime
|
||||
from lang import LANG as msg
|
||||
from db import PATH
|
||||
|
||||
def dt():
|
||||
date = datetime.now().date()
|
||||
time = datetime.now().time()
|
||||
str = f'{date} | {time.strftime("%H:%M:%S")}'
|
||||
return str
|
||||
|
||||
DEFAULT = ['{} LOG: ','{} ERROR: ']
|
||||
ID = str(uuid.uuid1())[0:7]
|
||||
FILE = f'{ID}.txt'
|
||||
|
||||
def file(log):
|
||||
if os.path.exists(f'{PATH}logs') == False:
|
||||
os.mkdir(f'{PATH}logs')
|
||||
with open(f'{PATH}logs/{FILE}','a') as logfile:
|
||||
logfile.write(f'{log}\n')
|
||||
logfile.close()
|
||||
|
||||
def start():
|
||||
log1 = DEFAULT[0].format(dt()) + str(msg.get('l_create').format(FILE))
|
||||
log2 = DEFAULT[0].format(dt()) + str(msg.get('l_start'))
|
||||
file(log2)
|
||||
print(f'{log1}\n{log2}')
|
||||
|
||||
def auth(name,id):
|
||||
log = DEFAULT[0].format(dt()) + str(msg.get('l_auth').format(name,id))
|
||||
file(log)
|
||||
print(log)
|
||||
|
||||
def add(name,id,folder,path):
|
||||
log = DEFAULT[0].format(dt()) + str(msg.get('l_add').format(name,id,folder,path))
|
||||
file(log)
|
||||
print(log)
|
||||
|
||||
def rm(name,id,folder):
|
||||
log = DEFAULT[0].format(dt()) + str(msg.get('l_rm').format(name,id,folder))
|
||||
file(log)
|
||||
print(log)
|
||||
|
||||
def addfile(name,id,filename):
|
||||
log = DEFAULT[0].format(dt()) + str(msg.get('l_file').format(name,id,filename[9:]))
|
||||
file(log)
|
||||
print(log)
|
||||
|
||||
def addmagnet(name,id,link):
|
||||
log = DEFAULT[0].format(dt()) + str(msg.get('l_magnet').format(name,id,link))
|
||||
file(log)
|
||||
print(log)
|
||||
|
||||
def errqbt():
|
||||
log = DEFAULT[1].format(dt()) + str(msg.get('l_errqbt'))
|
||||
file(log)
|
||||
print(log)
|
||||
|
||||
def errtelebot():
|
||||
log = DEFAULT[1].format(dt()) + str(msg.get('l_errtele'))
|
||||
file(log)
|
||||
print(log)
|
|
@ -1,6 +1,7 @@
|
|||
services:
|
||||
qbitdl_bot:
|
||||
image: <YOUR_IMAGE_HERE>
|
||||
tty: true
|
||||
container_name: qbitdl_bot
|
||||
volumes:
|
||||
- /path/to/config:/etc/bot
|
||||
|
@ -9,6 +10,8 @@ services:
|
|||
environment:
|
||||
TOKEN: "<YOUR_BOT_TOKEN_HERE>"
|
||||
PASS: "change_me"
|
||||
QURL: "<http://<YOUR_QBIT_SERVER_IP_HERE>:<PORT>"
|
||||
QURL: "http://<YOUR_QBIT_SERVER_IP_HERE>:<PORT>"
|
||||
QUSER: "<YOUR_QBIT_USERNAME>"
|
||||
QPASS: "<YOUR_QBIT_PASSWORD>"
|
||||
LANG: "<YOUR_LANG>"
|
||||
TZ: "Europe/Moscow"
|
||||
|
|
Reference in New Issue