Browse Source

Remove chat.Read() chat.Next() and chat.Previous() as they have been replaced

main
Sam 4 years ago
parent
commit
8cef252023
  1. 89
      chat.go

89
chat.go

@ -559,95 +559,6 @@ func (c Chat) ReadMessage(messageID int) (*ChatAPI, error) { @@ -559,95 +559,6 @@ func (c Chat) ReadMessage(messageID int) (*ChatAPI, error) {
return &r, nil
}
// Read fetches chat messages from a conversation. By default, 10 messages will
// be fetched at a time. However, if count is passed, then that is the number of
// messages that will be fetched.
func (c Chat) Read(count ...int) (*ChatAPI, error) {
m := ChatAPI{
Params: &params{},
}
m.Params.Options = options{
Pagination: &pagination{},
}
m.Method = "read"
m.Params.Options.Channel = &c.Channel
if len(count) == 0 {
m.Params.Options.Pagination.Num = 10
} else {
m.Params.Options.Pagination.Num = count[0]
}
r, err := chatAPIOut(c.keybase, m)
if err != nil {
return &r, err
}
r.keybase = *c.keybase
return &r, nil
}
// Next fetches the next page of chat messages that were fetched with Read. By
// default, Next will fetch the same amount of messages that were originally
// fetched with Read. However, if count is passed, then that is the number of
// messages that will be fetched.
func (c *ChatAPI) Next(count ...int) (*ChatAPI, error) {
m := ChatAPI{
Params: &params{},
}
m.Params.Options = options{
Pagination: &pagination{},
}
m.Method = "read"
m.Params.Options.Channel = &c.Result.Messages[0].Msg.Channel
if len(count) == 0 {
m.Params.Options.Pagination.Num = c.Result.Pagination.Num
} else {
m.Params.Options.Pagination.Num = count[0]
}
m.Params.Options.Pagination.Next = c.Result.Pagination.Next
result, err := chatAPIOut(&c.keybase, m)
if err != nil {
return &result, err
}
k := c.keybase
*c = result
c.keybase = k
return c, nil
}
// Previous fetches the previous page of chat messages that were fetched with Read.
// By default, Previous will fetch the same amount of messages that were
// originally fetched with Read. However, if count is passed, then that is the
// number of messages that will be fetched.
func (c *ChatAPI) Previous(count ...int) (*ChatAPI, error) {
m := ChatAPI{
Params: &params{},
}
m.Params.Options = options{
Pagination: &pagination{},
}
m.Method = "read"
m.Params.Options.Channel = &c.Result.Messages[0].Msg.Channel
if len(count) == 0 {
m.Params.Options.Pagination.Num = c.Result.Pagination.Num
} else {
m.Params.Options.Pagination.Num = count[0]
}
m.Params.Options.Pagination.Previous = c.Result.Pagination.Previous
result, err := chatAPIOut(&c.keybase, m)
if err != nil {
return &result, err
}
k := c.keybase
*c = result
c.keybase = k
return c, nil
}
// Upload attaches a file to a conversation
// The filepath must be an absolute path
func (c Chat) Upload(title string, filepath string) (ChatAPI, error) {

Loading…
Cancel
Save