N
N
Nikolai Ostrovsky2021-03-16 13:41:17
Python
Nikolai Ostrovsky, 2021-03-16 13:41:17

How to implement message processing by Telebot bot only in private messages?

Hello, is there any way to implement the bot so that it works only through private messages? For example, he is in the chat, but he does not need to execute commands when writing them in a general chat, but only when writing in private messages.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-03-16
@KotoFeyic

Check what type of chat the message came from?

@bot.message_handler(commands=['start'])
def send_start(message):

    if message.chat.type == 'private':
        # ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question