F
F
Froeuse2020-09-02 13:15:46
Python
Froeuse, 2020-09-02 13:15:46

How to add "yes or no" selection conditions?

It is necessary to make it so that after "... is the correct name?" there was a yes or no choice.
If yes, then send the add message, if not, then return to "Name the clan"

@bot.message_handler(content_types=['text'])
def get_text_messages(message):
    if message.text.lower().startswith('!создать клан'):
        chat_id = message.chat.id
        bot.send_message(message.chat.id, 'Назовите клан:',)
        bot.register_next_step_handler_by_chat_id(chat_id, get_name)
    if message.text == ('!Вступить в Клан') or message.text == ('!вступить в клан') or message.text == (
            '!Вступить в клан') or message.text == ('!ВСТУПИТЬ В КЛАН'):
        chat_id1 = message.chat.id
        bot.send_message(message.chat.id, 'В какой клан хотите вступить?', reply_to_message_id=message.message_id, reply_markup=markup_menu_1)
        return (chat_id1)
def get_name(message):
    cht_id = message.from_user.id
    new_name = message.text
    bot.send_message(message.chat.id, new_name + ' - верное название?')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
heka313, 2020-09-02
@Froeuse

firstly, write message.text.lower() so as not to compare millions of text writing options,
and secondly, use bot.register_next_step_handler(message, func) - this thing sends message to another function
, and the if..else construct, and in end of bot.send_message

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question