R
R
Rusiantvso2020-08-01 16:55:37
Python
Rusiantvso, 2020-08-01 16:55:37

How to make the bot respond if there is a keyword in the text?

for example, a person writes hello to someone and the bot accepts hello as for himself

if textl.lower() == 'привет':
            try:
                vk.messages.send(
                    peer_id=peer_id,
                    message='привет',
                    random_id=get_random_id(),
                )
            except Exception as e:
                print ("Сообщение не отправленно")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0ralo, 2020-08-01
@Rusiantvso

if "слово" in text.lower():
   ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question