Как использовать репозиторий python -telegram-bot для отправки сообщения на запрос пользователя telegram? - PullRequest
0 голосов
/ 08 апреля 2020

Я запрограммировал бот-телеграмму для загрузки торрентов с репозитория python -telegram-bot; однако, мои функции, кажется, работают на стороне сервера, и ответы появляются на моем терминале / консоли, где я запускаю сервер py-script и translationBT, но он не отправляет ответ обратно пользователю. ниже мой код:

def get_torrent(MAGNET):
    import subprocess
    get_it = subprocess.run(["transmission-remote", "-a", "-D", "-o", "--utp", MAGNET])
    return "*success*"

def list_torrent(LISTED):
    import subprocess
    get_list = subprocess.run(["transmission-remote", LISTED])
    return "*listed*"

def del_torrent(TORRENT_NO):
    import subprocess
    del_torrent = subprocess.run(["transmission-remote", "-t", TORRENT_NO, "-r"])
    return "*deleted*"

def crepttit(bot, update, args):
    import time
    MAGNET = " ".join(args)
    media_content = get_torrent(MAGNET)
    time.sleep(1)
    bot.send_meessage(chat_id=update.message.chat_id, text=media_content)

def crepttl(bot, update, args):
    import time
    LISTED  = " ".join(args)
    listed_torrent = list_torrent(LISTED)
    time.sleep(1)
    chat_id = update.message.chat_id
    bot.send_message(chat_id=chat_id, text=torrent_list)

def crepttd(bot, update, args):
    import time
    TORRENT_NO = " ".join(args)
    deleted_torrent = del_torrent(TORRENT_NO) 
    time.sleep(1)
    bot.send_meessage(chat_id=update.message.chat_id, text=deleted_torrent)



from telegram.ext import Updater, CommandHandler
import subprocess
import time
import os
TOKEN = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
updater = Updater(TOKEN)
dispatcher = updater.dispatcher
start_handler = CommandHandler("creptt", crepttit, pass_args=True)
dispatcher.add_handler(start_handler)
start_handler2 = CommandHandler("crepttl", crepttl, pass_args=True)
dispatcher.add_handler(start_handler2)
start_handler3 = CommandHandler("crepttd", crepttd, pass_args=True)
dispatcher.add_handler(start_handler3)
updater.start_polling()
updater.idle()
...