M
M
mikeshadow2022-04-09 12:24:25
Python
mikeshadow, 2022-04-09 12:24:25

How to catch a photo from a dialog and send it via VK API?

I need the bot to send it back when it receives a photo in PM. First I catch attachments, it comes in the form

{'attach1_type': 'photo', 'attach1': '224789790_457250860'}

I turn it into the format <type><owner_id>_<media_id>:
ids = '"'+event.attachments[attach1_type]+event.attachments[attach1]+'"'

And I send it back:
vk.method("messages.send", {"user_id": event.user_id, "message": event.message, "attachment": ids, "random_id": 0})

But in the end, only the sent message flies back, there are no errors in the console. Moreover, if I manually enter the id of the photo not from the message instead of ids, then the photo will be sent, but if I manually enter the id of the photo from the dialog, then nothing will work again.

As I understand it from access_key, but I can't find anywhere how to get it. Is there a way to get the access key, or is there a workaround?

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