Сама ошибка:
Traceback (most recent call last):
File "C:\vkbot\vkbot.py", line 15, in
for event in VkLongPoll(session).listen():
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\vk_api\longpoll.py", line 517, in __init__
self.update_longpoll_server()
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\vk_api\longpoll.py", line 531, in update_longpoll_server
response = self.vk.method('messages.getLongPollServer', values)
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\vk_api\vk_api.py", line 656, in method
raise error
vk_api.exceptions.ApiError: [5] User authorization failed: invalid session.
import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
session = vk_api.VkApi(token="скрыт в целях безопасности")
def send_message(user_id, message):
session.method("messages.send", {
"user_id": user_id,
"message": message,
"random_id": 0
})
for event in VkLongPoll(session).listen():
if event.type == VkEventType.MESSAGE_NEW and event.to_me:
text = event.text.lower()
user_id = event.user_id
if text == "hello":
send_message(user_id, "Hi")