K
K
Kirill2021-08-19 14:55:50
API
Kirill, 2021-08-19 14:55:50

How to find out the last message sent to a specific user from a VK group?

Good afternoon.

It is necessary to implement the menu using callback buttons.

The principle is simple:
The user starts a chat with the bot. The community sends him a keyboard with the Callback button of a certain Payload. After pressing the Callback button, the bot edits the message and sends a new keyboard with Callback buttons. For this I need: peer_id and conversation_message_id. If I can get the peer_id from the message_event, then I can only get the conversation_message_id when the message itself is sent, and not when the callback button is pressed.

Question: How to track the last message sent to a specific user in the correspondence of the VK group from vkapi itself? Or do I need to remember peer_id and conversation_message_id on my own.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
RINAMI, 2021-08-19
@RINAMI

To get the conversation_message_id you just need to create a variable like:

conv = event.obj.message['conversation_message_id']

Peer_id in messages with a user: If you need to respond as you said to a specific user, then set a condition before:
per = event.object.message['from_id']
if event.from_user:
    id =  event.object.message['from_id']
    if id == 'айди пользователя'
    #Код

H
HemulGM, 2021-08-19
@HemulGM

If I can get the peer_id from the message_event, then I can get the conversation_message_id only when the message itself is sent, and not when the callback button is pressed.

Why is that? This structure comes https://vk.com/dev/objects/message . With conversation_message_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question