Change API for ChannelMessages to accept Message ID's as strings. Fixes #120

This commit is contained in:
Chris Rhodes 2016-02-20 14:21:25 -08:00
parent e1a88003e6
commit 50b7bdd6ff

View file

@ -794,7 +794,7 @@ func (s *Session) ChannelTyping(channelID string) (err error) {
// limit : The number messages that can be returned. // limit : The number messages that can be returned.
// beforeID : If provided all messages returned will be before given ID. // beforeID : If provided all messages returned will be before given ID.
// afterID : If provided all messages returned will be after given ID. // afterID : If provided all messages returned will be after given ID.
func (s *Session) ChannelMessages(channelID string, limit int, beforeID int, afterID int) (st []*Message, err error) { func (s *Session) ChannelMessages(channelID string, limit int, beforeID, afterID string) (st []*Message, err error) {
uri := CHANNEL_MESSAGES(channelID) uri := CHANNEL_MESSAGES(channelID)
@ -802,11 +802,11 @@ func (s *Session) ChannelMessages(channelID string, limit int, beforeID int, aft
if limit > 0 { if limit > 0 {
v.Set("limit", strconv.Itoa(limit)) v.Set("limit", strconv.Itoa(limit))
} }
if afterID > 0 { if afterID != "" {
v.Set("after", strconv.Itoa(afterID)) v.Set("after", afterID)
} }
if beforeID > 0 { if beforeID != "" {
v.Set("before", strconv.Itoa(beforeID)) v.Set("before", beforeID)
} }
if len(v) > 0 { if len(v) > 0 {
uri = fmt.Sprintf("%s?%s", uri, v.Encode()) uri = fmt.Sprintf("%s?%s", uri, v.Encode())