Answer the question
In order to leave comments, you need to log in
What needs to be corrected in the code so that in the message “*text* is the correct name” instead of !create a clan, there is a user message?
The bot does not respond correctly to the next step
How should it be:
- !create a clan
- Name the clan:
- Uchiha
- Uchiha - correct name?
@bot.message_handler(content_types=['text'])
def get_text_messages(message):
if message.text == ('!Создать Клан') or message.text == ('!Создать клан') or message.text == (
'!создать клан') or message.text == ('!СОЗДАТЬ КЛАН'):
chat_id = message.chat.id
bot.send_message(message.chat.id, 'Назовите клан:',)
bot.register_next_step_handler_by_chat_id(chat_id,get_text_messages,get_name(message))
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)
elif message.text == 'Что я умею❓':
bot.send_message(message.from_user.id,
"Я умею назначать роли участникам группы, создавать кланы и организации, а также добавлять в них участников.")
elif message.text == 'Как добавить бота в чат❓':
bot.send_message(message.from_user.id,
'Для того чтобы подлючить бота к чату нужно:\nПредоставить права администратора в чате, остальное он сделает сам')
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
one.
if message.text == ('!Создать Клан') or message.text == ('!Создать клан') or message.text == (
'!создать клан') or message.text == ('!СОЗДАТЬ КЛАН'):
if message.text.lower().startswith('!создать клан'):
bot.register_next_step_handler_by_chat_id(chat_id,get_text_messages,get_name(message))
bot.register_next_step_handler_by_chat_id(result, get_name)
You can do it like this:
1. Change the ifs a little
if message.text.startwith('Создать клан'):
. . .
if message.text.startwith('Создать клан'):
mess_split = message.text.split() #разделится на слова.
if message.text.startwith('Создать клан'):
mess_split = message.text.split()
if mess_split.__len__ - 1 != 2:
#сделать, что-то.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question