Answer the question
In order to leave comments, you need to log in
Why do you write in a conversation and the bot replies in PM?
import vk_api
from vk_api.utils import get_random_id
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import requests
from vk_api.longpoll import VkEventType
vk_session = vk_api.VkApi(token="я чеченец")
vk = vk_session.get_api()
longpoll = VkBotLongPoll(vk_session, "186308067")
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.obj.text == 'ок':
if event.from_chat:
vk.messages.send(
user_id=event.obj.from_id,
random_id=get_random_id(),
chat_id=event.chat_id,
message="bruh")
if event.obj.text == 'кто':
if event.from_chat:
vk.messages.send(
user_id=event.obj.from_id,
random_id=get_random_id(),
chat_id=event.chat_id,
message="нет")
Answer the question
In order to leave comments, you need to log in
It is necessary to understand the difference between user_id and peer_id
user_id can also come from a conversation, this will indicate which person specifically wrote. And peer_id is the ID of the conversation. The dialogue can be with a person personally, then it will be user_id === peer_id, and it can be different when it is a conversation.
Always take peer_id, always send messages to peer_id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question