T
T
TupaBan Dev2020-10-29 22:59:26
Python
TupaBan Dev, 2020-10-29 22:59:26

Where is the mistake? NameError: name 'VkLongPoll' is not definedr?

Error:
NameError: name 'VkLongPoll' is not

defined

import requests
import vk_api

vk_session = vk_api.VkApi(token='big yellow Cocks')

longpoll = VkLongPoll(vk_session)
vk = vk_session.get_api()
for event in longpoll.listen():
    if event.type == VkEventType.MESSAGE_NEW and event.to_me and event.text:
        if event.text == 'Первый вариант фразы' or event.text == 'Второй вариант фразы': #Если написали заданную фразу
            if event.from_user: #Если написали в ЛС
                vk.messages.send( #Отправляем сообщение
                    user_id=event.user_id,
                    message='Ваш текст'
    )
            elif event.from_chat: #Если написали в Беседе
                vk.messages.send( #Отправляем собщение
                    chat_id=event.chat_id,
                    message='Ваш текст'
    )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sswwssww, 2020-10-29
@TupaBan

Here it is,
longpoll = VkLongPoll(vk_session)
replace with this:
longpoll_ = vk_api.longpoll.VkLongPoll(vk_session)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question