GetUserProfilePhotos added

pull/69/head
aiden 8 years ago
parent fc4d712ce0
commit 2558381794

@ -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.

@ -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"`
}

Loading…
Cancel
Save