W
W
WolfInChains2020-05-26 12:46:48
Python
WolfInChains, 2020-05-26 12:46:48

TypeError("'Event' object is not subscriptable") how to fix?

while True:
    try:
        for event in longpoll.listen():
            if event.type == VkEventType.MESSAGE_NEW:
                if event.from_chat:
                    text = event["text"].split(' ')
                    if text[0] == "Вернуть" or text[0] == "вернуть":
                        s = text[1]
                        parts = s.rsplit('com/', 1)
                        res = parts[1]
                        print(res)
                        user_id1 = vk.users.get(
                            user_id=res
                        )['id']
                        vk.messages.addChatUser(
                            chat_id=event.chat_id,
                            user_id=user_id1,
                        )
    except Exception as e:
        print(repr(e))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2020-05-26
@WolfInChains

text = event.text.split(' ')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question