Skip to content
Merged

9.0 #176

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.15.0 (2025-04-29)

- support API 8.3

## v1.14.2 (2025-02-12)

- add `MatchTypeCommand` and `MatchTypeCommandStartOnly`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

> [Telegram Group](https://t.me/gotelegrambotui)

> Supports Bot API version: [8.3](https://core.telegram.org/bots/api#february-12-2025) from February 12, 2025
> Supports Bot API version: [9.0](https://core.telegram.org/bots/api#april-11-2025) from April 11, 2025

It's a Go zero-dependencies telegram bot framework

Expand Down
126 changes: 126 additions & 0 deletions methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -943,3 +943,129 @@ func (b *Bot) RemoveChatVerification(ctx context.Context, params *RemoveChatVeri
err := b.rawRequest(ctx, "removeChatVerification", params, &result)
return result, err
}

// ReadBusinessMessage https://core.telegram.org/bots/api#readbusinessmessage
func (b *Bot) ReadBusinessMessage(ctx context.Context, params *ReadBusinessMessageParams) (bool, error) {
var result bool
err := b.rawRequest(ctx, "readBusinessMessage", params, &result)
return result, err
}

// DeleteBusinessMessages https://core.telegram.org/bots/api#deletebusinessmessages
func (b *Bot) DeleteBusinessMessages(ctx context.Context, params *DeleteBusinessMessagesParams) (bool, error) {
var result bool
err := b.rawRequest(ctx, "deleteBusinessMessages", params, &result)
return result, err
}

// SetBusinessAccountName https://core.telegram.org/bots/api#setbusinessaccountname
func (b *Bot) SetBusinessAccountName(ctx context.Context, params *SetBusinessAccountNameParams) (bool, error) {
var result bool
err := b.rawRequest(ctx, "setBusinessAccountName", params, &result)
return result, err
}

// SetBusinessAccountUsername https://core.telegram.org/bots/api#setbusinessaccountusername
func (b *Bot) SetBusinessAccountUsername(ctx context.Context, params *SetBusinessAccountUsernameParams) (bool, error) {
var result bool
err := b.rawRequest(ctx, "setBusinessAccountUsername", params, &result)
return result, err
}

// SetBusinessAccountBio https://core.telegram.org/bots/api#setbusinessaccountbio
func (b *Bot) SetBusinessAccountBio(ctx context.Context, params *SetBusinessAccountBioParams) (bool, error) {
var result bool
err := b.rawRequest(ctx, "setBusinessAccountBio", params, &result)
return result, err
}

// SetBusinessAccountProfilePhoto https://core.telegram.org/bots/api#setbusinessaccountprofilephoto
func (b *Bot) SetBusinessAccountProfilePhoto(ctx context.Context, params *SetBusinessAccountProfilePhotoParams) (bool, error) {
var result bool
err := b.rawRequest(ctx, "SetBusinessAccountProfilePhoto", params, &result)
return result, err
}

// RemoveBusinessAccountProfilePhoto https://core.telegram.org/bots/api#removebusinessaccountprofilephoto
func (b *Bot) RemoveBusinessAccountProfilePhoto(ctx context.Context, params *RemoveBusinessAccountProfilePhotoParams) (bool, error) {
var result bool
err := b.rawRequest(ctx, "removeBusinessAccountProfilePhoto", params, &result)
return result, err
}

// SetBusinessAccountGiftSettings https://core.telegram.org/bots/api#setbusinessaccountgiftsettings
func (b *Bot) SetBusinessAccountGiftSettings(ctx context.Context, params *SetBusinessAccountGiftSettingsParams) (bool, error) {
var result bool
err := b.rawRequest(ctx, "setBusinessAccountGiftSettings", params, &result)
return result, err
}

// GetBusinessAccountStarBalance https://core.telegram.org/bots/api#getbusinessaccountstarbalance
func (b *Bot) GetBusinessAccountStarBalance(ctx context.Context, params *GetBusinessAccountStarBalanceParams) (*models.StarAmount, error) {
result := &models.StarAmount{}
err := b.rawRequest(ctx, "getBusinessAccountStarBalance", params, &result)
return result, err
}

// TransferBusinessAccountStars https://core.telegram.org/bots/api#transferbusinessaccountstars
func (b *Bot) TransferBusinessAccountStars(ctx context.Context, params *TransferBusinessAccountStarsParams) (bool, error) {
var result bool
err := b.rawRequest(ctx, "transferBusinessAccountStars", params, &result)
return result, err
}

// GetBusinessAccountGifts https://core.telegram.org/bots/api#getbusinessaccountgifts
func (b *Bot) GetBusinessAccountGifts(ctx context.Context, params *GetBusinessAccountGiftsParams) (*models.OwnedGifts, error) {
result := &models.OwnedGifts{}
err := b.rawRequest(ctx, "getBusinessAccountGifts", params, &result)
return result, err
}

// ConvertGiftToStars https://core.telegram.org/bots/api#convertgifttostars
func (b *Bot) ConvertGiftToStars(ctx context.Context, params *ConvertGiftToStarsParams) (bool, error) {
var result bool
err := b.rawRequest(ctx, "convertGiftToStars", params, &result)
return result, err
}

// UpgradeGift https://core.telegram.org/bots/api#upgradegift
func (b *Bot) UpgradeGift(ctx context.Context, params *UpgradeGiftParams) (bool, error) {
var result bool
err := b.rawRequest(ctx, "upgradeGift", params, &result)
return result, err
}

// TransferGift https://core.telegram.org/bots/api#transfergift
func (b *Bot) TransferGift(ctx context.Context, params *TransferGiftParams) (bool, error) {
var result bool
err := b.rawRequest(ctx, "transferGift", params, &result)
return result, err
}

// PostStory https://core.telegram.org/bots/api#poststory
func (b *Bot) PostStory(ctx context.Context, params *PostStoryParams) (*models.Story, error) {
result := &models.Story{}
err := b.rawRequest(ctx, "postStory", params, &result)
return result, err
}

// EditStory https://core.telegram.org/bots/api#editstory
func (b *Bot) EditStory(ctx context.Context, params *EditStoryParams) (*models.Story, error) {
result := &models.Story{}
err := b.rawRequest(ctx, "editStory", params, &result)
return result, err
}

// DeleteStory https://core.telegram.org/bots/api#deletestory
func (b *Bot) DeleteStory(ctx context.Context, params *DeleteStoryParams) (bool, error) {
var result bool
err := b.rawRequest(ctx, "deleteStory", params, &result)
return result, err
}

// GiftPremiumSubscription https://core.telegram.org/bots/api#giftpremiumsubscription
func (b *Bot) GiftPremiumSubscription(ctx context.Context, params *GiftPremiumSubscriptionParams) (bool, error) {
var result bool
err := b.rawRequest(ctx, "giftPremiumSubscription", params, &result)
return result, err
}
138 changes: 138 additions & 0 deletions methods_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -1065,3 +1065,141 @@ type RemoveUserVerificationParams struct {
type RemoveChatVerificationParams struct {
ChatID any `json:"chat_id"`
}

// ReadBusinessMessageParams https://core.telegram.org/bots/api#readbusinessmessage
type ReadBusinessMessageParams struct {
BusinessConnectionID string `json:"business_connection_id"`
ChatID int `json:"chat_id"`
MessageID int `json:"message_id"`
}

// DeleteBusinessMessagesParams https://core.telegram.org/bots/api#deletebusinessmessages
type DeleteBusinessMessagesParams struct {
BusinessConnectionID string `json:"business_connection_id"`
MessageIDs []int `json:"message_ids"`
}

// SetBusinessAccountNameParams https://core.telegram.org/bots/api#setbusinessaccountname
type SetBusinessAccountNameParams struct {
BusinessConnectionID string `json:"business_connection_id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name,omitempty"`
}

// SetBusinessAccountUsernameParams https://core.telegram.org/bots/api#setbusinessaccountusername
type SetBusinessAccountUsernameParams struct {
BusinessConnectionID string `json:"business_connection_id"`
Username string `json:"username,omitempty"`
}

// SetBusinessAccountBioParams https://core.telegram.org/bots/api#setbusinessaccountbio
type SetBusinessAccountBioParams struct {
BusinessConnectionID string `json:"business_connection_id"`
Bio string `json:"bio,omitempty"`
}

// SetBusinessAccountProfilePhotoParams https://core.telegram.org/bots/api#setbusinessaccountprofilephoto
type SetBusinessAccountProfilePhotoParams struct {
BusinessConnectionID string `json:"business_connection_id"`
Photo models.InputProfilePhoto `json:"photo"`
IsPublic bool `json:"is_public,omitempty"`
}

// RemoveBusinessAccountProfilePhotoParams https://core.telegram.org/bots/api#removebusinessaccountprofilephoto
type RemoveBusinessAccountProfilePhotoParams struct {
BusinessConnectionID string `json:"business_connection_id"`
IsPublic bool `json:"is_public,omitempty"`
}

// SetBusinessAccountGiftSettingsParams https://core.telegram.org/bots/api#setbusinessaccountgiftsettings
type SetBusinessAccountGiftSettingsParams struct {
BusinessConnectionID string `json:"business_connection_id"`
ShowGiftButton bool `json:"show_gift_button"`
AcceptedGiftTypes models.AcceptedGiftTypes `json:"accepted_gift_types"`
}

// GetBusinessAccountStarBalanceParams https://core.telegram.org/bots/api#getbusinessaccountstarbalance
type GetBusinessAccountStarBalanceParams struct {
BusinessConnectionID string `json:"business_connection_id"`
}

// TransferBusinessAccountStarsParams https://core.telegram.org/bots/api#transferbusinessaccountstars
type TransferBusinessAccountStarsParams struct {
BusinessConnectionID string `json:"business_connection_id"`
StarCount int `json:"star_count"`
}

// GetBusinessAccountGiftsParams https://core.telegram.org/bots/api#getbusinessaccountgifts
type GetBusinessAccountGiftsParams struct {
BusinessConnectionID string `json:"business_connection_id"`
ExcludeUnsaved bool `json:"exclude_unsaved,omitempty"`
ExcludeSaved bool `json:"exclude_saved,omitempty"`
ExcludeUnlimited bool `json:"exclude_unlimited,omitempty"`
ExcludeLimited bool `json:"exclude_limited,omitempty"`
ExcludeUnique bool `json:"exclude_unique,omitempty"`
SortByPrice bool `json:"sort_by_price,omitempty"`
Offset string `json:"offset,omitempty"`
Limit int `json:"limit,omitempty"`
}

// ConvertGiftToStarsParams https://core.telegram.org/bots/api#convertgifttostars
type ConvertGiftToStarsParams struct {
BusinessConnectionID string `json:"business_connection_id"`
OwnedGiftID string `json:"owned_gift_id"`
}

// UpgradeGiftParams https://core.telegram.org/bots/api#upgradegift
type UpgradeGiftParams struct {
BusinessConnectionID string `json:"business_connection_id"`
OwnedGiftID string `json:"owned_gift_id"`
KeepOriginalDetails bool `json:"keep_original_details,omitempty"`
StarCount int `json:"star_count,omitempty"`
}

// TransferGiftParams https://core.telegram.org/bots/api#transfergift
type TransferGiftParams struct {
BusinessConnectionID string `json:"business_connection_id"`
OwnedGiftID string `json:"owned_gift_id"`
NewOwnerChatID int `json:"new_owner_chat_id"`
StarCount int `json:"star_count"`
}

// PostStoryParams https://core.telegram.org/bots/api#poststory
type PostStoryParams struct {
BusinessConnectionID string `json:"business_connection_id"`
Content models.InputStoryContent `json:"content"`
ActivePeriod int `json:"active_period"`
Caption string `json:"caption,omitempty"`
ParseMode models.ParseMode `json:"parse_mode,omitempty"`
CaptionEntities []models.MessageEntity `json:"caption_entities,omitempty"`
Areas []models.StoryArea `json:"areas,omitempty"`
PostToChatPage bool `json:"post_to_chat_page,omitempty"`
ProtectContent bool `json:"protect_content,omitempty"`
}

// EditStoryParams https://core.telegram.org/bots/api#editstory
type EditStoryParams struct {
BusinessConnectionID string `json:"business_connection_id"`
StoryID int `json:"story_id"`
Content models.InputStoryContent `json:"content"`
Caption string `json:"caption,omitempty"`
ParseMode models.ParseMode `json:"parse_mode,omitempty"`
CaptionEntities []models.MessageEntity `json:"caption_entities,omitempty"`
Areas []models.StoryArea `json:"areas,omitempty"`
}

// DeleteStoryParams https://core.telegram.org/bots/api#deletestory
type DeleteStoryParams struct {
BusinessConnectionID string `json:"business_connection_id"`
StoryID int `json:"story_id"`
}

// GiftPremiumSubscriptionParams https://core.telegram.org/bots/api#giftpremiumsubscription
type GiftPremiumSubscriptionParams struct {
UserID int64 `json:"user_id"`
MonthCount int `json:"month_count"`
StarCount int `json:"star_count"`
Text string `json:"text,omitempty"`
TextParseMode string `json:"text_parse_mode,omitempty"`
TextEntities []models.MessageEntity `json:"text_entities,omitempty"`
}
29 changes: 23 additions & 6 deletions models/business.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package models

// BusinessConnection https://core.telegram.org/bots/api#businessconnection
type BusinessConnection struct {
ID string `json:"id"`
User User `json:"user"`
UserChatID int64 `json:"user_chat_id"`
Date int64 `json:"date"`
CanReply bool `json:"can_reply"`
IsEnabled bool `json:"is_enabled"`
ID string `json:"id"`
User User `json:"user"`
UserChatID int64 `json:"user_chat_id"`
Date int64 `json:"date"`
Rights *BusinessBotRights `json:"rights,omitempty"`
IsEnabled bool `json:"is_enabled"`
}

// BusinessMessagesDeleted https://core.telegram.org/bots/api#businessmessagesdeleted
Expand Down Expand Up @@ -41,3 +41,20 @@ type BusinessOpeningHoursInterval struct {
OpeningMinute int `json:"opening_minute"`
ClosingMinute int `json:"closing_minute"`
}

type BusinessBotRights struct {
CanReply bool `json:"can_reply,omitempty"`
CanReadMessages bool `json:"can_read_messages,omitempty"`
CanDeleteOutgoingMessages bool `json:"can_delete_outgoing_messages,omitempty"`
CanDeleteAllMessages bool `json:"can_delete_all_messages,omitempty"`
CanEditName bool `json:"can_edit_name,omitempty"`
CanEditBio bool `json:"can_edit_bio,omitempty"`
CanEditProfilePhoto bool `json:"can_edit_profile_photo,omitempty"`
CanEditUsername bool `json:"can_edit_username,omitempty"`
CanChangeGiftSettings bool `json:"can_change_gift_settings,omitempty"`
CanViewGiftsAndStars bool `json:"can_view_gifts_and_stars,omitempty"`
CanConvertGiftsToStars bool `json:"can_convert_gifts_to_stars,omitempty"`
CanTransferAndUpgradeGifts bool `json:"can_transfer_and_upgrade_gifts,omitempty"`
CanTransferStars bool `json:"can_transfer_stars,omitempty"`
CanManageStories bool `json:"can_manage_stories,omitempty"`
}
2 changes: 1 addition & 1 deletion models/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ type ChatFullInfo struct {
InviteLink string `json:"invite_link,omitempty"`
PinnedMessage *Message `json:"pinned_message,omitempty"`
Permissions *ChatPermissions `json:"permissions,omitempty"`
AcceptedGiftTypes AcceptedGiftTypes `json:"accepted_gift_types"`
CanSendPaidMedia bool `json:"can_send_paid_media,omitempty"`
SlowModeDelay int `json:"slow_mode_delay,omitempty"`
UnrestrictBoostCount int `json:"unrestrict_boost_count,omitempty"`
Expand All @@ -146,5 +147,4 @@ type ChatFullInfo struct {
CustomEmojiStickerSetName string `json:"custom_emoji_sticker_set_name,omitempty"`
LinkedChatID int64 `json:"linked_chat_id,omitempty"`
Location *ChatLocation `json:"location,omitempty"`
CanSendGift bool `json:"can_send_gift,omitempty"`
}
Loading
Loading