F
F
fodiche2021-04-29 21:15:43
Python
fodiche, 2021-04-29 21:15:43

How to get the id of the person who sent the message vk api?

the task is that as soon as the user sends a message to the conversation (to which the bot will respond), we get his user_id so that we can work with him in the future

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iris_duty_2020, 2021-04-30
@fodich

hmm........ it's simple.
vk.api.messages.getConversationMembers({ peer_id: message.peerId, fields: "id", group_id: group_id}).then(function(response){
let c = response;
c.items.map(function(c){
if(c.member_id < 1) return;
vk.api.call('users.get', {
user_ids: c.member_id,
fields: "photo_max,city,verified,status,domain,photo_id,sex,last_seen,first_name"
}).then(res => {
let user = res[0];
Thus, later, we can write the user ID to the database like this:
id: c.member_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question