D
D
Denis2021-01-17 05:14:35
Python
Denis, 2021-01-17 05:14:35

How to make the telegram bot give a specific message to any user text?

If you write any message to the bot in a personal, roughly speaking, how to respond with one message without touching the commands / / /
For example: I don’t understand you - send me a command.
At the same time, so that the bot does not react to a public chat, only if you write to him in a personal :)
Thanks for any help :)
python - telegrambotapi

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2021-01-17
@denmeln

@bot.message_handler(content_types=['text'])
def text_handler(message):
    if message.chat.type == 'private':
        bot.send_message(message.chat.id, 'Я тебя не понимаю - отправь  мне команду')

M
me, 2021-01-17
@dabudi

bot = telebot.TeleBot('token')

@bot.message_handler(commands=['start'])
def start_message(message):
    bot.send_message(message.chat.id, 'Привет!')
    
@bot.message_handler(content_types=['text'])
def start(message):
    bot.send_message(message.chat.id, 'Я тебя не понимаю - отправь  мне команду')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question