import vk_api
import time
token = "5843245b181ae990161384ba1e0008bd13e5b5fe993d51"
user_id = 1
vk = vk_api.VkApi(token=token).get_api()
f = open("tt.txt", "rt", encoding="utf8")
def captcha_handler(captcha):
key = input("Enter captcha code {0}: ".format(captcha.get_url())).strip()
return captcha.try_again(key)
while True:
try:
line = f.read()
time.sleep(1)
vk.messages.send(
chat_id=51,
message=line,
random_id=0
)
f.seek(0)
except vk_api.exceptions.Captcha as captcha:
captcha_handler(captcha)
после вызова исключения и введении капчи вылазит ошибка:
Traceback (most recent call last):
File "C:\Users\Rik\Desktop\321.py", line 15, in
vk.messages.send(
File "C:\Users\Rik\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\vk_api\vk_api.py", line 708, in __call__
return self._vk.method(self._method, kwargs)
File "C:\Users\Rik\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\vk_api\vk_api.py", line 668, in method
raise error
vk_api.exceptions.ApiError: [100] One of the parameters specified was missing or invalid: message is empty or invalid