Telegram bot written in python. How to do if sent exactly the message that you asked the bot to respond?

Here is the code -
import telebot
import config
from telebot import types

bot = telebot.TeleBot(config.token)

@bot.message_handler(commands=['start'])
def start(m):
 msg = bot.send_message(m.chat.id, 'Hello!')
 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True)
 keyboard.add(*[types.Keyboardbutton to(name) for name in ['Sherlock Holmes', 'Dr Watson']])
 bot.send_message(m.chat.id, 'Whom to choose?',
reply_markup=keyboard)
 bot.register_next_step_handler(msg, name)
<b>
def name(m):
 if m.text == 'Sherlock Holmes':
 bot.send_message(m.chat.id, '*You chose Sherlock Holmes', parse_mode='Markdown')
 elif m.text == 'Dr. Watson':
 bot.send_message(m.chat.id, '*You chose Dr. Watson', parse_mode='Markdown')</b>

bot.polling()


But when I click on button it displays the text but no answer from bot no!

What is the error?

If you want to - t.me/castlewarsbot

Thanks in advance!
June 14th 19 at 19:19
2 answers
June 14th 19 at 19:21
Solution
@bot.message_handler(content_types=['text'])
def messages(message):
 if 'Sherlock' in the message.text.lower() or 'Holmes' in the message.text.lower():
 bot.send_message(message.chat.id, 'You chose Sherlock')
 elif 'doctor' in message.text.lower() or 'Watson' in the message.text.lower():
 bot.send_message(message.chat.id, 'You have chosen Watson')
Thank you so much! Very helpful. 3 hours tormented. Thank you. - nikita.Stracke commented on June 14th 19 at 19:24
June 14th 19 at 19:23
It's much easier. You have code error:
<b>
def name(m):</b>


Instead of here: "<b>"</b>must be a handle: @bot.message_handler(content_types=['text'])

Find more questions by tags BotsMessengersPython