如何使用python-telegram-bot存储库向电报用户请求发送消息?

时间:2020-04-08 18:41:22

标签: python-telegram-bot

我编写了一个电报机器人,用于使用python-telegram-bot存储库下载种子;但是,我的功能似乎在服务器端起作用,并且响应显示在运行py-script和TransmissionBT服务器的终端/控制台上,但不会将响应发送回用户。下面是我的代码:

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()

0 个答案:

没有答案