コード例 #1
0
def addmagnet(torrent, chat_id):
    try:
        user = ClassUsers.load(chat_id)
        # http://pazpi.ecc to replace with the setting from the user
        url = user.host + ":" + user.port + '/php/addtorrent.php?url=' + torrent
        if not (user.username == "NULL" or user.password == "NULL"):
            try:
                respond = requests.post(url,
                                        auth=HTTPBasicAuth(
                                            user.username, user.password))
                # If server answer correctly answer successfully
                if respond.status_code == 200:
                    return 'Magnet added successfully!'
                else:
                    return 'Error communicating with server Error ' + str(
                        respond.status_code)
            except requests.exceptions.ConnectionError:
                return 'Host not reachable'
        else:
            try:
                respond = requests.post(url)
                if respond.status_code == 200:
                    return 'Magnet added successfully!'
                else:
                    return 'Error communicating with server. Error ' + str(
                        respond.status_code)
            except requests.exceptions.ConnectionError:
                return 'Host not reachable'
    except EOFError:
        return 'Host not set, type /start to config your user'
コード例 #2
0
ファイル: handleTorrent.py プロジェクト: pazpi/ruTorrent-bot
def addmagnet(torrent, chat_id):
    try:
        user = ClassUsers.load(chat_id)
        # http://pazpi.ecc to replace with the setting from the user
        url = user.host + ":" + user.port + '/ruTorrent/php/addtorrent.php?url=' + torrent
        if not (user.username == "NULL" or user.password == "NULL"):
            try:
                respond = requests.post(url, auth=HTTPBasicAuth(user.username, user.password))
                # If server answer correctly answer successfully
                if respond.status_code == 200:
                    return 'Magnet added successfully!'
                else:
                    return 'Error communicating with server Error ' + str(respond.status_code)
            except requests.exceptions.ConnectionError:
                return 'Host not reachable'
        else:
            try:
                respond = requests.post(url)
                if respond.status_code == 200:
                    return 'Magnet added successfully!'
                else:
                    return 'Error communicating with server. Error ' + str(respond.status_code)
            except requests.exceptions.ConnectionError:
                return 'Host not reachable'
    except EOFError:
        return 'Host not set, type /start to config your user'
コード例 #3
0
def setpassword():
    global text
    global chat_id
    chat_id_password_config.remove(chat_id)
    user = ClassUsers.load(chat_id)
    user.password = text
    user.dump(chat_id)
    chat_id_config.remove(chat_id)
    bot_logger.debug("set password")
    return "Password setted"
コード例 #4
0
def setusername():
    global text
    global chat_id
    chat_id_user_config.remove(chat_id)
    user = ClassUsers.load(chat_id)
    user.username = text
    user.dump(chat_id)
    chat_id_config.remove(chat_id)
    bot_logger.debug("set username")
    return "Hostname setted"
コード例 #5
0
ファイル: botDef.py プロジェクト: pazpi/ruTorrent-bot
def setpassword():
    global text
    global chat_id
    chat_id_password_config.remove(chat_id)
    user = ClassUsers.load(chat_id)
    user.password = text
    user.dump(chat_id)
    chat_id_config.remove(chat_id)
    bot_logger.debug("set password")
    return "Password setted"
コード例 #6
0
ファイル: botDef.py プロジェクト: pazpi/ruTorrent-bot
def setusername():
    global text
    global chat_id
    chat_id_user_config.remove(chat_id)
    user = ClassUsers.load(chat_id)
    user.username= text
    user.dump(chat_id)
    chat_id_config.remove(chat_id)
    bot_logger.debug("set username")
    return "Hostname setted"
コード例 #7
0
def setport():
    global text
    global chat_id
    if not text.isdigit:
        return "Port not correct, make sure is a number.\nEs: 80, 8080"
    else:
        chat_id_port_config.remove(chat_id)
        user = ClassUsers.load(chat_id)
        user.port = text
        user.dump(chat_id)
        chat_id_config.remove(chat_id)
        bot_logger.debug("set port")
        return "Port setted"
コード例 #8
0
ファイル: botDef.py プロジェクト: pazpi/ruTorrent-bot
def setport():
    global text
    global chat_id
    if not text.isdigit:
        return "Port not correct, make sure is a number.\nEs: 80, 8080"
    else:
        chat_id_port_config.remove(chat_id)
        user = ClassUsers.load(chat_id)
        user.port = text
        user.dump(chat_id)
        chat_id_config.remove(chat_id)
        bot_logger.debug("set port")
        return "Port setted"
コード例 #9
0
def sethost():
    global text
    global chat_id
    if not text[:7] == ("http://" or "https:/"):
        return "Address not correct, please follow the example.\nEs: http://myaddress.me"
    else:
        chat_id_host_config.remove(chat_id)
        try:
            user = ClassUsers.load(chat_id)
        except EOFError:
            user = ClassUsers.ChatIDUser()
        user.host = text
        user.dump(chat_id)
        chat_id_config.remove(chat_id)
        bot_logger.debug("set host")
        return "Host address setted"
コード例 #10
0
ファイル: botDef.py プロジェクト: pazpi/ruTorrent-bot
def sethost():
    global text
    global chat_id
    if not text[:7] == ("http://" or "https:/"):
        return "Address not correct, please follow the example.\nEs: http://myaddress.me"
    else:
        chat_id_host_config.remove(chat_id)
        try:
            user = ClassUsers.load(chat_id)
        except EOFError:
            user = ClassUsers.ChatIDUser()
        user.host = text
        user.dump(chat_id)
        chat_id_config.remove(chat_id)
        bot_logger.debug("set host")
        return "Host address setted"
コード例 #11
0
def read_user_info():
    global chat_id
    user = ClassUsers.load(chat_id)
    bot_logger.debug("Read user")
    return user
コード例 #12
0
ファイル: botDef.py プロジェクト: pazpi/ruTorrent-bot
def read_user_info():
    global chat_id
    user = ClassUsers.load(chat_id)
    bot_logger.debug("Read user")
    return user