O
O
OREl33432021-11-05 18:52:03
Python
OREl3343, 2021-11-05 18:52:03

When the queue reaches the last block, choosing 1 does nothing. Why doesn't the last block of code work?

import telebot
from telebot import types

client = telebot.TeleBot("1963852427:AAFuzigy74HooXQk9XolCB3SPuZalEo1A")

@client.message_handler(commands="start")
def start (message):
    button = types.ReplyKeyboardMarkup (resize_keyboard = True)
    item1 = types.KeyboardButton ("начать")
    button.add(item1)

    client.send_message(message.chat.id, "Привет,{0.first_name}".format(message.from_user), reply_markup=button)

@client.message_handler(content_types="text")
def send_message (message):
    if message.chat.type == "private":
        if message.text == "начать":
            button = types.ReplyKeyboardMarkup(resize_keyboard=True)
            item1 = types.KeyboardButton("Один")
            item2 = types.KeyboardButton("Два")
            item3 = types.KeyboardButton("Три")
            item4 = types.KeyboardButton("Четыре")
            button.add(item1, item2, item3, item4)
            client.send_message(message.chat.id, "Выберите число", reply_markup=button)

@client.message_handler(content_types="text")
def lalala (message):
    if message.text == "Один":
        client.send_message(message.chat.id, "1")


client.polling (none_stop = True)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-11-05
@OREl3343

Because you have two identical decorators.
@client.message_handler(content_types="text")
The top one fires .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question