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'
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'
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"
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"
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"
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"
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"
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"
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"
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"
def read_user_info(): global chat_id user = ClassUsers.load(chat_id) bot_logger.debug("Read user") return user
def read_user_info(): global chat_id user = ClassUsers.load(chat_id) bot_logger.debug("Read user") return user