Vk_api Error 917. Bot can't send messages, all his rights are granted.



  • I'm learning how to write beans to talk to Vontact.

    vk_session = vk_api.VkApi(token='мой токен')
    longpoll = VkBotLongPoll(vk_session, 'id группы')
    vk = vk_session.get_api()
    Lslongpoll = VkLongPoll(vk_session)
    Lsvk = vk_session.get_api()
    vk.messages.send(chat_id='424', message='Сообщение', random_id=get_random_id())
    

    I'm making such a mistake:

    vk_api.exceptions.ApiError: [917] You don't have access to this chat
    

    There's access to the message history, the rights of the administrator, too. What's the matter?



  • chat_id You and your bot have the same conversation! They are relevant for each user/bot.

    To find out. chat_id I need a list. https://vk.com/dev/messages.getConversations and in all conversations, find necessary and record id

    print(vk.messages.getConversations()['items'])
    

    We can go through this list. https://vk.com/dev/objects/conversation and find necessary, for example, by name. It depends on your needs.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2