Closed Skyforces closed 6 years ago
@Skyforces Thanks for your interest in my code. You can get user hashes using ContactsGetContacts. It also needs a hash, but you can just assign 0 to it as below.
caller.ContactsGetContacts(context.Background(), &mtproto.ReqContactsGetContacts{})
I added this example to examples/simpleshell as 'contacts' command.
Thanks for your quick reply. With your example i get all my contacts and the access hashs. It works fine but im missing Bots and foreign users, which aren't in my contact list. Maybe i understand the getUser function wrong?
@Skyforces I think
caller.MessagesGetAllChats(context.Background(), &mtproto.ReqMessagesGetAllChats{})
would work for that. It returns id and hash list of all the chats and channels.
It works quite good so far. Still have some question, sorry i didn't clarified them. What is the function of MessageGetChats
and UsersGetUsers
? I thought you can get a specific User/Chat/Channel with them based on ID. Like this:
ids := []int32{u.(*mtproto.PredUpdateShortMessage).UserId} chats, _ := caller.MessagesGetChats(context.Background(), &mtproto.ReqMessagesGetChats{ Id: ids, })
Second is about the implementation of the InputUser. There are too different types, inputUserContact
and inputUserForeign
. One with access hash and one without. How is this implemented in your api?
@Skyforces MessagesGetChats() needs a chat or channel ID, not an user ID. MessagesGetAllChats() returns TypeMessagesChats, which would be one of PredMessagesChats and PredMessagesChatsSlice. The both have an array of TypeChat. TypeChat is one of PredChat, PredChannel, ... . PredChat and PredChannel have an id, and you can use it for MessagesGetChats().
Now InputUser has no types of inputUserContact and inputUserForeign. Telegram's mtproto document is too old, so you should refer to the protocol definition in this protobuf file; Telegram's document version is layer 23, the latest one is layer 81, and mine is 71.
Okay, I undestand this now. You pushed me to the right point. Thank you! Keep on your good work!
Hey! I like to get the full information about an user (from my contacts or not) if he writes me a message. So on
PredUpdateShortMessage
, i try to call theUsersGetUsers
but i need an AccessHash i didnt have. how do i get it? Here is my code: `case *mtproto.PredUpdateShortMessage: