Answer the question
In order to leave comments, you need to log in
Why does this error occur?
AttributeError: 'NoneType' object has no attribute 'lower'
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import vk_api
import random
vk = vk_api.VkApi(token="528a1314d9b963564dsf6vd4dfvd464dvb5r5555885ee6e6e6d3ca57b54115e1")
vk._auth_token()
vk.get_api()
longpoll = VkBotLongPoll(vk, "195455515")
#while True:
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.object.peer_id != event.object.from_id:
if event.object.text.lower() == 'Привет':
vk.method("messages.send", {"peer_id": event.object.peer_id, "message": event.object.text,
"random_id": random.randint(1, 2147483647)})
elif event.object.peer_id == event.object.from_id:
if event.object.text.lower() == 'Привет':
vk.method("messages.send", {"user_id": event.object.from_id, "message": event.object.text,
"random_id": random.randint(1, 2147483647)})
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