G
G
Guerro692020-06-04 21:27:00
Python
Guerro69, 2020-06-04 21:27:00

Bot in VK sends one message and then an error?

I made a simple bot, the essence of it is that when messages are written to him in a PM or in a conversation with him, he must write messages to the cf I prepared, it works, but the problem is that it works for one message, when they write the second message, it just throws vk_api.exceptions.ApiError [10] Internal server error. I read what this error means, catching it, I thought that messages would be sent every other time, but this is not so. Here is the code:

while True:
    try:
        for i in longpoll.listen():
            if i.type == VkBotEventType.MESSAGE_NEW:
                vk.messages.send(peer_id=2000000005, message=f"Сообщение из чата (ID: {i.chat_id})\nID Пользователя: @id{i.obj.from_id}\nТекст: {i.obj.text}", random_id=rand)

    except vk_api.exceptions.ApiError:
        time.sleep(2)

UPD: My friend has the same bot and everything works fine for him.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Renat Ataev, 2020-06-04
@fanepka

DRINK LESS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question