F
F
Froeuse2020-09-02 16:16:21
Python
Froeuse, 2020-09-02 16:16:21

Why is the next step not being logged? What to change in the code?

@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, 'Назовите клан:', reply_to_message_id=message.message_id)
        bot.register_next_step_handler_by_chat_id(chat_id, get_name)
    if message.text.lower() == '!вступить в клан':
        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):
    new_name = message.text
    bot.send_message(message.chat.id, str(new_name) + ' - верное название?', reply_to_message_id=message.message_id)
    clan_names.append(new_name)
    print(new_name)
    bot.register_next_step_handler_by_chat_id(new_name, accept)


def accept(message):
    if message.text('Да') or message.text.lower('да'):
        bot.send_message(message.chat.id, 'Клан ' + clan_names[0] + ' - успешно создан')
    elif message.text('Нет') or message.text.lower('нет'):
        return get_text_messages

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TwoBlueCats, 2020-09-02
@Froeuse

In the get_game function, an error occurred when registering the next handler, instead of the chat_id, the text of the user's message is passed.
The accept function also looks strange. Why return the initial function at the end? And only in the case of a negative answer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question