Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question