Ejemplo n.º 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'
Ejemplo n.º 2
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 + '/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'
Ejemplo n.º 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"
Ejemplo n.º 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"
Ejemplo n.º 5
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"
Ejemplo n.º 6
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"
Ejemplo n.º 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"
Ejemplo n.º 8
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"
Ejemplo n.º 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"
Ejemplo n.º 10
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"
Ejemplo n.º 11
0
def read_user_info():
    global chat_id
    user = ClassUsers.load(chat_id)
    bot_logger.debug("Read user")
    return user
Ejemplo n.º 12
0
def read_user_info():
    global chat_id
    user = ClassUsers.load(chat_id)
    bot_logger.debug("Read user")
    return user