Add Params to ChatAPI instance so we can fill it with data
This commit is contained in:
12
chatIn.go
12
chatIn.go
@ -103,7 +103,9 @@ func heartbeat(c chan<- ChatAPI, freq time.Duration) {
|
||||
// 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{}
|
||||
m := ChatAPI{
|
||||
Params: ¶ms{},
|
||||
}
|
||||
m.Method = "read"
|
||||
m.Params.Options.Channel = c.Channel
|
||||
if len(count) == 0 {
|
||||
@ -125,7 +127,9 @@ func (c Chat) Read(count ...int) (*ChatAPI, error) {
|
||||
// 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{}
|
||||
m := ChatAPI{
|
||||
Params: ¶ms{},
|
||||
}
|
||||
m.Method = "read"
|
||||
m.Params.Options.Channel = c.Result.Messages[0].Msg.Channel
|
||||
if len(count) == 0 {
|
||||
@ -150,7 +154,9 @@ func (c *ChatAPI) Next(count ...int) (*ChatAPI, error) {
|
||||
// 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{}
|
||||
m := ChatAPI{
|
||||
Params: ¶ms{},
|
||||
}
|
||||
m.Method = "read"
|
||||
m.Params.Options.Channel = c.Result.Messages[0].Msg.Channel
|
||||
if len(count) == 0 {
|
||||
|
||||
16
chatOut.go
16
chatOut.go
@ -26,7 +26,9 @@ func chatAPIOut(keybasePath string, c ChatAPI) (ChatAPI, error) {
|
||||
|
||||
// Send sends a chat message
|
||||
func (c Chat) Send(message ...string) (ChatAPI, error) {
|
||||
m := ChatAPI{}
|
||||
m := ChatAPI{
|
||||
Params: ¶ms{},
|
||||
}
|
||||
m.Method = "send"
|
||||
m.Params.Options.Channel = c.Channel
|
||||
m.Params.Options.Message.Body = strings.Join(message, " ")
|
||||
@ -40,7 +42,9 @@ func (c Chat) Send(message ...string) (ChatAPI, error) {
|
||||
|
||||
// Edit edits a previously sent chat message
|
||||
func (c Chat) Edit(messageId int, message ...string) (ChatAPI, error) {
|
||||
m := ChatAPI{}
|
||||
m := ChatAPI{
|
||||
Params: ¶ms{},
|
||||
}
|
||||
m.Method = "edit"
|
||||
m.Params.Options.Channel = c.Channel
|
||||
m.Params.Options.Message.Body = strings.Join(message, " ")
|
||||
@ -55,7 +59,9 @@ func (c Chat) Edit(messageId int, message ...string) (ChatAPI, error) {
|
||||
|
||||
// React sends a reaction to a message.
|
||||
func (c Chat) React(messageId int, reaction string) (ChatAPI, error) {
|
||||
m := ChatAPI{}
|
||||
m := ChatAPI{
|
||||
Params: ¶ms{},
|
||||
}
|
||||
m.Method = "reaction"
|
||||
m.Params.Options.Channel = c.Channel
|
||||
m.Params.Options.Message.Body = reaction
|
||||
@ -70,7 +76,9 @@ func (c Chat) React(messageId int, reaction string) (ChatAPI, error) {
|
||||
|
||||
// Delete deletes a chat message
|
||||
func (c Chat) Delete(messageId int) (ChatAPI, error) {
|
||||
m := ChatAPI{}
|
||||
m := ChatAPI{
|
||||
Params: ¶ms{},
|
||||
}
|
||||
m.Method = "delete"
|
||||
m.Params.Options.Channel = c.Channel
|
||||
m.Params.Options.MessageID = messageId
|
||||
|
||||
Reference in New Issue
Block a user