Решил впервые сделать бота в вк. Вроде во всех источниках код такой же как у меня, но возникает ошибка. Код:
import vk_api
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
token = 'token'
vk_session = vk_api.VkApi(token = token)
longpoll = VkBotLongPoll(vk_session, 'group_id')
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW and event.to_me and event.text:
msg = event.text.lower()
print(msg)
Ошибка:
File "D:\JesbaSbot\main.py", line 7, in
longpoll = VkBotLongPoll(vk_session, 200768157)
File "C:\Users\миша и саша\AppData\Local\Programs\Python\Python39\lib\site-packages\vk_api\bot_longpoll.py", line 219, in __init__
self.update_longpoll_server()
File "C:\Users\миша и саша\AppData\Local\Programs\Python\Python39\lib\site-packages\vk_api\bot_longpoll.py", line 232, in update_longpoll_server
response = self.vk.method('groups.getLongPollServer', values)
File "C:\Users\миша и саша\AppData\Local\Programs\Python\Python39\lib\site-packages\vk_api\vk_api.py", line 656, in method
raise error
vk_api.exceptions.ApiError: [5] User authorization failed: invalid session.