import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
vk_session = vk_api.VkApi(token="vk1.a.IMXoxF7BIOEoFvpGPgiPG4De6KHprI8f7hXBjISVi8dqGHzowuySv8aXgtdRiiSq-9QsavHyXPGOdHWOpn0BGZ04mPQKuqhye4BI5gC4Kt9YH1OHqz4_PGjHqbBNHtQ1Mh6xN4MOl3NXW_4HjEQggd4kFX124_oFdwn7-LHhUBeQfBmcXnqwRovDJukl6Af0toHeQqcickmHScqg87HD-w")
session_api = vk_session.get_api()
longpool = VkLongPoll(vk_session)
def send_some_msg(id, some_text):
vk_session.method("messages.send", {"user_id":id, "message":some_text,"random_id":0})
for event in longpool.listen():
if event.type == VkEventType.MESSAGE_NEW:
if event.to_me:
msg = event.text.lower()
id = event.user_id
if msg == "hi":
send_some_msg(id, "Hi friend!")
Выдает такую ошибку:
Traceback (most recent call last):
File "C:\Users\Святогор\PycharmProjects\pythonProject\bot.py", line 6, in
longpool = VkLongPoll(vk_session)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Святогор\PycharmProjects\pythonProject\.venv\Lib\site-packages\vk_api\longpoll.py", line 515, in __init__
self.update_longpoll_server()
File "C:\Users\Святогор\PycharmProjects\pythonProject\.venv\Lib\site-packages\vk_api\longpoll.py", line 529, in update_longpoll_server
response = self.vk.method('messages.getLongPollServer', values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Святогор\PycharmProjects\pythonProject\.venv\Lib\site-packages\vk_api\vk_api.py", line 697, in method
raise error
vk_api.exceptions.ApiError: [15] Access denied: group messages are disabled