Answer the question
In order to leave comments, you need to log in
Why doesn't the bot receive messages from the VKontakte conversation?
The VK bot sees messages sent to it via PM (and returns a message with the same text), but does not respond to messages in the conversation (even print (event) does not detect). I found a similar question, the answer says that messages should be addressed to him , but I still don’t understand what this means. Works through BotsLongPoll. What's wrong?
session = TokenSession(access_token = 'token')
api = API(session)
lp = longpoll.BotsLongPoll(api, mode=2, group_id=group_id)
async def main():
try:
event = await lp.wait()
except asyncio.TimeoutError:
pass
else:
if event['updates'] != []:
if event['updates'][0]['type'] == 'message_new':
await api.messages.send(
user_id=event['updates'][0]['object']['user_id'],
random_id=int(time.time()*10000),
message=event['updates'][0]['object']['body'])
asyncio.get_event_loop().create_task(main())
loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever()
Answer the question
In order to leave comments, you need to log in
Oh yo, everything turned out to be much easier. I used version LongPoll 5.50 - put 5.101 and everything comes as it should. Thanks to all)
if event['updates'][0]['type'] == 'message_new':
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question