diff options
Diffstat (limited to 'vendor/github.com/nlopes/slack')
-rw-r--r-- | vendor/github.com/nlopes/slack/bots.go | 2 | ||||
-rw-r--r-- | vendor/github.com/nlopes/slack/chat.go | 24 | ||||
-rw-r--r-- | vendor/github.com/nlopes/slack/examples/websocket/websocket.go | 68 | ||||
-rw-r--r-- | vendor/github.com/nlopes/slack/info.go | 10 | ||||
-rw-r--r-- | vendor/github.com/nlopes/slack/oauth.go | 2 | ||||
-rw-r--r-- | vendor/github.com/nlopes/slack/team.go | 41 | ||||
-rw-r--r-- | vendor/github.com/nlopes/slack/users.go | 2 |
7 files changed, 99 insertions, 50 deletions
diff --git a/vendor/github.com/nlopes/slack/bots.go b/vendor/github.com/nlopes/slack/bots.go index dc031ef5..555915e4 100644 --- a/vendor/github.com/nlopes/slack/bots.go +++ b/vendor/github.com/nlopes/slack/bots.go @@ -30,7 +30,7 @@ func botRequest(path string, values url.Values, debug bool) (*botResponseFull, e return response, nil } -// GetBotInfo will retrive the complete bot information +// GetBotInfo will retrieve the complete bot information func (api *Client) GetBotInfo(bot string) (*Bot, error) { values := url.Values{ "token": {api.config.token}, diff --git a/vendor/github.com/nlopes/slack/chat.go b/vendor/github.com/nlopes/slack/chat.go index 52a3420f..120c6be7 100644 --- a/vendor/github.com/nlopes/slack/chat.go +++ b/vendor/github.com/nlopes/slack/chat.go @@ -29,18 +29,18 @@ type chatResponseFull struct { // PostMessageParameters contains all the parameters necessary (including the optional ones) for a PostMessage() request type PostMessageParameters struct { - Text string - Username string - AsUser bool - Parse string - LinkNames int - Attachments []Attachment - UnfurlLinks bool - UnfurlMedia bool - IconURL string - IconEmoji string - Markdown bool `json:"mrkdwn,omitempty"` - EscapeText bool + Text string `json:"text"` + Username string `json:"user_name"` + AsUser bool `json:"as_user"` + Parse string `json:"parse"` + LinkNames int `json:"link_names"` + Attachments []Attachment `json:"attachments"` + UnfurlLinks bool `json:"unfurl_links"` + UnfurlMedia bool `json:"unfurl_media"` + IconURL string `json:"icon_url"` + IconEmoji string `json:"icon_emoji"` + Markdown bool `json:"mrkdwn,omitempty"` + EscapeText bool `json:"escape_text"` } // NewPostMessageParameters provides an instance of PostMessageParameters with all the sane default values set diff --git a/vendor/github.com/nlopes/slack/examples/websocket/websocket.go b/vendor/github.com/nlopes/slack/examples/websocket/websocket.go index 612b97c0..d02caadd 100644 --- a/vendor/github.com/nlopes/slack/examples/websocket/websocket.go +++ b/vendor/github.com/nlopes/slack/examples/websocket/websocket.go @@ -17,42 +17,38 @@ func main() { rtm := api.NewRTM() go rtm.ManageConnection() -Loop: - for { - select { - case msg := <-rtm.IncomingEvents: - fmt.Print("Event Received: ") - switch ev := msg.Data.(type) { - case *slack.HelloEvent: - // Ignore hello - - case *slack.ConnectedEvent: - fmt.Println("Infos:", ev.Info) - fmt.Println("Connection counter:", ev.ConnectionCount) - // Replace #general with your Channel ID - rtm.SendMessage(rtm.NewOutgoingMessage("Hello world", "#general")) - - case *slack.MessageEvent: - fmt.Printf("Message: %v\n", ev) - - case *slack.PresenceChangeEvent: - fmt.Printf("Presence Change: %v\n", ev) - - case *slack.LatencyReport: - fmt.Printf("Current latency: %v\n", ev.Value) - - case *slack.RTMError: - fmt.Printf("Error: %s\n", ev.Error()) - - case *slack.InvalidAuthEvent: - fmt.Printf("Invalid credentials") - break Loop - - default: - - // Ignore other events.. - // fmt.Printf("Unexpected: %v\n", msg.Data) - } + for msg := range rtm.IncomingEvents { + fmt.Print("Event Received: ") + switch ev := msg.Data.(type) { + case *slack.HelloEvent: + // Ignore hello + + case *slack.ConnectedEvent: + fmt.Println("Infos:", ev.Info) + fmt.Println("Connection counter:", ev.ConnectionCount) + // Replace #general with your Channel ID + rtm.SendMessage(rtm.NewOutgoingMessage("Hello world", "#general")) + + case *slack.MessageEvent: + fmt.Printf("Message: %v\n", ev) + + case *slack.PresenceChangeEvent: + fmt.Printf("Presence Change: %v\n", ev) + + case *slack.LatencyReport: + fmt.Printf("Current latency: %v\n", ev.Value) + + case *slack.RTMError: + fmt.Printf("Error: %s\n", ev.Error()) + + case *slack.InvalidAuthEvent: + fmt.Printf("Invalid credentials") + return + + default: + + // Ignore other events.. + // fmt.Printf("Unexpected: %v\n", msg.Data) } } } diff --git a/vendor/github.com/nlopes/slack/info.go b/vendor/github.com/nlopes/slack/info.go index 445df832..49db5327 100644 --- a/vendor/github.com/nlopes/slack/info.go +++ b/vendor/github.com/nlopes/slack/info.go @@ -198,3 +198,13 @@ func (info Info) GetGroupByID(groupID string) *Group { } return nil } + +// GetIMByID returns an IM given an IM id +func (info Info) GetIMByID(imID string) *IM { + for _, im := range info.IMs { + if im.ID == imID { + return &im + } + } + return nil +} diff --git a/vendor/github.com/nlopes/slack/oauth.go b/vendor/github.com/nlopes/slack/oauth.go index 33c3ed2d..1285abbd 100644 --- a/vendor/github.com/nlopes/slack/oauth.go +++ b/vendor/github.com/nlopes/slack/oauth.go @@ -8,6 +8,7 @@ import ( type OAuthResponseIncomingWebhook struct { URL string `json:"url"` Channel string `json:"channel"` + ChannelID string `json:"channel_id,omitempty"` ConfigurationURL string `json:"configuration_url"` } @@ -23,6 +24,7 @@ type OAuthResponse struct { TeamID string `json:"team_id"` IncomingWebhook OAuthResponseIncomingWebhook `json:"incoming_webhook"` Bot OAuthResponseBot `json:"bot"` + UserID string `json:"user_id,omitempty"` SlackResponse } diff --git a/vendor/github.com/nlopes/slack/team.go b/vendor/github.com/nlopes/slack/team.go index d4e7899f..61b6a0a1 100644 --- a/vendor/github.com/nlopes/slack/team.go +++ b/vendor/github.com/nlopes/slack/team.go @@ -44,6 +44,16 @@ type Login struct { Region string `json:"region"` } +type BillableInfoResponse struct { + BillableInfo map[string]BillingActive `json:"billable_info"` + SlackResponse + +} + +type BillingActive struct { + BillingActive bool `json:"billing_active"` +} + // AccessLogParameters contains all the parameters necessary (including the optional ones) for a GetAccessLogs() request type AccessLogParameters struct { Count int @@ -73,6 +83,20 @@ func teamRequest(path string, values url.Values, debug bool) (*TeamResponse, err return response, nil } +func billableInfoRequest(path string, values url.Values, debug bool) (map[string]BillingActive, error) { + response := &BillableInfoResponse{} + err := post(path, values, response, debug) + if err != nil { + return nil, err + } + + if !response.Ok { + return nil, errors.New(response.Error) + } + + return response.BillableInfo, nil +} + func accessLogsRequest(path string, values url.Values, debug bool) (*LoginResponse, error) { response := &LoginResponse{} err := post(path, values, response, debug) @@ -117,3 +141,20 @@ func (api *Client) GetAccessLogs(params AccessLogParameters) ([]Login, *Paging, return response.Logins, &response.Paging, nil } +func (api *Client) GetBillableInfo(user string) (map[string]BillingActive, error) { + values := url.Values{ + "token": {api.config.token}, + "user": {user}, + } + + return billableInfoRequest("team.billableInfo", values, api.debug) +} + +// GetBillableInfoForTeam returns the billing_active status of all users on the team. +func (api *Client) GetBillableInfoForTeam() (map[string]BillingActive, error) { + values := url.Values{ + "token": {api.config.token}, + } + + return billableInfoRequest("team.billableInfo", values, api.debug) +} diff --git a/vendor/github.com/nlopes/slack/users.go b/vendor/github.com/nlopes/slack/users.go index f2d5447f..c71f4ee2 100644 --- a/vendor/github.com/nlopes/slack/users.go +++ b/vendor/github.com/nlopes/slack/users.go @@ -122,7 +122,7 @@ func (api *Client) GetUserPresence(user string) (*UserPresence, error) { return &response.UserPresence, nil } -// GetUserInfo will retrive the complete user information +// GetUserInfo will retrieve the complete user information func (api *Client) GetUserInfo(user string) (*User, error) { values := url.Values{ "token": {api.config.token}, |