Answer the question
In order to leave comments, you need to log in
Bot not sending message to conversation?
Hey Habr! I ran into a problem...
The bot simply does not work in a conversation, gave access to the correspondence, turned on longpoll, in the settings longpoll gave access to everything and silence...
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, "айди сообщества")
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.obj.text == 'тест':
if event.from_chat:
vk.messages.send(
random_id=get_random_id(),
peer_id=event.obj.peer_id,
message="Ну вроде бы работает")
Answer the question
In order to leave comments, you need to log in
He needs not only to give access to all correspondence, just like everyone else, not only by mentions, but also to make him an administrator. That's when it will work without mentioning it. I also came across this
UPD: for some reason, through a dot in new versions does not work.
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
m = event.object.message
if m["text"] == 'тест':
vk.messages.send(
random_id=get_random_id(),
peer_id=m["peer_id"],
message="Ну вроде бы работает")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question