From 0dca12b7f18f061f5cebf11f77027ad388a15d42 Mon Sep 17 00:00:00 2001 From: Andrew Privalov Date: Tue, 23 Aug 2022 13:24:20 +0300 Subject: [PATCH] v6.2 (#3) --- CHANGELOG.md | 4 ++++ README.md | 4 +--- methods.go | 7 +++++++ methods_params.go | 5 +++++ models/chat.go | 45 ++++++++++++++++++++-------------------- models/message_entity.go | 14 +++++++------ models/sticker.go | 2 ++ models/sticker_set.go | 1 + 8 files changed, 51 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37225fb..e5f591e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.2.2 (2022-08-23) + +- support bot api v6.2 + ## v0.2.1 (2022-07-08) - support bot api v6.1 diff --git a/README.md b/README.md index 830b15e..76951bd 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # Golang Telegram Bot -> The project is under development. API may be changed before v1.0.0 version. - > [Telegram Group](https://t.me/gotelegrambotui) -> Supports Bot API version: [6.1](https://core.telegram.org/bots/api#june-20-2022) from June 20, 2022 +> Supports Bot API version: [6.2](https://core.telegram.org/bots/api#august-12-2022) from August 12, 2022 It's a Go zero-dependencies telegram bot framework diff --git a/methods.go b/methods.go index 10977f3..b10e9ab 100644 --- a/methods.go +++ b/methods.go @@ -503,6 +503,13 @@ func (b *Bot) GetStickerSet(ctx context.Context, params *GetStickerSetParams) (* return result, err } +// GetCustomEmojiStickers https://core.telegram.org/bots/api#getcustomemojistickers +func (b *Bot) GetCustomEmojiStickers(ctx context.Context, params *GetCustomEmojiStickersParams) ([]*models.Sticker, error) { + var result []*models.Sticker + err := b.rawRequest(ctx, "getCustomEmojiStickers", params, &result) + return result, err +} + // UploadStickerFile https://core.telegram.org/bots/api#uploadstickerfile func (b *Bot) UploadStickerFile(ctx context.Context, params *UploadStickerFileParams) (*models.File, error) { result := &models.File{} diff --git a/methods_params.go b/methods_params.go index 4953ac3..4e92f22 100644 --- a/methods_params.go +++ b/methods_params.go @@ -540,6 +540,10 @@ type GetStickerSetParams struct { Name string `json:"name"` } +type GetCustomEmojiStickersParams struct { + CustomEmojiIDs []string `json:"custom_emoji_ids"` +} + type UploadStickerFileParams struct { UserID int `json:"user_id"` PngSticker models.InputFile `json:"png_sticker"` @@ -552,6 +556,7 @@ type CreateNewStickerSetParams struct { PngSticker models.InputFile `json:"png_sticker,omitempty"` TgsSticker models.InputFile `json:"tgs_sticker,omitempty"` WebmSticker models.InputFile `json:"webm_sticker,omitempty"` + StickerType string `json:"sticker_type,omitempty"` Emojis string `json:"emojis"` ContainsMasks bool `json:"contains_masks,omitempty"` MaskPosition models.MaskPosition `json:"mask_position,omitempty"` diff --git a/models/chat.go b/models/chat.go index 61c11a3..eb8953e 100644 --- a/models/chat.go +++ b/models/chat.go @@ -65,26 +65,27 @@ type ChatLocation struct { // Chat https://core.telegram.org/bots/api#chat type Chat struct { - ID int `json:"id"` - Type string `json:"type"` - Title string `json:"title,omitempty"` - Username string `json:"username,omitempty"` - FirstName string `json:"first_name,omitempty"` - LastName string `json:"last_name,omitempty"` - Photo *ChatPhoto `json:"photo,omitempty"` - Bio string `json:"bio"` - HasPrivateForwards bool `json:"has_private_forwards,omitempty"` - JoinToSendMessages bool `json:"join_to_send_messages"` - JoinByRequest bool `json:"join_by_request"` - Description string `json:"description,omitempty"` - InviteLink string `json:"invite_link,omitempty"` - PinnedMessage *Message `json:"pinned_message,omitempty"` - Permissions *ChatPermissions `json:"permissions,omitempty"` - SlowModeDelay int `json:"slow_mode_delay,omitempty"` - MessageAutoDeleteTime int `json:"message_auto_delete_time,omitempty"` - HasProtectedContent bool `json:"has_protected_content,omitempty"` - StickerSetName string `json:"sticker_set_name,omitempty"` - CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"` - LinkedChatID int `json:"linked_chat_id,omitempty"` - Location *ChatLocation `json:"location,omitempty"` + ID int `json:"id"` + Type string `json:"type"` + Title string `json:"title,omitempty"` + Username string `json:"username,omitempty"` + FirstName string `json:"first_name,omitempty"` + LastName string `json:"last_name,omitempty"` + Photo *ChatPhoto `json:"photo,omitempty"` + Bio string `json:"bio"` + HasPrivateForwards bool `json:"has_private_forwards,omitempty"` + HasRestrictedVoiceAndVideoMessages bool `json:"has_restricted_voice_and_video_messages,omitempty"` + JoinToSendMessages bool `json:"join_to_send_messages"` + JoinByRequest bool `json:"join_by_request"` + Description string `json:"description,omitempty"` + InviteLink string `json:"invite_link,omitempty"` + PinnedMessage *Message `json:"pinned_message,omitempty"` + Permissions *ChatPermissions `json:"permissions,omitempty"` + SlowModeDelay int `json:"slow_mode_delay,omitempty"` + MessageAutoDeleteTime int `json:"message_auto_delete_time,omitempty"` + HasProtectedContent bool `json:"has_protected_content,omitempty"` + StickerSetName string `json:"sticker_set_name,omitempty"` + CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"` + LinkedChatID int `json:"linked_chat_id,omitempty"` + Location *ChatLocation `json:"location,omitempty"` } diff --git a/models/message_entity.go b/models/message_entity.go index a327b7b..2b0a35a 100644 --- a/models/message_entity.go +++ b/models/message_entity.go @@ -18,14 +18,16 @@ const ( MessageEntityTypePre MessageEntityType = "pre" MessageEntityTypeTextLink MessageEntityType = "text_link" MessageEntityTypeTextMention MessageEntityType = "text_mention" + MessageEntityTypeCustomEmoji MessageEntityType = "custom_emoji" ) // MessageEntity https://core.telegram.org/bots/api#messageentity type MessageEntity struct { - Type MessageEntityType `json:"type"` - Offset int `json:"offset"` - Length int `json:"length"` - URL string `json:"url,omitempty"` - User *User `json:"user,omitempty"` - Language string `json:"language,omitempty"` + Type MessageEntityType `json:"type"` + Offset int `json:"offset"` + Length int `json:"length"` + URL string `json:"url,omitempty"` + User *User `json:"user,omitempty"` + Language string `json:"language,omitempty"` + CustomEmojiID string `json:"custom_emoji_id"` } diff --git a/models/sticker.go b/models/sticker.go index c9a3d84..1807abb 100644 --- a/models/sticker.go +++ b/models/sticker.go @@ -12,6 +12,7 @@ type MaskPosition struct { type Sticker struct { FileID string `json:"file_id"` FileUniqueID string `json:"file_unique_id"` + Type string `json:"type"` Width int `json:"width"` Height int `json:"height"` IsAnimated bool `json:"is_animated"` @@ -21,5 +22,6 @@ type Sticker struct { SetName string `json:"set_name,omitempty"` PremiumAnimation *File `json:"premium_animation,omitempty"` MaskPosition MaskPosition `json:"mask_position,omitempty"` + CustomEmojiID string `json:"custom_emoji_id"` FileSize int `json:"file_size,omitempty"` } diff --git a/models/sticker_set.go b/models/sticker_set.go index 8c23545..9fdbef7 100644 --- a/models/sticker_set.go +++ b/models/sticker_set.go @@ -4,6 +4,7 @@ package models type StickerSet struct { Name string `json:"name"` Title string `json:"title"` + StickerType string `json:"sticker_type"` IsAnimated bool `json:"is_animated"` IsVideo bool `json:"is_video"` ContainsMasks bool `json:"contains_masks"`