Answer the question
In order to leave comments, you need to log in
Name vk_api python, how to get it?
Hello. I would like to ask for help. I want my auto-responder bot to respond to the name of the person who wrote to me. For example:
Some Anton, for example: Hello!
Bot: Hi Anton! ...
Answer the question
In order to leave comments, you need to log in
Lord, open the dock on the VK API and read - everything is written in Russian there.
The username can be obtained through from_id , which can be obtained from the object coming from VK. You make a request to the users.get method, where you specify from_id in the user_ids parameter . Then, from the response array , you get the first_name field , the name is stored there.
Sample Code
from_id = event.from_id # event - переменная прослушки запросов на ваш сервер от вк
resp = vk.method('users.get', {'user_ids': from_id}) # Запрос к вк апи
name = resp[0]['first_name'] # Получение имени
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question