A
A
Artem00712019-07-07 12:53:12
In contact with
Artem0071, 2019-07-07 12:53:12

What is peer_id?

I can’t understand what kind of animal this peer_id is.
I made a test group, send a message from it to the bot and receive the following message object:

"date": 1562492622,
"from_id": -18191****, // собственно группа от имени которой отправил сообщение
"out": 1,
"peer_id": 1375****, // тот кому отправил
"text": "hi there",

Everything is logical here, but as soon as the user sends a message to the group, then peer_id === from_id
"date": 1562492617,
"from_id": 1375****, // Тот кто отправил
"out": 0,
"peer_id": 1375****, // ШТА???
"text": "hi",

Is this a bug or a feature?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita, 2019-07-07
@fwervbyberstvrstrf

peer_id is the general id of some object, it can be a conversation, a user and a community.
For example
peer_id = 1234567 is the user id
peer_id = -1234567 is the community id (all community ids are negative only)
peer_id = 2001234567 is the chat id (all chat ids start from 2000000000)

A
AlerX, 2019-07-07
@AlerX

peer_id = in other words, the dialogue where the message was sent from, if the message was sent to the bot's PM it will be == from_id, if in a conversation then peer_id != from_id because the conversation has a completely different identifier.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question