B
B
BlackDog052019-08-27 23:58:45
Python
BlackDog05, 2019-08-27 23:58:45

How to get a value into a variable?

Hello, I would like to get the ID of the person of the message that was replied to,

if event.type == VkBotEventType.MESSAGE_NEW:
                peer_id = event.object.peer_id
                message = event.object.text
                reply_message = event.object.reply_message
                print(reply_message)
A photo
5d6597ca7ae8e188262928.jpeg
but when I specify from_id
if event.type == VkBotEventType.MESSAGE_NEW:
                peer_id = event.object.peer_id
                message = event.object.text
                reply_message = event.object.reply_message.from_id
                print(reply_message)
gives an error that the "from_id" object does not exist...
A photo
5d6598fee6487441306910.jpeg
How to do it, thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cunning-seal, 2019-09-05
@cunning-seal

I dare to suggest that you need to contact reply_message = event.object.reply_message.get("from_id")
In the error it says that event.object.reply_message is a dictionary (which is also visible in the output on the first screenshot), which means you need just use the key

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question