From 1b089d2833ef1ccf8faf490e4801881de7332368 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 25 Jul 2019 11:23:09 -0400 Subject: [PATCH] Add Params to ChatAPI instance so we can fill it with data --- chatIn.go | 12 +++++++++--- chatOut.go | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/chatIn.go b/chatIn.go index 4fc2932..2746c6a 100644 --- a/chatIn.go +++ b/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 { diff --git a/chatOut.go b/chatOut.go index 5397ffb..68b131e 100644 --- a/chatOut.go +++ b/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