Home python 10 Internal server error

10 Internal server error

Author

Date

Category

I decided to create a bot for VK conversations. I added it to one conversation, started trying to start writing something through it, and then there was an error:

Traceback (most recent call last):
 File "bot.py", line 11, in & lt; module & gt;
  msg (2,000,000,000 + 50, 'check')
 File "bot.py", line 9, in msg
  vk.messages.send (peer_id = idd, random_id = 0, message = text)
 File "C: \ Users \ asus \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ site-packages \ vk_api \ vk_api.py", line 671, in __call__
  return self._vk.method (self._method, kwargs)
 File "C: \ Users \ asus \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ site-packages \ vk_api \ vk_api.py", line 636, in method
  raise error
vk_api.exceptions.ApiError: [10] Internal server error

By the way, here’s the code itself:

import vk_api
token = 'HIDDEN'
session = vk_api.VkApi (token = token)
vk = session.get_api ()
def msg (idd, text):
  vk.messages.send (peer_id = idd, random_id = 0, message = text)
msg (2,000,000,000 + 50, 'check')

Tell me what’s wrong


Answer 1

You are trying to send a message to a non-existent dialog. Such a problem was here . You want to write to conversation at number 50, but at number 50 it is you on the page, the bot probably has a different number (I guess it’s 1). Plus, you can pass random.getrandbits (32) as random_id . Better to use vk_api right away in conjunction with Long Poll. I advise you to read the following questions: VkBotLongPoll ignores messages from the conversation Vk-bot responds in LAN, but does not respond in conversations, what should I do? I get an error when trying to send a message to a conversation via VK_API Python

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions