N
N
ne_Sci_fi2019-12-04 16:56:06
Python
ne_Sci_fi, 2019-12-04 16:56:06

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

1 answer(s)
F
Febel, 2019-12-05
@Febel

Event.message.text?
VK here somehow updated the api and the old methods of messages basically no longer work. Check out the documentation and new features of messages

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question