X
X
XWR2021-06-11 14:33:15
Python
XWR, 2021-06-11 14:33:15

Removing sms telegrams aiogram from the list?

Hello!!!!
I want to remove words from the list Here is the code
Delet = ["мат", "мат2"]

@dp.message_handler()
async def pro(message: types.Message):
    if Delet in message.text:
        await message.delete()


How to remove from the list?
I will be glad for your help)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Krostelev, 2021-06-11
@twistfire92

If we do not talk about any optimization, performance and false positives, for example, on the phrase "belt plaque", then this option will do:

@dp.message_handler()
async def pro(message: types.Message):
    for word in Delet:
        if word in message.text:
            await message.delete()
            break

But in a good way, you first need to make a list of all unique words in the message, remove punctuation marks, etc., and check each word in the Delet list. It is even better to convert the Delet list into a set (set)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question