Skip to content

Commit

Permalink
Merge pull request tucnak#484 from setval/support-5.5
Browse files Browse the repository at this point in the history
api: support 5.5
  • Loading branch information
demget authored Feb 5, 2022
2 parents 15ad8bd + 54d6d11 commit 0fd6dea
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 11 deletions.
25 changes: 25 additions & 0 deletions admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,28 @@ func (b *Bot) SetAdminTitle(chat *Chat, user *User, title string) error {
_, err := b.Raw("setChatAdministratorCustomTitle", params)
return err
}

// BanSenderChat will use this method to ban a channel chat in a supergroup or a channel.
// Until the chat is unbanned, the owner of the banned chat won't be able
// to send messages on behalf of any of their channels.
func (b *Bot) BanSenderChat(chat *Chat, sender Recipient) error {
params := map[string]string{
"chat_id": chat.Recipient(),
"sender_chat_id": sender.Recipient(),
}

_, err := b.Raw("banChatSenderChat", params)
return err
}

// UnbanSenderChat will use this method to unban 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.
func (b *Bot) UnbanSenderChat(chat *Chat, sender Recipient) error {
params := map[string]string{
"chat_id": chat.Recipient(),
"sender_chat_id": sender.Recipient(),
}

_, err := b.Raw("unbanChatSenderChat", params)
return err
}
24 changes: 13 additions & 11 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,19 @@ type Chat struct {
Still bool `json:"is_member,omitempty"`

// Returns only in getChat
Bio string `json:"bio,omitempty"`
Photo *ChatPhoto `json:"photo,omitempty"`
Description string `json:"description,omitempty"`
InviteLink string `json:"invite_link,omitempty"`
PinnedMessage *Message `json:"pinned_message,omitempty"`
Permissions *Rights `json:"permissions,omitempty"`
SlowMode int `json:"slow_mode_delay,omitempty"`
StickerSet string `json:"sticker_set_name,omitempty"`
CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
LinkedChatID int64 `json:"linked_chat_id,omitempty"`
ChatLocation *ChatLocation `json:"location,omitempty"`
Bio string `json:"bio,omitempty"`
Photo *ChatPhoto `json:"photo,omitempty"`
HasPrivateForwards bool `json:"has_private_forwards,omitempty"`
Description string `json:"description,omitempty"`
InviteLink string `json:"invite_link,omitempty"`
PinnedMessage *Message `json:"pinned_message,omitempty"`
Permissions *Rights `json:"permissions,omitempty"`
SlowMode int `json:"slow_mode_delay,omitempty"`
HasProtectedContent bool `json:"has_protected_content,omitempty"`
StickerSet string `json:"sticker_set_name,omitempty"`
CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
LinkedChatID int64 `json:"linked_chat_id,omitempty"`
ChatLocation *ChatLocation `json:"location,omitempty"`
}

type ChatLocation struct {
Expand Down
3 changes: 3 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ var (
ErrWrongFileIDSymbol = NewError(400, "Bad Request: wrong remote file id specified: can't unserialize it. Wrong last symbol")
ErrWrongTypeOfContent = NewError(400, "Bad Request: wrong type of the web page content")
ErrWrongURL = NewError(400, "Bad Request: wrong HTTP URL specified")
ErrForwardMessage = NewError(400, "Bad Request: administrators of the chat restricted message forwarding")
)

// Forbidden errors
Expand Down Expand Up @@ -228,6 +229,8 @@ func Err(s string) error {
return ErrNotStartedByUser
case ErrUserIsDeactivated.ʔ():
return ErrUserIsDeactivated
case ErrForwardMessage.ʔ():
return ErrForwardMessage
default:
return nil
}
Expand Down
6 changes: 6 additions & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ type Message struct {
// For forwarded messages, unixtime of the original message.
OriginalUnixtime int `json:"forward_date"`

// Message is a channel post that was automatically forwarded to the connected discussion group
IsAutomaticForward bool `json:"is_automatic_forward"`

// For replies, ReplyTo represents the original message.
//
// Note that the Message object in this field will not
Expand All @@ -56,6 +59,9 @@ type Message struct {
// (Optional) Time of last edit in Unix
LastEdit int64 `json:"edit_date"`

// (Optional) Message can't be forwarded
HasProtectedContent bool `json:"has_protected_content,omitempty"`

// AlbumID is the unique identifier of a media message group
// this message belongs to.
AlbumID string `json:"media_group_id"`
Expand Down

0 comments on commit 0fd6dea

Please sign in to comment.