I
I
Ivan Yakushenko2019-04-28 16:24:16
Python
Ivan Yakushenko, 2019-04-28 16:24:16

Why is the message only sent once?

Message sending code:

def send_message(self, user_id, message):
        return self.vk_api.messages.send(
            user_id=user_id,
            random_id=int(VkLongpollMode.GET_RANDOM_ID),
            message=message
        )

Function call code:
def waiting_message_listen(self, value_map):
        for event in self.long_poll.listen():
            if event.type == VkBotEventType.MESSAGE_NEW:
                if value_map.get(event.object.text) is not None:
                    entry_message = value_map.get(event.object.text)
                    return float(entry_message)
                else:
                    print('incorrect')
                    self.send_message(event.object.from_id, 'Вы ввели неверное значение. Повторите попытку.')

The pint('incorrect') line works great, but the message is only sent once.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Zhilyaev, 2019-04-28
@kshnkvn

Message may not be sent due to the same random_id (or missing)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question