Added transmission client.

This commit is contained in:
Alexandr Bogomyakov
2020-06-07 20:15:57 +03:00
parent e41f7348d4
commit 64337108a1
4 changed files with 24 additions and 0 deletions

View File

@ -72,11 +72,25 @@ def main():
pre="\n")
update.message.reply_text(msg, parse_mode='HTML', disable_web_page_preview=True)
def handle_client(update, context):
log.info(
"Got /client request from user [%s] %s",
update.message.chat['id'],
update.message.from_user.username)
try:
host, port = update.message.text.split(':')
except:
update.message.reply_text(
'Send transmission RPC address like <b>host:port</b>',
parse_mode='HTML',
disable_web_page_preview=True)
updater = Updater(token, use_context=True)
update_watcher(updater.bot)
updater.dispatcher.add_handler(CommandHandler('list', list_alerts))
updater.dispatcher.add_handler(CommandHandler('client', handle_client))
updater.dispatcher.add_handler(MessageHandler(filters.Filters.text, add))
updater.start_polling()

View File

@ -4,6 +4,7 @@ import logging
from datetime import datetime
from .rutracker import Torrent
from .tools import format_topic
from .transmission import add_tor
UPDATE_INTERVAL = 2 * 60 * 60 # in secs.

8
gaspar/transmission.py Normal file
View File

@ -0,0 +1,8 @@
from transmission_rpc import Client
def add_tor(tor_hash):
c = Client(host='msk.hexor.ru', port=80)
m = f'magnet:?xt=urn:btih:{tor_hash}'
c.add_torrent(m)

View File

@ -1 +1,2 @@
python-telegram-bot==12.7
transmission-rpc==2.0.4