steavy29 / Telegram.Net

Telegram (http://telegram.org) client library implemented in C#.
17 stars 6 forks source link

Подскажите пожалуйста, что такое from_id #4

Closed andrew-maksimov closed 8 years ago

andrew-maksimov commented 8 years ago

Помогите пожалуйста разобраться с структуре MessageConstructor.

В поле to_id - идентификатор пира отправителя сообщения. С этим всё понятно. Но вот в поле from_id - неизвестный номер, который я не знаю, как соотнести с получателем.

В результате, когда я получаю updates_Difference с отправленными мной же сообщениями, я не знаю, кому они были отправлены.

Например:

Я получаю следующий Message (message id:259 from_id:1590 to_id:188888888 out:False unread:False date:1474534709 message:'тестовое сообщение' media:(messageMediaEmpty)) 188888888 - это мой ID, так как это сообщение отправлял я. Но кому это сообщение было мной отправлено, я понять из этих данных не могу. Как мне соотнести с id'ом или from_id'ом идентификатор того пира, которому это сообщение предназначалось?

steavy29 commented 8 years ago

Hi. Here is link to the documentation regarding this: https://core.telegram.org/constructor/message So, from_id - id of one who send the message. In your case it is 1590. And this is your id(because you sent the message) to_id - id of the recipient. It can be either some user id or chat id. In your case(188888888) I think it's the latter. Does this make sense?

andrew-maksimov commented 8 years ago

How can I use from_id? How do I know peer sender?

to_id - Peer (I know who sent) from_id - int (I do not know who the recipient =( )

steavy29 commented 8 years ago

You can use GetUserFull method to load info about user. It accepts userId so you can pass from_id there.

andrew-maksimov commented 8 years ago

If I make a request GetUserFull for from_id then I get USER_ID_INVALID.

For GetUserFull needs Peer ID.

steavy29 commented 8 years ago

Ah, ok. I see. Can you write a small test and paste the code here(and description how to use it to reproduce your problem). I think at the moment api lacks some methods. And today or tomorrow I'll run it and implement all missing apis. What do you think?

andrew-maksimov commented 8 years ago

Yes. Now I do it.

andrew-maksimov commented 8 years ago

My PeerId: 281488817 I auth in Telegram from two client.

From first client I send someone a message.

In the second client comes the following message: (message id:257 from_id:1487 to_id:281488817 out:False unread:False date:1474377618 message:'test message' media:(messageMediaEmpty))

How do I find out who is the addressee of this message?

steavy29 commented 8 years ago

From first client I send someone a message. Is this someone in your contacts list?

andrew-maksimov commented 8 years ago

The first client I know whom I have sent a message. In the second - no.


(message id:257 from_id:1487 to_id:281488817 out:False unread:False date:1474377618 message:'test message' media:(messageMediaEmpty)) This message. He sent one person to another.

Peer the one who sent - 281488817. How do I know Peer to whom he sent it?

andrew-maksimov commented 8 years ago

Or so:

Somebody sends two messages to the two groups.

I received data: (message id:259 from_id:618 to_id:281488817 out:False unread:False date:1474990666 message:'This message was sent to the first group' media:(messageMediaEmpty)) (message id:259 from_id:619 to_id:281488817 out:False unread:False date:1474990690 message:'This message was sent to the second group' media:(messageMediaEmpty))

How do you know which group any of these messages?

steavy29 commented 8 years ago

Hey. Finally I think I found the problem. Message was deserialized incorrectly and fromId and toId were mixed and contained incorrect values. Now I'm fixing this. Will push fix today. Stay tuned :)

steavy29 commented 8 years ago

I've made changes. Please check new fields in Message constructors and how it behaves now.

andrew-maksimov commented 8 years ago

I can not check because of an error: Telegram.Net.Core.TelegramReqestException: MessageSeqNoTooLow

https://github.com/steavy29/Telegram.Net/issues/9