Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: implement 6.8 features #652

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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"`
demget marked this conversation as resolved.
Show resolved Hide resolved
}

// 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"`
demget marked this conversation as resolved.
Show resolved Hide resolved
}

// 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.
demget marked this conversation as resolved.
Show resolved Hide resolved
func (b *Bot) UnpinGeneralTopicMessages(chat *Chat) error {
demget marked this conversation as resolved.
Show resolved Hide resolved
params := map[string]interface{}{
"chat_id": chat.Recipient(),
}

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