V
V
Vasily2021-01-17 01:42:30
Python
Vasily, 2021-01-17 01:42:30

How to make the bot answer in the chat when it is called through the dog???

Hello, for the life of me I can’t figure out how to make him answer when his name is called through a dog or just replay in a group
How to make him answer one thing in a chat and another in private messages? pyTelegramBotApi

And then when I add him to the group and write something there without calling him (without replay, dogs), he answers me.

ps A
simple chat bot that responds with audio messages to user messages.
pss I
apologize for such a rudely worded combination of letters, the brain is boiling, newfag.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-01-17
@SoreMix

First, get the username of the bot using the get_me function. Then you can process text messages and only respond to them when the message starts with @username_bot
bot_username = '@{}'.format(bot.get_me().username)

@bot.message_handler(content_types=['text'])
def text_handler(message):
    
    if message.text.startswith(bot_username):
        # bla bla

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question