V
V
Valentine2019-01-22 17:26:52
Python
Valentine, 2019-01-22 17:26:52

Updated vk_api and now random_id is required to send messages, why is this needed?

Traceback (most recent call last):
File "", line 93, in
vk.messages.send(peer_id= user_id, message = text)
File "C:\Program Files\Python37\lib\site-packages\vk_api\vk_api. py", line 646, in __call__
return self._vk.method(self._method, kwargs)
File "C:\Program Files\Python37\lib\site-packages\vk_api\vk_api.py", line 615, in method
raise error
vk_api.exceptions.ApiError: [100] One of the parameters specified was missing or invalid: random_id is a required parameter

Found this solution:
def get_random_id():
    return random.getrandbits(31) * random.choice([-1, 1])

and add random_id=get_random_id() to message.send . Is it optimal? But most of all I'm interested in the purpose for which this update was released?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Helow19274, 2019-01-22
@val_gr

https://vk.com/dev/versions
Look at version 5.90
If you don't want to specify random_id every time, install version 5.89.
And in general, they already wrote about it, including on the toaster.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question