I
I
Ivan Smorodin2020-05-03 15:56:03
Python
Ivan Smorodin, 2020-05-03 15:56:03

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

1 answer(s)
M
Miit, 2020-05-03
@Miit

Object event.objecthas no attributetext

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question