Skip to content

Commit

Permalink
api: implement 6.8 features
Browse files Browse the repository at this point in the history
  • Loading branch information
Nash-Well committed Feb 19, 2024
1 parent 71ac299 commit a969f8c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 16 deletions.
41 changes: 25 additions & 16 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,23 @@ type Chat struct {
Username string `json:"username"`

// 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"`
Private bool `json:"has_private_forwards,omitempty"`
Protected bool `json:"has_protected_content,omitempty"`
NoVoiceAndVideo bool `json:"has_restricted_voice_and_video_messages"`
HiddenMembers bool `json:"has_hidden_members,omitempty"`
AggressiveAntiSpam bool `json:"has_aggressive_anti_spam_enabled,omitempty"`
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"`
Private bool `json:"has_private_forwards,omitempty"`
Protected bool `json:"has_protected_content,omitempty"`
NoVoiceAndVideo bool `json:"has_restricted_voice_and_video_messages"`
HiddenMembers bool `json:"has_hidden_members,omitempty"`
AggressiveAntiSpam bool `json:"has_aggressive_anti_spam_enabled,omitempty"`
ExpirationEmojiDate int `json:"emoji_status_expiration_date"`
}

// Recipient returns chat ID (see Recipient interface).
Expand Down Expand Up @@ -240,6 +241,14 @@ type ChatInviteLink struct {
PendingCount int `json:"pending_join_request_count"`
}

type Story struct {
// Unique identifier for the story in the chat
ID int `json:"id"`

// Chat that posted the story
Sender *Chat `json:"chat"`
}

// ExpireDate returns the moment of the link expiration in local time.
func (c *ChatInviteLink) ExpireDate() time.Time {
return time.Unix(c.ExpireUnixtime, 0)
Expand Down
3 changes: 3 additions & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ type Message struct {
// itself is a reply.
ReplyTo *Message `json:"reply_to_message"`

// (Optional) For replies to a story, the original story
Story *Story `json:"reply_to_story"`

// Shows through which bot the message was sent.
Via *User `json:"via_bot"`

Expand Down
1 change: 1 addition & 0 deletions poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type PollOption struct {
type PollAnswer struct {
PollID string `json:"poll_id"`
Sender *User `json:"user"`
Chat *Chat `json:"voter_chat"`
Options []int `json:"option_ids"`
}

Expand Down
10 changes: 10 additions & 0 deletions topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,13 @@ func (b *Bot) UnhideGeneralTopic(chat *Chat) error {
_, err := b.Raw("unhideGeneralForumTopic", params)
return err
}

// UnpinGeneralTopicMessages clears the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup.
func (b *Bot) UnpinGeneralTopicMessages(chat *Chat) error {
params := map[string]interface{}{
"chat_id": chat.Recipient(),
}

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

0 comments on commit a969f8c

Please sign in to comment.