import vk_api
import peewee
import utils
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
from models import User
from config import *
class MyLongPoll(VkBotLongPoll):
def listen(self):
while True:
try:
for event in self.check():
yield event
except Exception as e:
print(e)
class VkBot:
def __init__(self):
self.vk_session = vk_api.VkApi(token = token)
self.longpoll = MyLongPoll(self.vk_session, 218405889)
def run(self):
for event in self.longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
msg = event.object.message
user_id = msg['from_id']
user = utils.get_user_by_id(user_id)
text = msg['text']
fwd = self.vk_session.method("messages.getByConverstationMessageId", {"converstation_message_ids": msg["converstation_message_id"],
'peer_id':msg['peer_id']})
print(user_id, text, fwd)
if __name__ == '__main__':
VkBot().run()
ошибку выводит вот такую: Traceback (most recent call last):
File "D:\vkbot\main.py", line 36, in
VkBot().run()
File "D:\vkbot\main.py", line 21, in __init__
self.longpoll = MyLongPoll(self.vk_session, 218405889)
File "C:\Users\79122\AppData\Local\Programs\Python\Python310\lib\site-packages\vk_api\bot_longpoll.py", line 219, in __init__
self.update_longpoll_server()
File "C:\Users\79122\AppData\Local\Programs\Python\Python310\lib\site-packages\vk_api\bot_longpoll.py", line 232, in update_longpoll_server
response = self.vk.method('groups.getLongPollServer', values)
File "C:\Users\79122\AppData\Local\Programs\Python\Python310\lib\site-packages\vk_api\vk_api.py", line 697, in method
raise error
vk_api.exceptions.ApiError: [100] One of the parameters specified was missing or invalid: longpoll for this group is not enabled.
PS D:\vkbot>
(скопировал все, вдруг найдутся "знатоки")