Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down