From 3f07c5f67644dfc8a9c37210de2b95cfdb060515 Mon Sep 17 00:00:00 2001 From: Syfaro Date: Tue, 7 Dec 2021 10:08:41 -0500 Subject: [PATCH] Updates for Bot API 5.5. --- configs.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ types.go | 25 +++++++++++++++++++++++++ types_test.go | 2 ++ 3 files changed, 75 insertions(+) diff --git a/configs.go b/configs.go index db8ada6..5e43af4 100644 --- a/configs.go +++ b/configs.go @@ -1406,6 +1406,54 @@ func (config SetChatAdministratorCustomTitle) params() (Params, error) { return params, nil } +// BanChatSenderChatConfig bans a channel chat in a supergroup or a channel. The +// owner of the chat will not be able to send messages and join live streams on +// behalf of the chat, unless it is unbanned first. The bot must be an +// administrator in the supergroup or channel for this to work and must have the +// appropriate administrator rights. +type BanChatSenderChatConfig struct { + ChatID int64 + ChannelUsername string + SenderChatID int64 + UntilDate int +} + +func (config BanChatSenderChatConfig) method() string { + return "banChatSenderChat" +} + +func (config BanChatSenderChatConfig) params() (Params, error) { + params := make(Params) + + _ = params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername) + params.AddNonZero64("sender_chat_id", config.SenderChatID) + params.AddNonZero("until_date", config.UntilDate) + + return params, nil +} + +// UnbanChatSenderChatConfig unbans a previously banned channel chat in a +// supergroup or channel. The bot must be an administrator for this to work and +// must have the appropriate administrator rights. +type UnbanChatSenderChatConfig struct { + ChatID int64 + ChannelUsername string + SenderChatID int64 +} + +func (config UnbanChatSenderChatConfig) method() string { + return "unbanChatSenderChat" +} + +func (config UnbanChatSenderChatConfig) params() (Params, error) { + params := make(Params) + + _ = params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername) + params.AddNonZero64("sender_chat_id", config.SenderChatID) + + return params, nil +} + // ChatConfig contains information about getting information on a chat. type ChatConfig struct { ChatID int64 diff --git a/types.go b/types.go index 5421b8e..18b4dec 100644 --- a/types.go +++ b/types.go @@ -264,6 +264,12 @@ type Chat struct { // // optional Bio string `json:"bio,omitempty"` + // HasPrivateForwards is true if privacy settings of the other party in the + // private chat allows to use tg://user?id= links only in chats + // with the user. Returned only in getChat. + // + // optional + HasPrivateForwards bool `json:"has_private_forwards,omitempty"` // Description for groups, supergroups and channel chats // // optional @@ -289,6 +295,16 @@ type Chat struct { // // optional SlowModeDelay int `json:"slow_mode_delay,omitempty"` + // MessageAutoDeleteTime is the time after which all messages sent to the + // chat will be automatically deleted; in seconds. Returned only in getChat. + // + // optional + MessageAutoDeleteTime int `json:"message_auto_delete_time,omitempty"` + // HasProtectedContent is true if messages from the chat can't be forwarded + // to other chats. Returned only in getChat. + // + // optional + HasProtectedContent bool `json:"has_protected_content,omitempty"` // StickerSetName is for supergroups, name of group sticker set.Returned // only in getChat. // @@ -384,6 +400,11 @@ type Message struct { // // optional ForwardDate int `json:"forward_date,omitempty"` + // IsAutomaticForward is true if the message is a channel post that was + // automatically forwarded to the connected discussion group. + // + // optional + IsAutomaticForward bool `json:"is_automatic_forward,omitempty"` // ReplyToMessage for replies, the original message. // Note that the Message object in this field will not contain further ReplyToMessage fields // even if it itself is a reply; @@ -398,6 +419,10 @@ type Message struct { // // optional EditDate int `json:"edit_date,omitempty"` + // HasProtectedContent is true if the message can't be forwarded. + // + // optional + HasProtectedContent bool `json:"has_protected_content,omitempty"` // MediaGroupID is the unique identifier of a media message group this message belongs to; // // optional diff --git a/types_test.go b/types_test.go index af3cd67..9ba9bb5 100644 --- a/types_test.go +++ b/types_test.go @@ -282,6 +282,7 @@ var ( _ Chattable = AnimationConfig{} _ Chattable = AudioConfig{} _ Chattable = BanChatMemberConfig{} + _ Chattable = BanChatSenderChatConfig{} _ Chattable = CallbackConfig{} _ Chattable = ChatActionConfig{} _ Chattable = ChatAdministratorsConfig{} @@ -332,6 +333,7 @@ var ( _ Chattable = StopMessageLiveLocationConfig{} _ Chattable = StopPollConfig{} _ Chattable = UnbanChatMemberConfig{} + _ Chattable = UnbanChatSenderChatConfig{} _ Chattable = UnpinChatMessageConfig{} _ Chattable = UpdateConfig{} _ Chattable = UserProfilePhotosConfig{}