I
I
Ivan Yakushenko2019-04-28 13:28:55
Python
Ivan Yakushenko, 2019-04-28 13:28:55

How to check the input of a message in VK?

There is a console program that checks for valid input:

while True:
    try:
        n = int(input("Введите число от 1 до 10: "))
        if count_map.get(n) == None:
            raise Exception()
        break
    except Exception as e:
        print('Введено неправильное значение. Необходимо вводить цифру от 1 до 10')

By analogy, I tried to do this to check the message sent to the bot in VK, but whatever I tried, nothing works and the bot just spams the input error.
How can you "freeze" the execution of the loop until the VkBotEventType.MESSAGE_NEW event fires and then already perform the check, by analogy, as the input() function does?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Yakushenko, 2019-04-28
@kshnkvn

I solved the issue by creating a separate event listener loop.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question