Skip to content

Commit

Permalink
Add .ReplyAlbum and .RespondAlbum for Message Type.
Browse files Browse the repository at this point in the history
  • Loading branch information
AmarnathCJD committed Aug 11, 2024
1 parent 4c9cd93 commit 60ceea0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion telegram/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func (c *Client) sendAlbum(Peer InputPeer, Album []*InputSingleMedia, sendAs Inp
m = append(m, packMessage(c, update))
}
} else {
return nil, errors.New("no response")
return nil, errors.New("no response for sendAlbum")
}
return m, nil
}
Expand Down
16 changes: 16 additions & 0 deletions telegram/newmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ func (m *NewMessage) ReplyMedia(Media interface{}, Opts ...MediaOptions) (*NewMe
} else {
Opts[0].ReplyID = m.ID
}

resp, err := m.Client.SendMedia(m.ChatID(), Media, &Opts[0])
if err != nil {
return nil, err
Expand All @@ -560,6 +561,14 @@ func (m *NewMessage) ReplyMedia(Media interface{}, Opts ...MediaOptions) (*NewMe
return &response, err
}

func (m *NewMessage) ReplyAlbum(Album any, Opts ...*MediaOptions) ([]*NewMessage, error) {
if len(Opts) == 0 {
Opts = append(Opts, &MediaOptions{})
}
Opts[0].ReplyID = m.ID
return m.Client.SendAlbum(m.ChatID(), Album, Opts...)
}

func (m *NewMessage) RespondMedia(Media interface{}, Opts ...MediaOptions) (*NewMessage, error) {
if len(Opts) == 0 {
Opts = append(Opts, MediaOptions{})
Expand All @@ -573,6 +582,13 @@ func (m *NewMessage) RespondMedia(Media interface{}, Opts ...MediaOptions) (*New
return &response, err
}

func (m *NewMessage) RespondAlbum(Album any, Opts ...*MediaOptions) ([]*NewMessage, error) {
if len(Opts) == 0 {
Opts = append(Opts, &MediaOptions{})
}
return m.Client.SendAlbum(m.ChatID(), Album, Opts...)
}

// Delete deletes the message
func (m *NewMessage) Delete() (*MessagesAffectedMessages, error) {
return m.Client.DeleteMessages(m.Peer, []int32{m.ID})
Expand Down

0 comments on commit 60ceea0

Please sign in to comment.