mirror of
https://github.com/house-of-vanity/gaspar.git
synced 2025-07-06 18:24:07 +00:00
Added transmission client.
This commit is contained in:
@ -72,11 +72,25 @@ def main():
|
|||||||
pre="\n")
|
pre="\n")
|
||||||
update.message.reply_text(msg, parse_mode='HTML', disable_web_page_preview=True)
|
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)
|
updater = Updater(token, use_context=True)
|
||||||
update_watcher(updater.bot)
|
update_watcher(updater.bot)
|
||||||
|
|
||||||
updater.dispatcher.add_handler(CommandHandler('list', list_alerts))
|
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.dispatcher.add_handler(MessageHandler(filters.Filters.text, add))
|
||||||
|
|
||||||
updater.start_polling()
|
updater.start_polling()
|
||||||
|
@ -4,6 +4,7 @@ import logging
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from .rutracker import Torrent
|
from .rutracker import Torrent
|
||||||
from .tools import format_topic
|
from .tools import format_topic
|
||||||
|
from .transmission import add_tor
|
||||||
|
|
||||||
UPDATE_INTERVAL = 2 * 60 * 60 # in secs.
|
UPDATE_INTERVAL = 2 * 60 * 60 # in secs.
|
||||||
|
|
||||||
|
8
gaspar/transmission.py
Normal file
8
gaspar/transmission.py
Normal 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)
|
||||||
|
|
||||||
|
|
@ -1 +1,2 @@
|
|||||||
python-telegram-bot==12.7
|
python-telegram-bot==12.7
|
||||||
|
transmission-rpc==2.0.4
|
||||||
|
Reference in New Issue
Block a user