K
K
kodbiprog2021-03-15 13:55:43
Python
kodbiprog, 2021-03-15 13:55:43

How to search word in message (Bot Telegram Python)?

In my code, I want to implement that if the user of the bot writes the message "Does he want to leave?", And in this message there is the right word, for example, "wants", then the bot would send the answer "does not want".
import telebot
from telebot import types

token = 'Insert token'
bot = telebot.TeleBot(token)

@bot.message_handler(content_types='text')
def send(message):
Don't know how to proceed...
bot.send_message(chat_id= '@bottopli' , text='Don't want')

bot.polling()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2021-03-15
@kodbiprog

import telebot

token = ''

bot = telebot.TeleBot(token)

@bot.message_handler(content_types=['text'])
def repeat_all_message(message):

  if 'хочет' in message.text:
    bot.send_message(message.chat.id,'не хочет')

if __name__ == '__main__':
    bot.polling(none_stop=True)

This is taught in first grade.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question