Ошибка:
Traceback (most recent call last):
File "...", line 6, in <module>
from vk_api.longpoll import VkLongPol, VkEventType
ImportError: cannot import name 'VkLongPol' from 'vk_api.longpoll'
Код:
import random
import vk_api
vk_session = vk_api.VkApi(token = '...')
from vk_api.longpoll import VkLongPol, VkEventType
longpoll = VkLongPol(vk_session)
vk = vk_session.get_api()
global Random
def random_id():
Random = 0
Random += random.randint(0, 10000000)
return Random
while true:
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW and event.to_me:
if event.text.lower() == 'привет':
vk.messeg.send(
user_id = event.user_id,
message = 'Привет!',
random_id = random_id()
)