From 7b3b2101cac9b5ab7033f4925df271cba02601e0 Mon Sep 17 00:00:00 2001 From: MamaD Date: Thu, 8 Jun 2023 00:38:24 +0330 Subject: [PATCH] API 6.7 --- admin.go | 52 +++++++++++++++++++--------- admin_test.go | 1 - bot.go | 2 +- bot_data.go | 91 +++++++++++++++++++++++++++++++++++++++++++++++++ chat.go | 5 +++ inline.go | 15 ++++---- inline_types.go | 38 ++++++++++----------- markup.go | 23 ++++++++++--- media.go | 15 ++++---- message.go | 3 ++ sendable.go | 3 +- share.go | 27 +++++++++++++++ stickers.go | 68 +++++++++++++++++++----------------- 13 files changed, 252 insertions(+), 91 deletions(-) diff --git a/admin.go b/admin.go index b1b7de9..c0b0292 100644 --- a/admin.go +++ b/admin.go @@ -11,17 +11,24 @@ type Rights struct { // Anonymous is true, if the user's presence in the chat is hidden. Anonymous bool `json:"is_anonymous"` - CanBeEdited bool `json:"can_be_edited"` - CanChangeInfo bool `json:"can_change_info"` - CanPostMessages bool `json:"can_post_messages"` - CanEditMessages bool `json:"can_edit_messages"` - CanDeleteMessages bool `json:"can_delete_messages"` - CanPinMessages bool `json:"can_pin_messages"` - CanInviteUsers bool `json:"can_invite_users"` - CanRestrictMembers bool `json:"can_restrict_members"` - CanPromoteMembers bool `json:"can_promote_members"` - CanSendMessages bool `json:"can_send_messages"` - CanSendMedia bool `json:"can_send_media_messages"` + CanBeEdited bool `json:"can_be_edited"` + CanChangeInfo bool `json:"can_change_info"` + CanPostMessages bool `json:"can_post_messages"` + CanEditMessages bool `json:"can_edit_messages"` + CanDeleteMessages bool `json:"can_delete_messages"` + CanPinMessages bool `json:"can_pin_messages"` + CanInviteUsers bool `json:"can_invite_users"` + CanRestrictMembers bool `json:"can_restrict_members"` + CanPromoteMembers bool `json:"can_promote_members"` + CanSendMessages bool `json:"can_send_messages"` + + CanSendAudios bool `json:"can_send_audios"` + CanSendDocuments bool `json:"can_send_documents"` + CanSendPhotos bool `json:"can_send_photos"` + CanSendVideos bool `json:"can_send_videos"` + CanSendVideoNotes bool `json:"can_send_video_notes"` + CanSendVoiceNotes bool `json:"can_send_voice_notes"` + CanSendPolls bool `json:"can_send_polls"` CanSendOther bool `json:"can_send_other_messages"` CanAddPreviews bool `json:"can_add_web_page_previews"` @@ -50,7 +57,12 @@ func NoRestrictions() Rights { CanPinMessages: false, CanPromoteMembers: false, CanSendMessages: true, - CanSendMedia: true, + CanSendAudios: true, + CanSendDocuments: true, + CanSendPhotos: true, + CanSendVideos: true, + CanSendVideoNotes: true, + CanSendVoiceNotes: true, CanSendPolls: true, CanSendOther: true, CanAddPreviews: true, @@ -72,7 +84,12 @@ func AdminRights() Rights { CanPinMessages: true, CanPromoteMembers: true, CanSendMessages: true, - CanSendMedia: true, + CanSendAudios: true, + CanSendDocuments: true, + CanSendPhotos: true, + CanSendVideos: true, + CanSendVideoNotes: true, + CanSendVoiceNotes: true, CanSendPolls: true, CanSendOther: true, CanAddPreviews: true, @@ -124,13 +141,14 @@ func (b *Bot) Unban(chat *Chat, user *User, forBanned ...bool) error { // - can send media // - can send other // - can add web page previews -func (b *Bot) Restrict(chat *Chat, member *ChatMember) error { +func (b *Bot) Restrict(chat *Chat, member *ChatMember, useIndependentChatPermissions bool) error { prv, until := member.Rights, member.RestrictedUntil params := map[string]interface{}{ - "chat_id": chat.Recipient(), - "user_id": member.User.Recipient(), - "until_date": strconv.FormatInt(until, 10), + "chat_id": chat.Recipient(), + "user_id": member.User.Recipient(), + "until_date": strconv.FormatInt(until, 10), + "use_independent_chat_permissions": useIndependentChatPermissions, } embedRights(params, prv) diff --git a/admin_test.go b/admin_test.go index 5fd2412..805a2ba 100644 --- a/admin_test.go +++ b/admin_test.go @@ -20,7 +20,6 @@ func TestEmbedRights(t *testing.T) { "user_id": "2", "can_be_edited": true, "can_send_messages": true, - "can_send_media_messages": true, "can_send_polls": true, "can_send_other_messages": true, "can_add_web_page_previews": true, diff --git a/bot.go b/bot.go index 8cf0610..6201c97 100644 --- a/bot.go +++ b/bot.go @@ -577,7 +577,7 @@ func (b *Bot) EditMedia(msg Editable, media Inputtable, opts ...interface{}) (*M files = make(map[string]File) thumb *Photo - thumbName = "thumb" + thumbName = "thumbnail" ) switch { diff --git a/bot_data.go b/bot_data.go index 6812348..0754a36 100644 --- a/bot_data.go +++ b/bot_data.go @@ -1 +1,92 @@ package telebot + +import "encoding/json" + +func (b *Bot) SetMyDescription(description, languageCode string) error { + _, err := b.Raw("setMyCommands", map[string]interface{}{ + "description": description, + "language_code": languageCode, + }) + return err +} + +type BotDescription struct { + Description string `json:"description"` +} + +func (b *Bot) GetMyDescription(languageCode string) (*BotDescription, error) { + params := map[string]string{ + "language_code": languageCode, + } + + data, err := b.Raw("getMyCommands", params) + if err != nil { + return nil, err + } + + var resp struct { + Result BotDescription + } + if err := json.Unmarshal(data, &resp); err != nil { + return nil, wrapError(err) + } + return &resp.Result, nil +} + +func (b *Bot) SetMyShortDescription(shortDescription, languageCode string) error { + _, err := b.Raw("setMyShortDescription", map[string]interface{}{ + "short_description": shortDescription, + "language_code": languageCode, + }) + return err +} + +type BotShortDescription struct { + ShortDescription string `json:"short_description"` +} + +func (b *Bot) GetMyShortDescription(languageCode string) (*BotShortDescription, error) { + data, err := b.Raw("getMyCommands", map[string]string{ + "language_code": languageCode, + }) + if err != nil { + return nil, err + } + + var resp struct { + Result BotShortDescription + } + if err := json.Unmarshal(data, &resp); err != nil { + return nil, wrapError(err) + } + return &resp.Result, nil +} + +func (b *Bot) SetMyName(name, languageCode string) error { + _, err := b.Raw("setMyName", map[string]interface{}{ + "name": name, + "language_code": languageCode, + }) + return err +} + +type BotName struct { + Name string `json:"name"` +} + +func (b *Bot) GetMyName(languageCode string) (*BotName, error) { + data, err := b.Raw("getMyCommands", map[string]string{ + "language_code": languageCode, + }) + if err != nil { + return nil, err + } + + var resp struct { + Result BotName + } + if err := json.Unmarshal(data, &resp); err != nil { + return nil, wrapError(err) + } + return &resp.Result, nil +} diff --git a/chat.go b/chat.go index 77de6c0..47bc331 100644 --- a/chat.go +++ b/chat.go @@ -154,6 +154,8 @@ type ChatMemberUpdate struct { // (Optional) InviteLink which was used by the user to // join the chat; for joining by invite link events only. InviteLink *ChatInviteLink `json:"invite_link"` + + ViaChatFolderInviteLink bool `json:"via_chat_folder_invite_link,omitempty"` } // Time returns the moment of the change in local time. @@ -199,6 +201,9 @@ type ChatJoinRequest struct { // InviteLink is the chat invite link that was used by //the user to send the join request, optional. InviteLink *ChatInviteLink `json:"invite_link"` + + // Identifier of a private chat with the user who sent the join request. + UserChatID int64 `json:"user_chat_id"` } // ChatInviteLink object represents an invite for a chat. diff --git a/inline.go b/inline.go index b369139..44fb841 100644 --- a/inline.go +++ b/inline.go @@ -53,14 +53,7 @@ type QueryResponse struct { // pagination. Offset length can’t exceed 64 bytes. NextOffset string `json:"next_offset"` - // (Optional) If passed, clients will display a button with specified - // text that switches the user to a private chat with the bot and sends - // the bot a start message with the parameter switch_pm_parameter. - SwitchPMText string `json:"switch_pm_text,omitempty"` - - // (Optional) Parameter for the start message sent to the bot when user - // presses the switch button. - SwitchPMParameter string `json:"switch_pm_parameter,omitempty"` + Button *InlineQueryResultsButton `json:"button,omitempty"` } // InlineResult represents a result of an inline query that was chosen @@ -137,3 +130,9 @@ func inferIQR(result Result) error { return nil } + +type InlineQueryResultsButton struct { + Text string `json:"text"` + WebApp *WebApp `json:"web_app,omitempty"` + StartParameter string `json:"start_parameter,omitempty"` +} diff --git a/inline_types.go b/inline_types.go index d93cffc..e920585 100644 --- a/inline_types.go +++ b/inline_types.go @@ -81,13 +81,13 @@ type ArticleResult struct { Description string `json:"description,omitempty"` // Optional. URL of the thumbnail for the result. - ThumbURL string `json:"thumb_url,omitempty"` + ThumbURL string `json:"thumbnail_url,omitempty"` // Optional. Width of the thumbnail for the result. - ThumbWidth int `json:"thumb_width,omitempty"` + ThumbWidth int `json:"thumbnail_width,omitempty"` // Optional. Height of the thumbnail for the result. - ThumbHeight int `json:"thumb_height,omitempty"` + ThumbHeight int `json:"thumbnail_height,omitempty"` } // AudioResult represents a link to an mp3 audio file. @@ -130,13 +130,13 @@ type ContactResult struct { LastName string `json:"last_name,omitempty"` // Optional. URL of the thumbnail for the result. - ThumbURL string `json:"thumb_url,omitempty"` + ThumbURL string `json:"thumbnail_url,omitempty"` // Optional. Width of the thumbnail for the result. - ThumbWidth int `json:"thumb_width,omitempty"` + ThumbWidth int `json:"thumbnail_width,omitempty"` // Optional. Height of the thumbnail for the result. - ThumbHeight int `json:"thumb_height,omitempty"` + ThumbHeight int `json:"thumbnail_height,omitempty"` } // DocumentResult represents a link to a file. @@ -160,13 +160,13 @@ type DocumentResult struct { Description string `json:"description,omitempty"` // Optional. URL of the thumbnail (jpeg only) for the file. - ThumbURL string `json:"thumb_url,omitempty"` + ThumbURL string `json:"thumbnail_url,omitempty"` // Optional. Width of the thumbnail for the result. - ThumbWidth int `json:"thumb_width,omitempty"` + ThumbWidth int `json:"thumbnail_width,omitempty"` // Optional. Height of the thumbnail for the result. - ThumbHeight int `json:"thumb_height,omitempty"` + ThumbHeight int `json:"thumbnail_height,omitempty"` // If Cache != "", it'll be used instead Cache string `json:"document_file_id,omitempty"` @@ -189,11 +189,11 @@ type GifResult struct { Duration int `json:"gif_duration,omitempty"` // URL of the static thumbnail for the result (jpeg or gif). - ThumbURL string `json:"thumb_url"` + ThumbURL string `json:"thumbnail_url"` // Optional. MIME type of the thumbnail, must be one of // “image/jpeg”, “image/gif”, or “video/mp4”. - ThumbMIME string `json:"thumb_mime_type,omitempty"` + ThumbMIME string `json:"thumbnail_mime_type,omitempty"` // Optional. Title for the result. Title string `json:"title,omitempty"` @@ -215,7 +215,7 @@ type LocationResult struct { Title string `json:"title"` // Optional. Url of the thumbnail for the result. - ThumbURL string `json:"thumb_url,omitempty"` + ThumbURL string `json:"thumbnail_url,omitempty"` } // Mpeg4GifResult represents a link to a video animation @@ -236,11 +236,11 @@ type Mpeg4GifResult struct { Duration int `json:"mpeg4_duration,omitempty"` // URL of the static thumbnail (jpeg or gif) for the result. - ThumbURL string `json:"thumb_url,omitempty"` + ThumbURL string `json:"thumbnail_url,omitempty"` // Optional. MIME type of the thumbnail, must be one of // “image/jpeg”, “image/gif”, or “video/mp4”. - ThumbMIME string `json:"thumb_mime_type,omitempty"` + ThumbMIME string `json:"thumbnail_mime_type,omitempty"` // Optional. Title for the result. Title string `json:"title,omitempty"` @@ -276,7 +276,7 @@ type PhotoResult struct { Caption string `json:"caption,omitempty"` // URL of the thumbnail for the photo. - ThumbURL string `json:"thumb_url"` + ThumbURL string `json:"thumbnail_url"` // If Cache != "", it'll be used instead Cache string `json:"photo_file_id,omitempty"` @@ -298,13 +298,13 @@ type VenueResult struct { FoursquareID string `json:"foursquare_id,omitempty"` // Optional. URL of the thumbnail for the result. - ThumbURL string `json:"thumb_url,omitempty"` + ThumbURL string `json:"thumbnail_url,omitempty"` // Optional. Width of the thumbnail for the result. - ThumbWidth int `json:"thumb_width,omitempty"` + ThumbWidth int `json:"thumbnail_width,omitempty"` // Optional. Height of the thumbnail for the result. - ThumbHeight int `json:"thumb_height,omitempty"` + ThumbHeight int `json:"thumbnail_height,omitempty"` } // VideoResult represents a link to a page containing an embedded @@ -319,7 +319,7 @@ type VideoResult struct { MIME string `json:"mime_type"` // URL of the thumbnail (jpeg only) for the video. - ThumbURL string `json:"thumb_url"` + ThumbURL string `json:"thumbnail_url"` // Title for the result. Title string `json:"title"` diff --git a/markup.go b/markup.go index cb5edea..33e4729 100644 --- a/markup.go +++ b/markup.go @@ -206,10 +206,12 @@ func (r *ReplyMarkup) WebApp(text string, app *WebApp) Btn { type ReplyButton struct { Text string `json:"text"` - Contact bool `json:"request_contact,omitempty"` - Location bool `json:"request_location,omitempty"` - Poll PollType `json:"request_poll,omitempty"` - WebApp *WebApp `json:"web_app,omitempty"` + Contact bool `json:"request_contact,omitempty"` + Location bool `json:"request_location,omitempty"` + Poll PollType `json:"request_poll,omitempty"` + WebApp *WebApp `json:"web_app,omitempty"` + RequestUser bool `json:"request_user_phone_number,omitempty"` + RequestChat bool `json:"request_user_location,omitempty"` } // MarshalJSON implements json.Marshaler. It allows passing PollType as a @@ -222,6 +224,14 @@ func (pt PollType) MarshalJSON() ([]byte, error) { }) } +type SwitchInlineQueryChosenChat struct { + Query string `json:"query"` + AllowUserChats bool `json:"allow_user_chats"` + AllowBotChats bool `json:"allow_bot_chats"` + AllowGroupChats bool `json:"allow_group_chats"` + AllowChannelChats bool `json:"allow_channel_chats"` +} + // InlineButton represents a button displayed in the message. type InlineButton struct { // Unique slagish name for this kind of button, @@ -237,6 +247,11 @@ type InlineButton struct { InlineQueryChat string `json:"switch_inline_query_current_chat"` Login *Login `json:"login_url,omitempty"` WebApp *WebApp `json:"web_app,omitempty"` + + RequestUser bool `json:"request_user_phone_number,omitempty"` + RequestChat bool `json:"request_user_location,omitempty"` + + SwitchInlineQueryChosenChat *SwitchInlineQueryChosenChat `json:"switch_inline_query_chosen_chat,omitempty"` } // MarshalJSON implements json.Marshaler interface. diff --git a/media.go b/media.go index ca31e26..aabb602 100644 --- a/media.go +++ b/media.go @@ -19,7 +19,7 @@ type InputMedia struct { Type string `json:"type"` Media string `json:"media"` Caption string `json:"caption"` - Thumbnail string `json:"thumb,omitempty"` + Thumbnail string `json:"thumbnail,omitempty"` ParseMode string `json:"parse_mode,omitempty"` Entities Entities `json:"caption_entities,omitempty"` HasSpoiler bool `json:"has_spoiler,omitempty"` @@ -113,7 +113,7 @@ type Audio struct { // (Optional) Caption string `json:"caption,omitempty"` - Thumbnail *Photo `json:"thumb,omitempty"` + Thumbnail *Photo `json:"thumbnail,omitempty"` Title string `json:"title,omitempty"` Performer string `json:"performer,omitempty"` MIME string `json:"mime_type,omitempty"` @@ -145,7 +145,7 @@ type Document struct { File // (Optional) - Thumbnail *Photo `json:"thumb,omitempty"` + Thumbnail *Photo `json:"thumbnail,omitempty"` Caption string `json:"caption,omitempty"` MIME string `json:"mime_type"` FileName string `json:"file_name,omitempty"` @@ -179,7 +179,7 @@ type Video struct { // (Optional) Caption string `json:"caption,omitempty"` - Thumbnail *Photo `json:"thumb,omitempty"` + Thumbnail *Photo `json:"thumbnail,omitempty"` Streaming bool `json:"supports_streaming,omitempty"` MIME string `json:"mime_type,omitempty"` FileName string `json:"file_name,omitempty"` @@ -215,7 +215,7 @@ type Animation struct { // (Optional) Caption string `json:"caption,omitempty"` - Thumbnail *Photo `json:"thumb,omitempty"` + Thumbnail *Photo `json:"thumbnail,omitempty"` MIME string `json:"mime_type,omitempty"` FileName string `json:"file_name,omitempty"` } @@ -265,7 +265,7 @@ type VideoNote struct { Duration int `json:"duration"` // (Optional) - Thumbnail *Photo `json:"thumb,omitempty"` + Thumbnail *Photo `json:"thumbnail,omitempty"` Length int `json:"length,omitempty"` } @@ -284,11 +284,12 @@ type Sticker struct { Height int `json:"height"` Animated bool `json:"is_animated"` Video bool `json:"is_video"` - Thumbnail *Photo `json:"thumb"` + Thumbnail *Photo `json:"thumbnail"` Emoji string `json:"emoji"` SetName string `json:"set_name"` MaskPosition *MaskPosition `json:"mask_position"` PremiumAnimation *File `json:"premium_animation"` + NeedsRepainting bool `json:"needs_repainting"` } func (s *Sticker) MediaType() string { diff --git a/message.go b/message.go index 55a0d9e..b9eb395 100644 --- a/message.go +++ b/message.go @@ -260,6 +260,9 @@ type Message struct { GeneralForumTopicUnhidden *GeneralForumTopicUnhidden `json:"general_forum_topic_unhidden,omitempty"` WriteAccessAllowed *WriteAccessAllowed `json:"write_access_allowed,omitempty"` + UserShared *UserShared `json:"user_shared,omitempty"` + ChatShared *ChatShared `json:"chat_shared,omitempty"` + // For a service message, represents about a change in auto-delete timer settings. AutoDeleteTimer *AutoDeleteTimer `json:"message_auto_delete_timer_changed,omitempty"` diff --git a/sendable.go b/sendable.go index 2e782e3..add29d7 100644 --- a/sendable.go +++ b/sendable.go @@ -18,7 +18,6 @@ type Recipient interface { // This is pretty cool, since it lets bots implement // custom Sendables for complex kind of media or // chat objects spanning across multiple messages. -// type Sendable interface { Send(*Bot, Recipient, *SendOptions) (*Message, error) } @@ -402,7 +401,7 @@ func (g *Game) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) { func thumbnailToFilemap(thumb *Photo) map[string]File { if thumb != nil { - return map[string]File{"thumb": thumb.File} + return map[string]File{"thumbnail": thumb.File} } return nil } diff --git a/share.go b/share.go index 6812348..0e40801 100644 --- a/share.go +++ b/share.go @@ -1 +1,28 @@ package telebot + +type KeyboardButtonRequestUser struct { + RequestID string `json:"request_id"` + UserIsBot bool `json:"user_is_bot,omitempty"` + UserIsPremium bool `json:"user_is_premium,omitempty"` +} + +type KeyboardButtonRequestChat struct { + RequestID string `json:"request_id"` + ChatIsChannel bool `json:"chat_is_channel,omitempty"` + ChatIsForum bool `json:"chat_is_forum,omitempty"` + ChatHasUsername bool `json:"chat_has_username,omitempty"` + ChatIsCreated bool `json:"chat_is_created,omitempty"` + UserAdministratorRights *Rights `json:"user_administrator_rights,omitempty"` + BotAdministratorRights *Rights `json:"bot_administrator_rights,omitempty"` + BotIsMember bool `json:"bot_is_member,omitempty"` +} + +type UserShared struct { + ID int `json:"request_id"` + UserID int64 `json:"user_id"` +} + +type ChatShared struct { + ID int `json:"request_id"` + ChatID int64 `json:"chat_id"` +} diff --git a/stickers.go b/stickers.go index 3e0a626..db66527 100644 --- a/stickers.go +++ b/stickers.go @@ -8,9 +8,9 @@ import ( type StickerSetType = string const ( - StickerRegular = "regular" - StickerMask = "mask" - StickerCustomEmoji = "custom_emoji" + StickerRegular StickerSetType = "regular" + StickerMask StickerSetType = "mask" + StickerCustomEmoji StickerSetType = "custom_emoji" ) // StickerSet represents a sticker set. @@ -21,7 +21,7 @@ type StickerSet struct { Animated bool `json:"is_animated"` Video bool `json:"is_video"` Stickers []Sticker `json:"stickers"` - Thumbnail *Photo `json:"thumb"` + Thumbnail *Photo `json:"thumbnail"` PNG *File `json:"png_sticker"` TGS *File `json:"tgs_sticker"` WebM *File `json:"webm_sticker"` @@ -50,12 +50,13 @@ const ( ) // UploadSticker uploads a PNG file with a sticker for later use. -func (b *Bot) UploadSticker(to Recipient, png *File) (*File, error) { +func (b *Bot) UploadSticker(to Recipient, png *File, emoji string) (*File, error) { files := map[string]File{ "png_sticker": *png, } params := map[string]string{ "user_id": to.Recipient(), + "emoji": emoji, } data, err := b.sendFiles("uploadStickerFile", files, params) @@ -89,7 +90,18 @@ func (b *Bot) StickerSet(name string) (*StickerSet, error) { } // CreateStickerSet creates a new sticker set. +// todo: https://core.telegram.org/bots/api#createnewstickerset +// update to the new version func (b *Bot) CreateStickerSet(to Recipient, s StickerSet) error { + params := map[string]string{ + "user_id": to.Recipient(), + "sticker_type": s.Type, + "name": s.Name, + "title": s.Title, + "contains_masks": strconv.FormatBool(s.ContainsMasks), + "needs_repainting": strconv.FormatBool(s.Type == StickerCustomEmoji), + } + files := make(map[string]File) if s.PNG != nil { files["png_sticker"] = *s.PNG @@ -100,16 +112,6 @@ func (b *Bot) CreateStickerSet(to Recipient, s StickerSet) error { if s.WebM != nil { files["webm_sticker"] = *s.WebM } - - params := map[string]string{ - "user_id": to.Recipient(), - "sticker_type": s.Type, - "name": s.Name, - "title": s.Title, - "emojis": s.Emojis, - "contains_masks": strconv.FormatBool(s.ContainsMasks), - } - if s.MaskPosition != nil { data, _ := json.Marshal(&s.MaskPosition) params["mask_position"] = string(data) @@ -119,26 +121,26 @@ func (b *Bot) CreateStickerSet(to Recipient, s StickerSet) error { return err } +type InputSticker struct { + Name string `json:"-"` + Sticker File `json:"-"` + EmojiList [20]string `json:"emojis"` + MaskPosition *MaskPosition `json:"mask_position"` + Keywords [20]string `json:"keywords"` +} + // AddSticker adds a new sticker to the existing sticker set. -func (b *Bot) AddSticker(to Recipient, s StickerSet) error { +// todo: test and see if it works +func (b *Bot) AddSticker(to Recipient, s InputSticker) error { files := make(map[string]File) - if s.PNG != nil { - files["png_sticker"] = *s.PNG - } else if s.TGS != nil { - files["tgs_sticker"] = *s.TGS - } else if s.WebM != nil { - files["webm_sticker"] = *s.WebM - } + files["sticker.sticker"] = s.Sticker + + data, _ := json.Marshal(&s) params := map[string]string{ "user_id": to.Recipient(), "name": s.Name, - "emojis": s.Emojis, - } - - if s.MaskPosition != nil { - data, _ := json.Marshal(&s.MaskPosition) - params["mask_position"] = string(data) + "sticker": string(data), } _, err := b.sendFiles("addStickerToSet", files, params) @@ -171,13 +173,12 @@ func (b *Bot) DeleteSticker(sticker string) error { // up to 32 kilobytes in size. // // Animated sticker set thumbnail can't be uploaded via HTTP URL. -// func (b *Bot) SetStickerSetThumb(to Recipient, s StickerSet) error { files := make(map[string]File) if s.PNG != nil { - files["thumb"] = *s.PNG + files["thumbnail"] = *s.PNG } else if s.TGS != nil { - files["thumb"] = *s.TGS + files["thumbnail"] = *s.TGS } params := map[string]string{ @@ -210,3 +211,6 @@ func (b *Bot) CustomEmojiStickers(ids []string) ([]Sticker, error) { } return resp.Result, nil } + +// todo: https://core.telegram.org/bots/api-changelog#march-9-2023 +// update stickers