V
V
vkidos2021-01-13 13:45:52
Python
vkidos, 2021-01-13 13:45:52

Ignore text after the command. Python. How to make it so that after the command 'I want', the bot will still execute the given command?

if event.text == "хочу" :
                        if event.from_chat:
                            str = event.text
                            array = str.split("хочу")
                            vk.messages.send(
                            chat_id=event.chat_id,
                            random_id=get_random_id(),
                            message="Передать " + array[1],
                            reply_to=event.message_id
                    )

Code example.
if event.text == "I want" - the user writes I want the command to be executed.
str = event.text
array = str.split("want") -- these commands are for splitting the user's message into two parts.

Briefly: how to make the bot react not only to "I want", but also to "I want (any words)"?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
crabov, 2021-01-13
@vkidos

if "want" in event.text

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question