예제 #1
0
def handle_text(message):
    try:
        arguments = parsing.find_arguments(message.text)
        record_id = parsing.get_id(arguments[0])
        database.remove(message.chat.id, record_id)
        bot.send_message(message.chat.id, quotes.REMOVE_OK)
    except exceptions.WrongNumberOfArgumentsException as exception:
        bot.send_message(message.chat.id, exception.value)
    except exceptions.NoSuchRecordException as exception:
        bot.send_message(message.chat.id, exception.value)
    except exceptions.InvalidArgumentFormatException as exception:
        bot.send_message(message.chat.id, exception.value)
    except OSError as exception:
        logging.critical(exception)
        bot.send_message(message.chat.id, quotes.BACKEND_ERROR)
        raise
    except Exception as exception:
        logging.error(exception)
        bot.send_message(message.chat.id, quotes.UNEXPECTED_ERROR)
        raise
예제 #2
0
def handle_text(message):
    try:
        arguments = parsing.find_arguments(message.text, last_is_string=True)
        cost = parsing.get_cost(arguments[0])
        date = parsing.get_date(arguments[1])
        description = parsing.get_description(arguments[2])
        database.add(message.chat.id, cost, date, description)
        bot.send_message(message.chat.id, quotes.ADD_OK)
    except exceptions.WrongNumberOfArgumentsException as exception:
        bot.send_message(message.chat.id, exception.value)
    except exceptions.InvalidArgumentFormatException as exception:
        bot.send_message(message.chat.id, exception.value)
    except OSError as exception:
        logging.critical(exception)
        bot.send_message(message.chat.id, quotes.BACKEND_ERROR)
        raise
    except Exception as exception:
        logging.error(exception)
        bot.send_message(message.chat.id, quotes.UNEXPECTED_ERROR)
        raise
예제 #3
0
def handle_text(message):
    try:
        arguments = parsing.find_arguments(message.text)
        number = parsing.get_number(arguments[0])
        unit = parsing.get_unit(arguments[1])
        bot.send_message(
            message.chat.id,
            database.recently_outcome(message.chat.id, number, unit))
    except exceptions.WrongNumberOfArgumentsException as exception:
        bot.send_message(message.chat.id, exception.value)
    except exceptions.InvalidArgumentFormatException as exception:
        bot.send_message(message.chat.id, exception.value)
    except OSError as exception:
        logging.critical(exception)
        bot.send_message(message.chat.id, quotes.BACKEND_ERROR)
        raise
    except Exception as exception:
        logging.error(exception)
        bot.send_message(message.chat.id, quotes.UNEXPECTED_ERROR)
        raise
예제 #4
0
def handle_text(message):
    try:
        arguments = parsing.find_arguments(message.text)
        date = parsing.get_date(arguments[0])
        database.clear_before_date(message.chat.id, date)
        bot.send_message(message.chat.id, quotes.CLEAR_OK)
    except exceptions.WrongNumberOfArgumentsException as exception:
        bot.send_message(message.chat.id, exception.value)
    except exceptions.InvalidArgumentFormatException as exception:
        bot.send_message(message.chat.id, exception.value)
        logging.critical(exception)
        bot.send_message(message.chat.id, quotes.BACKEND_ERROR)
        raise
    except OSError as exception:
        logging.critical(exception)
        bot.send_message(message.chat.id, quotes.BACKEND_ERROR)
        raise
    except Exception as exception:
        logging.error(exception)
        bot.send_message(message.chat.id, quotes.UNEXPECTED_ERROR)
        raise