1
0
telegram/set_chat_photo.go

37 lines
1.1 KiB
Go
Raw Normal View History

2017-12-13 14:00:09 +00:00
package telegram
import (
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
2018-04-19 13:02:15 +00:00
// SetChatPhotoParameters represents data for SetChatPhoto method.
type SetChatPhotoParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
ChatPhoto interface{} `json:"chat_photo"`
}
2017-12-13 14:00:09 +00:00
// SetChatPhoto set a new profile photo for the chat. Photos can't be changed for private chats. The
// bot must be an administrator in the chat for this to work and must have the appropriate admin
// rights. Returns True on success.
//
// Note: In regular groups (non-supergroups), this method will only work if the 'All Members Are
// Admins' setting is off in the target group.
2018-08-21 11:05:04 +00:00
func (bot *Bot) SetChatPhoto(chatID int64, chatPhoto interface{}) (ok bool, err error) {
2017-12-13 14:07:57 +00:00
args := http.AcquireArgs()
defer http.ReleaseArgs(args)
2017-12-13 14:00:09 +00:00
args.Add("chat_id", strconv.FormatInt(chatID, 10))
2018-04-12 11:58:05 +00:00
resp, err := bot.Upload(MethodSetChatPhoto, TypePhoto, "chat_photo", chatPhoto, args)
2017-12-13 14:00:09 +00:00
if err != nil {
2018-08-21 11:05:04 +00:00
return
2017-12-13 14:00:09 +00:00
}
2018-08-21 11:05:04 +00:00
err = json.Unmarshal(*resp.Result, &ok)
return
2017-12-13 14:00:09 +00:00
}