Example #1
0
def game_process_response(message):
    chat_id = message.chat.id

    number = int(Chat.get(chat_id, 'game_number'))
    steps = int(Chat.get(chat_id, 'game_steps'))
    guess_number = int(message.text)

    if (number == guess_number):
        bot.send_message(chat_id, f"Enhorabuena has acertado en {steps} pasos")
        return

    if (guess_number > number):
        reply = bot.send_message(chat_id, "El número es más pequeño")
    else:
        reply = bot.send_message(chat_id, "El número es más grande")

    Chat.set(chat_id, "game_steps", 1 + steps)
    bot.register_next_step_handler(reply, game_process_response)
Example #2
0
def load(message):
    """
    Recupera un dato guardado con save
    """

    chat_id = message.chat.id
    data = Chat.get(chat_id, 'memory')
    if not data:
        bot.reply_to(message, "Aún no has guardado nada")
        return

    bot.reply_to(message, "Dato recuperado: %s" % data)