W
W
Wearant2021-11-29 21:49:55
Python
Wearant, 2021-11-29 21:49:55

How to make a list of words to search for these words in the text?

The crux of the matter is this, you can call it a chat filter.
Throw a list of words into 1 file, and in the code check whether these words are in the message that has arrived.

text = event.message.text.lower().split()
peer_id = event.message.peer_id
user_id = event.message.from_id
user_get = vkls.users.get(user_ids=user_id, fields =("can_write_private_message") )
user_get = user_get[0]
first_name = user_get['first_name']

word = "слово", "слово", "слово", "слово", "слово",

if word in text:
message = (f"@id{user_id} ({first_name}), Вы успешно начали. \n Для вас открыто следующее достижение :)")
send(peer_id,message)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LXSTVAYNE, 2021-11-29
@Wearant

text = 'blablabla furfurfur 1234 123 11'.lower().split()
words = ['furfurfur', 'lalala']

print(any(filter(lambda x: x in text, words)))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question