I want to make a chat bot. In group messages, everything works correctly, and when adding to a conversation, even the messages do not see.

Import vk_api
Import Re.
From BS4 Import Beautifulsoup
Import Requests.
from vk_api import vkupload, vkapi
from vk_api.longpoll import vklongpoll, vkeventtype
From Random Import Randint
From BS4 Import Beautifulsoup
Import Requests.
vk= vkapi (token= token)
Upload= Vkupload (VK)
Session= Requests.session ()
LongPoll= VklongPoll (VK)
DEF WRITE_MSG (User_ID, Message):
    vk.method ('Messages.send', {'user_id': user_id, 'message': message, 'Random_id': Randint (1E16, 1E18)})
    vk.method ('Messages.send', {'Chat_id': Chat_id, 'Message': Message, 'Random_ID': Randint (1E16, 1E18)})
For event in longpoll.listen ():
    If event.Type== vkeventtype.message_new:
        If event.text== 'Hi':
            If event.to_me:
                write_msg (event.user_id, 'Hai')
                vk.messages.send (peer_id= event.obj.peer_id or event.message.peer_id, Message= 'Hai')
        Print (event.text)

Possible duplicate question: vkbotlongpoll ignores messages from the conversation

Михаил Муругов2021-07-22 11:40:58

@ Mikhailmurugov, the answers that were given in not in my question did not help

Maksim2021-07-22 11:40:58