I would like to filter in a program that I have made that hunts specific messages from a database.
I've been watching other posts and googling a bit, and if I duplicate any existing questions, I apologize, but I can not find exactly what I'm looking for.
What I want to do is a filter that blocks me the texts that come from the database, but the filter that I have done right now does not filter me exactly as I want, since it does not literally filter for what I have written.
I do not know very well what criteria it follows to filter but, looking for, I found this:
#Keywords to ignore messages exclude : "^(?!.*(paga|pago|expul)).*$"
What he does for example with a text that I saw, is, if he has the text "win" automatically he does not pick it up, when he should,
So my question is: what method can I use in python to filter "literally" the keywords that I want?
EDIT: Program code:
blacklist = ["paga", "pago", "expul"] @client.on(events.NewMessage(pattern=lambda msg: not is_blacklisted(msg.message, blacklist))) async def my_event_handler(event): from_channel_id = event.original_update.message.to_id.channel_id entity = redirections.get(from_channel_id) if entity: await event.client.send_message(entity, event.original_update.message) def is_blacklisted(frase, palabras): for palabra in palabras: if palabra in frase: return True return False
Although the filter works without any error, if the message contains a line break, it filters it, even if it does not contain any keywords as such.
The same thing happens when using a regular expression.