Example #1
0
    def guess_try(self, message, text):
        number = self.read_data(message.chat.id)

        done = False

        try:
            guess = int(text)
            if guess == number:
                reply = 'Congratz, you nailed it %s' % message.sender.first_name
                done = True
            elif guess < number:
                reply = "I'm thinking higher..."
            else:
                reply = "I'm thinking lower..."
        except ValueError:
            reply = "Invalid guess!"

        if done:
            self.save_data(message.chat.id)
            self.clear_chat_replies(message.chat)
            self.bot.send_message(
                message.chat.id,
                reply,
                reply_to_message_id=message.message_id,
                reply_markup=ReplyKeyboardHide.create()
            )
        else:
            m = self.bot.send_message(
                message.chat.id,
                reply,
                reply_to_message_id=message.message_id,
                reply_markup=ReplyKeyboardMarkup.create(
                    keyboard=[
                        ['0', '1', '2'],
                        ['3', '4', '5'],
                        ['6', '7', '8'],
                        ['9'],
                    ],
                    resize_keyboard=True,
                    one_time_keyboard=True,
                )
            ).wait()
            self.need_reply(self.guess_try, message, out_message=m, selective=True)
Example #2
0
    def guess_start(self, message, text):
        number = int(random() * 10)
        self.save_data(message.chat.id, obj=number)

        m = self.bot.send_message(
            message.chat.id,
            "I'm going to think of a number between 0 and 9 and you have to guess it! What's your guess?",
            reply_to_message_id=message.message_id,
            reply_markup=ReplyKeyboardMarkup.create(
                keyboard=[
                    ['0', '1', '2'],
                    ['3', '4', '5'],
                    ['6', '7', '8'],
                    ['9'],
                ],
                resize_keyboard=True,
                one_time_keyboard=True,
            )
        ).wait()
        self.need_reply(self.guess_try, message, out_message=m, selective=True)
Example #3
0
 def menu(chat):
     return ReplyKeyboardMarkup.create(keyboard=[['One']])
Example #4
0
 def menu(chat):
     return ReplyKeyboardMarkup.create(keyboard=[['One']])