From 4524b2bed9488b8be14a2afef89a92112812cd54 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Thu, 14 Dec 2017 12:39:12 +0500 Subject: [PATCH] :sparkles: Added GetUserProfilePhotos method --- get_user_profile_photos.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 get_user_profile_photos.go diff --git a/get_user_profile_photos.go b/get_user_profile_photos.go new file mode 100644 index 0000000..5c46554 --- /dev/null +++ b/get_user_profile_photos.go @@ -0,0 +1,29 @@ +package telegram + +import ( + "strconv" + + json "github.com/pquerna/ffjson/ffjson" + http "github.com/valyala/fasthttp" +) + +// GetUserProfilePhotos get a list of profile pictures for a user. Returns a UserProfilePhotos object. +func (bot *Bot) GetUserProfilePhotos(userID, offset, limit int) (*UserProfilePhotos, error) { + args := http.AcquireArgs() + defer http.ReleaseArgs(args) + args.Add("user_id", strconv.Itoa(userID)) + args.Add("offset", strconv.Itoa(offset)) + + if limit > 0 { + args.Add("limit", strconv.Itoa(limit)) + } + + resp, err := bot.request(nil, "getUserProfilePhotos", args) + if err != nil { + return nil, err + } + + var data UserProfilePhotos + err = json.Unmarshal(*resp.Result, &data) + return &data, err +}