D
D
Dmitry2021-12-13 22:50:06
Python
Dmitry, 2021-12-13 22:50:06

How not to delete the Telegram url?

Tell me how to make the Telegram bot not delete the url t dot me.

There is such a code, but it removes all links, you need to add the Tr domain to the exception.

def delete_links(message):
        for entity in message.entities:
            if entity.type in ["url", "text_link"]:
                bot.delete_message(message.chat.id, message.message_id)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2021-12-13
@dimonchik2013

if entity.type in ["url", "text_link"]:
        [сюда ставь условие по проверке содержимого сообщения] и not
                bot.delete_message(message.chat.id, message.message_id)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question