Skip to content

Commit

Permalink
Updates for Bot API 5.5.
Browse files Browse the repository at this point in the history
  • Loading branch information
Syfaro committed Dec 7, 2021
1 parent f2ef272 commit 3f07c5f
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
48 changes: 48 additions & 0 deletions configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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=<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
Expand All @@ -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.
//
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ var (
_ Chattable = AnimationConfig{}
_ Chattable = AudioConfig{}
_ Chattable = BanChatMemberConfig{}
_ Chattable = BanChatSenderChatConfig{}
_ Chattable = CallbackConfig{}
_ Chattable = ChatActionConfig{}
_ Chattable = ChatAdministratorsConfig{}
Expand Down Expand Up @@ -332,6 +333,7 @@ var (
_ Chattable = StopMessageLiveLocationConfig{}
_ Chattable = StopPollConfig{}
_ Chattable = UnbanChatMemberConfig{}
_ Chattable = UnbanChatSenderChatConfig{}
_ Chattable = UnpinChatMessageConfig{}
_ Chattable = UpdateConfig{}
_ Chattable = UserProfilePhotosConfig{}
Expand Down

0 comments on commit 3f07c5f

Please sign in to comment.