diff --git a/configs.go b/configs.go index 1831337b..1e4167a9 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 + TopicID int ChannelUsername string ProtectContent bool ReplyToMessageID int @@ -277,6 +278,7 @@ func (chat *BaseChat) params() (Params, error) { params := make(Params) params.AddFirstValid("chat_id", chat.ChatID, chat.ChannelUsername) + params.AddNonZero("message_thread_id", chat.TopicID) params.AddNonZero("reply_to_message_id", chat.ReplyToMessageID) params.AddBool("disable_notification", chat.DisableNotification) params.AddBool("allow_sending_without_reply", chat.AllowSendingWithoutReply) diff --git a/helpers.go b/helpers.go index 3a0e8187..97dac4d1 100644 --- a/helpers.go +++ b/helpers.go @@ -14,10 +14,16 @@ import ( // NewMessage creates a new Message. // // chatID is where to send it, text is the message text. -func NewMessage(chatID int64, text string) MessageConfig { +// topicID is additional parameter to specify topic of supergroup where message need to be sent. +func NewMessage(chatID int64, text string, topicID ...int) MessageConfig { + threadID := 0 + if len(topicID) > 0 { + threadID = topicID[0] + } return MessageConfig{ BaseChat: BaseChat{ ChatID: chatID, + TopicID: threadID, ReplyToMessageID: 0, }, Text: text, diff --git a/types.go b/types.go index 36c174b8..1b8d0d0c 100644 --- a/types.go +++ b/types.go @@ -361,6 +361,10 @@ func (c Chat) ChatConfig() ChatConfig { type Message struct { // MessageID is a unique message identifier inside this chat MessageID int `json:"message_id"` + // TopicID is id of topic in which message was sent + // + // optional, supergroups only + TopicID int `json:"message_thread_id",omitempty` // From is a sender, empty for messages sent to channels; // // optional