E
E
enotov322021-09-24 22:27:07
Python
enotov32, 2021-09-24 22:27:07

VK API on Python fields method, how to get the name?

614e246e5a001530662431.png
Library
Desirable code
But if I understand something like this will be?

while True:
    try:
        messages = vk.method("messages.getConversations", {"offset": 0, "count": 20, "filter": "unanswered"})
        if messages["count"] >= 1:
              name = messages["items"][0]["last_message"]["first_name"]
              body = messages["items"][0]["last_message"]["text"]
              if body.lower() in ["Начать", "начать"]:
                vk.method("messages.send", {"peer_id": id, "keyboard": keyboard,"message": f"Привет  {name}", "random_id": random.randint(1, 2147483647)})

But this structure does not work, tell me what's wrong

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question