diff --git a/configs.go b/configs.go index 1831337b..9b6f194d 100644 --- a/configs.go +++ b/configs.go @@ -265,6 +265,7 @@ func (CloseConfig) params() (Params, error) { // BaseChat is base type for all chat config types. type BaseChat struct { ChatID int64 // required + ThreadID int // optional ChannelUsername string ProtectContent bool ReplyToMessageID int @@ -278,6 +279,7 @@ func (chat *BaseChat) params() (Params, error) { params.AddFirstValid("chat_id", chat.ChatID, chat.ChannelUsername) params.AddNonZero("reply_to_message_id", chat.ReplyToMessageID) + params.AddNonZero("message_thread_id", chat.ThreadID) params.AddBool("disable_notification", chat.DisableNotification) params.AddBool("allow_sending_without_reply", chat.AllowSendingWithoutReply) params.AddBool("protect_content", chat.ProtectContent) diff --git a/helpers.go b/helpers.go index 3a0e8187..18ec5d4e 100644 --- a/helpers.go +++ b/helpers.go @@ -25,6 +25,21 @@ func NewMessage(chatID int64, text string) MessageConfig { } } +// NewTopicMessage creates a new Message which will be sent to a topic thread. +// +// chatID is where to send it, topicID is the topic thread id, text is the message text. +func NewTopicMessage(chatID int64, topicID int, text string) MessageConfig { + return MessageConfig{ + BaseChat: BaseChat{ + ChatID: chatID, + ThreadID: topicID, + ReplyToMessageID: 0, + }, + Text: text, + DisableWebPagePreview: false, + } +} + // NewDeleteMessage creates a request to delete a message. func NewDeleteMessage(chatID int64, messageID int) DeleteMessageConfig { return DeleteMessageConfig{ diff --git a/types.go b/types.go index 36c174b8..9235a888 100644 --- a/types.go +++ b/types.go @@ -361,6 +361,8 @@ func (c Chat) ChatConfig() ChatConfig { type Message struct { // MessageID is a unique message identifier inside this chat MessageID int `json:"message_id"` + // Optional. Unique identifier of a message thread to which the message belongs; for supergroups only + MessageThreadID int `json:"message_thread_id"` // From is a sender, empty for messages sent to channels; // // optional