diff --git a/info.go b/info.go index 9cf4cf3..17178bb 100644 --- a/info.go +++ b/info.go @@ -157,7 +157,7 @@ type infoResponseFull struct { Info - SlackWSResponse + SlackWebResponse } // GetBotByID returns a bot given a bot id diff --git a/websocket_managed_conn.go b/websocket_managed_conn.go index d16df7b..319ad1a 100644 --- a/websocket_managed_conn.go +++ b/websocket_managed_conn.go @@ -49,7 +49,7 @@ info, conn, err = rtm.startRTMAndDial() if err == nil { break // connected - } else if sErr, ok := err.(*SlackWSError); ok { + } else if sErr, ok := err.(*SlackWebError); ok { if sErr.Error() == "invalid_auth" { rtm.IncomingEvents <- SlackEvent{"invalid_auth", &InvalidAuthEvent{}} return diff --git a/websocket_misc.go b/websocket_misc.go index 512bcb2..93476b9 100644 --- a/websocket_misc.go +++ b/websocket_misc.go @@ -1,6 +1,9 @@ package slack -import "encoding/json" +import ( + "encoding/json" + "fmt" +) // AckMessage is used for messages received in reply to other messages type AckMessage struct { @@ -10,15 +13,29 @@ SlackWSResponse } +type SlackWebResponse struct { + Ok bool `json:"ok"` + Error *SlackWebError `json:"error"` +} + +type SlackWebError string + +func (s SlackWebError) Error() string { + return string(s) +} + type SlackWSResponse struct { Ok bool `json:"ok"` Error *SlackWSError `json:"error"` } -type SlackWSError string +type SlackWSError struct { + Code int + Msg string +} func (s SlackWSError) Error() string { - return string(s) + return fmt.Sprintf("Code %d - %s", s.Code, s.Msg) } type MessageEvent Message