api: implement 6.8 features (#652)

* api: implement 6.8 features

* chat,topic: refactor

* chat: change unixtime to lowercase
v3.3
Nash-Well 2 months ago committed by GitHub
parent 435ad606fa
commit 4670ccf5a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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"`
EmojiExpirationUnixtime int64 `json:"emoji_status_expiration_date"`
}
// Recipient returns chat ID (see Recipient interface).
@ -243,6 +244,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
Poster *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)
@ -253,6 +262,11 @@ func (r ChatJoinRequest) Time() time.Time {
return time.Unix(r.Unixtime, 0)
}
// Time returns the moment of the emoji status expiration.
func (c *Chat) Time() time.Time {
return time.Unix(c.EmojiExpirationUnixtime, 0)
}
// InviteLink should be used to export chat's invite link.
func (b *Bot) InviteLink(chat *Chat) (string, error) {
params := map[string]string{

@ -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"`

@ -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"`
}

@ -170,3 +170,15 @@ func (b *Bot) UnhideGeneralTopic(chat *Chat) error {
_, err := b.Raw("unhideGeneralForumTopic", params)
return err
}
// UnpinAllGeneralTopicMessages 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) UnpinAllGeneralTopicMessages(chat *Chat) error {
params := map[string]interface{}{
"chat_id": chat.Recipient(),
}
_, err := b.Raw("unpinAllGeneralForumTopicMessages", params)
return err
}

Loading…
Cancel
Save