Skip to content

feat: add topic message #717

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
ThreadID int // optional
ChannelUsername string
ProtectContent bool
ReplyToMessageID int
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/go-telegram-bot-api/telegram-bot-api/v5
module github.com/sphantix/telegram-bot-api

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to fix that before merge.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albertosouza i fixed it (#737)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, when will this features be added?


go 1.16
15 changes: 15 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 2 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down