Answer the question
In order to leave comments, you need to log in
Why does event.object.text return None?
This problem arose when a message is sent in a conversation "bot" sees that it has arrived, but says
that the message text is empty, that is, it returns None. Point out the mistake please
import requests
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
from vk_api.utils import get_random_id
vk_session = vk_api.VkApi(token = 'my_token')
longpoll = VkBotLongPoll(vk_session, '189470911')
vk = vk_session.get_api()
variants = ["привет", "Привет"]
while True:
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW and event.from_chat:
print(event.object.text)
# выводит: None
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