diff --git a/bot.go b/bot.go index fd1791f..961323d 100644 --- a/bot.go +++ b/bot.go @@ -769,6 +769,36 @@ func (b *Bot) GetChatMembersCount(recipient Recipient) (int, error) { return responseRecieved.Result, nil } +// Use this method to get a list of profile pictures for a user. +// +// Returns a UserProfilePhotos object. +func (b *Bot) GetUserProfilePhotos(recipient Recipient) (UserProfilePhotos, error) { + params := map[string]string{ + "user_id": recipient.Destination(), + } + responseJSON, err := sendCommand("getUserProfilePhotos", b.Token, params) + if err != nil { + return UserProfilePhotos{}, err + } + + var responseRecieved struct { + Ok bool + Result UserProfilePhotos + Description string `json:"description",omitempty` + } + + err = json.Unmarshal(responseJSON, &responseRecieved) + if err != nil { + return UserProfilePhotos{}, err + } + + if !responseRecieved.Ok { + return UserProfilePhotos{}, fmt.Errorf("telebot: getUserProfilePhotos failure %s", responseRecieved.Description) + } + + return responseRecieved.Result, nil +} + // Use this method to get information about a member of a chat. // // Returns a ChatMember object on success. diff --git a/types.go b/types.go index 890b990..67c9104 100644 --- a/types.go +++ b/types.go @@ -224,8 +224,18 @@ type MessageEntity struct { User User `json:"user",omitempty` } -// This object contains information about one member of the chat. +// This struct contains information about one member of the chat. type ChatMember struct { User User `json:"user"` Status string `json:"status"` } + +// This struct represent a user's profile pictures. +// +// Count : Total number of profile pictures the target user has +// +// Photos : Array of Array of PhotoSize , Requested profile pictures (in up to 4 sizes each) +type UserProfilePhotos struct { + Count int `json:"total_count"` + Photos [][]Photo `json:"photos"` +}