T
T
tatsuki12021-10-11 17:52:19
Python
tatsuki1, 2021-10-11 17:52:19

Doesn't want to answer in groups, can you help?

Greetings. I need your help, I am writing a bot on the PyTelegramBotApi library, and I did a check for messages in private messages with the bot, but when these messages are written to the group, it does not respond to what is written in else. And when I write any other message to him in PM, he answers what is in else. I'll attach the code below

@bot.message_handler(content_types=['text'])
def raspisanya(message):
    if message.chat.type == 'private':

        if message.text == 'Понедельник':
            photo = open('kartinki/pon.png', 'rb')
            bot.send_photo(message.chat.id, photo, caption='Держите')
        elif message.text == 'Вторник':
            photo = open('kartinki/vt.png', 'rb')
            bot.send_photo(message.chat.id, photo, caption='Держите')
        elif message.text == 'Среда':
            photo = open('kartinki/sreda.png', 'rb')
            bot.send_photo(message.chat.id, photo, caption='Держите')
        elif message.text == 'Четверг':
            photo = open('kartinki/cht.png', 'rb')
            bot.send_photo(message.chat.id, photo, caption='Держите')
        elif message.text == 'Пятница':
            photo = open('kartinki/pyt.png', 'rb')
            bot.send_photo(message.chat.id, photo, caption='Держите')
        elif message.text == 'Звонки':
            photo = open('kartinki/zvonki.png', 'rb')
            bot.send_photo(message.chat.id, photo, caption='Держите')
        else:
            sti = open('sticker/idinaxui.webp', 'rb')
            bot.send_sticker(message.chat.id, sti)
            bot.send_message(message.chat.id, 'Не отвечаю на данные сообщение в группах, пишите в личные сообщения.')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-10-11
@tatsuki1

We apply the ruler to the monitor and see that the else is clearly coming out of the first if block.
6164503d9441a639678272.jpeg
Remove spaces before else

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question