line 23, in
for event in longpoll.listen():
TypeError: listen() missing 1 required positional argument: 'self'
import random
import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
# --
from vk_bot import VkBot
# --
def write_msg(user_id, message):
vk.method('messages.send', {'user_id': user_id, 'message': message, 'random_id': random.randint(0, 2048)})
# API-ключ созданный ранее
token = "не скажу"
# Работа с сообщениями
longpoll = VkLongPoll
print("Server started")
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW:
if event.to_me:
print(f'New message from {event.user_id}', end='')
bot = VkBot(event.user_id)
if event.text[0] == "/":
write_msg(event.user_id, commander.do(event.text[1::]))
else:
write_msg(event.user_id, bot.new_message(event.text))
print('Text: ', event.text)
print("-------------------")
vks = vk_api.VkApi(token='токен')
longpoll = VkLongPoll(vks)
session = vk.Session(access_token = 'токен')
vk= vk.API(session, v = "5.95")