P
P
pivazik2020-05-28 02:02:23
Python
pivazik, 2020-05-28 02:02:23

How to resolve KeyError: 'reply_message' error?

Hello, I'm getting a KeyError when I try to enter a command without specifying a forwarded message.
Specifically, from this command, I get the id of the user whose messages I or someone else marked.

if msg == "%айди":
    x = session_api.messages.getById(message_ids=event.message_id)
    reply = x["items"][0]["reply_message"]
    send_message(peer_id=event.peer_id,message="Айди - " + str(reply["from_id"]))

Here is the error in the console:
5ecef15c4d0bc833194455.png

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