@ -12,46 +12,46 @@ type Topic struct {
ThreadID int ` json:"message_thread_id" `
}
type (
TopicCreated struct { Topic }
TopicClosed struct { }
TopicDeleted struct { Topic }
TopicReopened struct { Topic }
TopicEdited struct { Topic }
GeneralTopicHidden struct { }
GeneralTopicUnhidden struct { }
)
// CreateTopic creates a topic in a forum supergroup chat.
func ( b * Bot ) CreateTopic ( chat * Chat , forum * Topic ) error {
func ( b * Bot ) CreateTopic ( chat * Chat , topic * Topic ) ( * Topic , error ) {
params := map [ string ] string {
"chat_id" : chat . Recipient ( ) ,
"name" : forum . Name ,
"name" : topic . Name ,
}
if forum . IconColor != 0 {
params [ "icon_color" ] = strconv . Itoa ( forum . IconColor )
if topic . IconColor != 0 {
params [ "icon_color" ] = strconv . Itoa ( topic . IconColor )
}
if forum . IconCustomEmojiID != "" {
params [ "icon_custom_emoji_id" ] = forum . IconCustomEmojiID
if topic . IconCustomEmojiID != "" {
params [ "icon_custom_emoji_id" ] = topic . IconCustomEmojiID
}
_ , err := b . Raw ( "createForumTopic" , params )
return err
data , err := b . Raw ( "createForumTopic" , params )
if err != nil {
return nil , err
}
var resp struct {
Result * Topic
}
if err := json . Unmarshal ( data , & resp ) ; err != nil {
return nil , wrapError ( err )
}
return resp . Result , err
}
// EditTopic edits name and icon of a topic in a forum supergroup chat.
func ( b * Bot ) EditTopic ( chat * Chat , forum * Topic ) error {
func ( b * Bot ) EditTopic ( chat * Chat , topic * Topic ) error {
params := map [ string ] interface { } {
"chat_id" : chat . Recipient ( ) ,
"message_thread_id" : forum . ThreadID ,
"message_thread_id" : topic . ThreadID ,
}
if forum . Name != "" {
params [ "name" ] = forum . Name
if topic . Name != "" {
params [ "name" ] = topic . Name
}
if forum . IconCustomEmojiID != "" {
params [ "icon_custom_emoji_id" ] = forum . IconCustomEmojiID
if topic . IconCustomEmojiID != "" {
params [ "icon_custom_emoji_id" ] = topic . IconCustomEmojiID
}
_ , err := b . Raw ( "editForumTopic" , params )
@ -59,10 +59,10 @@ func (b *Bot) EditTopic(chat *Chat, forum *Topic) error {
}
// CloseTopic closes an open topic in a forum supergroup chat.
func ( b * Bot ) CloseTopic ( chat * Chat , forum * Topic ) error {
func ( b * Bot ) CloseTopic ( chat * Chat , topic * Topic ) error {
params := map [ string ] interface { } {
"chat_id" : chat . Recipient ( ) ,
"message_thread_id" : forum . ThreadID ,
"message_thread_id" : topic . ThreadID ,
}
_ , err := b . Raw ( "closeForumTopic" , params )
@ -70,10 +70,10 @@ func (b *Bot) CloseTopic(chat *Chat, forum *Topic) error {
}
// ReopenTopic reopens a closed topic in a forum supergroup chat.
func ( b * Bot ) ReopenTopic ( chat * Chat , forum * Topic ) error {
func ( b * Bot ) ReopenTopic ( chat * Chat , topic * Topic ) error {
params := map [ string ] interface { } {
"chat_id" : chat . Recipient ( ) ,
"message_thread_id" : forum . ThreadID ,
"message_thread_id" : topic . ThreadID ,
}
_ , err := b . Raw ( "reopenForumTopic" , params )
@ -81,10 +81,10 @@ func (b *Bot) ReopenTopic(chat *Chat, forum *Topic) error {
}
// DeleteTopic deletes a forum topic along with all its messages in a forum supergroup chat.
func ( b * Bot ) DeleteTopic ( chat * Chat , forum * Topic ) error {
func ( b * Bot ) DeleteTopic ( chat * Chat , topic * Topic ) error {
params := map [ string ] interface { } {
"chat_id" : chat . Recipient ( ) ,
"message_thread_id" : forum . ThreadID ,
"message_thread_id" : topic . ThreadID ,
}
_ , err := b . Raw ( "deleteForumTopic" , params )
@ -92,10 +92,10 @@ func (b *Bot) DeleteTopic(chat *Chat, forum *Topic) error {
}
// UnpinAllTopicMessages clears the list of pinned messages in a 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 ) UnpinAllTopicMessages ( chat * Chat , forum * Topic ) error {
func ( b * Bot ) UnpinAllTopicMessages ( chat * Chat , topic * Topic ) error {
params := map [ string ] interface { } {
"chat_id" : chat . Recipient ( ) ,
"message_thread_id" : forum . ThreadID ,
"message_thread_id" : topic . ThreadID ,
}
_ , err := b . Raw ( "unpinAllForumTopicMessages" , params )
@ -121,10 +121,10 @@ func (b *Bot) TopicIconStickers() ([]Sticker, error) {
}
// EditGeneralTopic edits name of the 'General' topic in a forum supergroup chat.
func ( b * Bot ) EditGeneralTopic ( chat * Chat , forum * Topic ) error {
func ( b * Bot ) EditGeneralTopic ( chat * Chat , topic * Topic ) error {
params := map [ string ] interface { } {
"chat_id" : chat . Recipient ( ) ,
"name" : forum . Name ,
"name" : topic . Name ,
}
_ , err := b . Raw ( "editGeneralForumTopic" , params )
@ -132,7 +132,7 @@ func (b *Bot) EditGeneralTopic(chat *Chat, forum *Topic) error {
}
// CloseGeneralTopic closes an open 'General' topic in a forum supergroup chat.
func ( b * Bot ) CloseGeneralTopic ( chat * Chat , forum * Topic ) error {
func ( b * Bot ) CloseGeneralTopic ( chat * Chat ) error {
params := map [ string ] interface { } {
"chat_id" : chat . Recipient ( ) ,
}
@ -142,7 +142,7 @@ func (b *Bot) CloseGeneralTopic(chat *Chat, forum *Topic) error {
}
// ReopenGeneralTopic reopens a closed 'General' topic in a forum supergroup chat.
func ( b * Bot ) ReopenGeneralTopic ( chat * Chat , forum * Topic ) error {
func ( b * Bot ) ReopenGeneralTopic ( chat * Chat ) error {
params := map [ string ] interface { } {
"chat_id" : chat . Recipient ( ) ,
}
@ -152,7 +152,7 @@ func (b *Bot) ReopenGeneralTopic(chat *Chat, forum *Topic) error {
}
// HideGeneralTopic hides the 'General' topic in a forum supergroup chat.
func ( b * Bot ) HideGeneralTopic ( chat * Chat , forum * Topic ) error {
func ( b * Bot ) HideGeneralTopic ( chat * Chat ) error {
params := map [ string ] interface { } {
"chat_id" : chat . Recipient ( ) ,
}
@ -162,7 +162,7 @@ func (b *Bot) HideGeneralTopic(chat *Chat, forum *Topic) error {
}
// UnhideGeneralTopic unhides the 'General' topic in a forum supergroup chat.
func ( b * Bot ) UnhideGeneralTopic ( chat * Chat , forum * Topic ) error {
func ( b * Bot ) UnhideGeneralTopic ( chat * Chat ) error {
params := map [ string ] interface { } {
"chat_id" : chat . Recipient ( ) ,
}