S
S
sergeyfilippov42019-09-21 19:30:43
Python
sergeyfilippov4, 2019-09-21 19:30:43

Why does event.obj.user_id return None?

This code is not working, because event.object.user_id returns None.

for event in longpoll.listen():
    if event.type == VkBotEventType.MESSAGE_NEW:
        if event.from_chat:
            if event.object.text == '!tap':
                print(event.object.user_id)
                if admin(event.user_id) == True:
                    kick_id = vk.messages.getById(message_ids=event.message_id)['items'][0]['reply_message']['from_id']
                    vk.messages.send(chat_id=event.chat_id, message='[id%s|пока]'%kick_id, random_id=0)
                    vk.messages.removeChatUser(user_id=kick_id,chat_id=event.chat_id)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stockholm Syndrome, 2019-09-21
@sergeyfilippov4

message object has no user_id field, since version 5.80 you need from_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question