S
S
Snowdevil2021-06-25 19:51:45
Python
Snowdevil, 2021-06-25 19:51:45

TypeError: 'NoneType' object is not subscriptable. Where is the mistake?

import vk_api
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType

vk_session = vk_api.VkApi(token = '1adbd73f02bcfa805971facdaf130387d5df1a176dc37fdb07eff499999999909643e9c706c5f')
longpoll = VkBotLongPoll(vk_session, 999999999)

def sender(id, text):
    vk_session.method('messages.send', {'chat_id': id, 'message': text, 'random_id': 0})

def main():
    for event in longpoll.listen():
        if event.type == VkBotEventType.MESSAGE_NEW:
            if event.from_chat:

                id = event.chat_id
                msg = event.object.message['text'].lower()
                try:
                    dey = event.message.action['type']
                    invite_id = event.message.action['member_id']
                except:
                    dey = ""
                    invite_id = -100

                if dey == 'chat_invite_user' or dey == 'chat_invite_user_by_link':
                    sender(id, '8888')

                if msg == 'кик':
                    vk_session.method("messages.removeChatUser", {"chat_id": id, "member_id": event.object.reply_message['from_id']})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
slikkness, 2021-07-13
@slikkness

The error is in the way you specified member_id, so it will be correct like this:

"member_id": event.object.message['reply_message']['from_id']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question