5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-29 18:41:36 +00:00

Update vendor (slack)

This commit is contained in:
Wim 2017-01-28 00:36:22 +01:00
parent dcccd43427
commit 482fbac68f
8 changed files with 92 additions and 43 deletions

View File

@ -30,7 +30,7 @@ func botRequest(path string, values url.Values, debug bool) (*botResponseFull, e
return response, nil 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) { func (api *Client) GetBotInfo(bot string) (*Bot, error) {
values := url.Values{ values := url.Values{
"token": {api.config.token}, "token": {api.config.token},

View File

@ -29,18 +29,18 @@ type chatResponseFull struct {
// PostMessageParameters contains all the parameters necessary (including the optional ones) for a PostMessage() request // PostMessageParameters contains all the parameters necessary (including the optional ones) for a PostMessage() request
type PostMessageParameters struct { type PostMessageParameters struct {
Text string Text string `json:"text"`
Username string Username string `json:"user_name"`
AsUser bool AsUser bool `json:"as_user"`
Parse string Parse string `json:"parse"`
LinkNames int LinkNames int `json:"link_names"`
Attachments []Attachment Attachments []Attachment `json:"attachments"`
UnfurlLinks bool UnfurlLinks bool `json:"unfurl_links"`
UnfurlMedia bool UnfurlMedia bool `json:"unfurl_media"`
IconURL string IconURL string `json:"icon_url"`
IconEmoji string IconEmoji string `json:"icon_emoji"`
Markdown bool `json:"mrkdwn,omitempty"` Markdown bool `json:"mrkdwn,omitempty"`
EscapeText bool EscapeText bool `json:"escape_text"`
} }
// NewPostMessageParameters provides an instance of PostMessageParameters with all the sane default values set // NewPostMessageParameters provides an instance of PostMessageParameters with all the sane default values set

View File

@ -17,10 +17,7 @@ func main() {
rtm := api.NewRTM() rtm := api.NewRTM()
go rtm.ManageConnection() go rtm.ManageConnection()
Loop: for msg := range rtm.IncomingEvents {
for {
select {
case msg := <-rtm.IncomingEvents:
fmt.Print("Event Received: ") fmt.Print("Event Received: ")
switch ev := msg.Data.(type) { switch ev := msg.Data.(type) {
case *slack.HelloEvent: case *slack.HelloEvent:
@ -46,7 +43,7 @@ Loop:
case *slack.InvalidAuthEvent: case *slack.InvalidAuthEvent:
fmt.Printf("Invalid credentials") fmt.Printf("Invalid credentials")
break Loop return
default: default:
@ -55,4 +52,3 @@ Loop:
} }
} }
} }
}

View File

@ -198,3 +198,13 @@ func (info Info) GetGroupByID(groupID string) *Group {
} }
return nil 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
}

View File

@ -8,6 +8,7 @@ import (
type OAuthResponseIncomingWebhook struct { type OAuthResponseIncomingWebhook struct {
URL string `json:"url"` URL string `json:"url"`
Channel string `json:"channel"` Channel string `json:"channel"`
ChannelID string `json:"channel_id,omitempty"`
ConfigurationURL string `json:"configuration_url"` ConfigurationURL string `json:"configuration_url"`
} }
@ -23,6 +24,7 @@ type OAuthResponse struct {
TeamID string `json:"team_id"` TeamID string `json:"team_id"`
IncomingWebhook OAuthResponseIncomingWebhook `json:"incoming_webhook"` IncomingWebhook OAuthResponseIncomingWebhook `json:"incoming_webhook"`
Bot OAuthResponseBot `json:"bot"` Bot OAuthResponseBot `json:"bot"`
UserID string `json:"user_id,omitempty"`
SlackResponse SlackResponse
} }

View File

@ -44,6 +44,16 @@ type Login struct {
Region string `json:"region"` 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 // AccessLogParameters contains all the parameters necessary (including the optional ones) for a GetAccessLogs() request
type AccessLogParameters struct { type AccessLogParameters struct {
Count int Count int
@ -73,6 +83,20 @@ func teamRequest(path string, values url.Values, debug bool) (*TeamResponse, err
return response, nil 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) { func accessLogsRequest(path string, values url.Values, debug bool) (*LoginResponse, error) {
response := &LoginResponse{} response := &LoginResponse{}
err := post(path, values, response, debug) err := post(path, values, response, debug)
@ -117,3 +141,20 @@ func (api *Client) GetAccessLogs(params AccessLogParameters) ([]Login, *Paging,
return response.Logins, &response.Paging, nil 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)
}

View File

@ -122,7 +122,7 @@ func (api *Client) GetUserPresence(user string) (*UserPresence, error) {
return &response.UserPresence, nil 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) { func (api *Client) GetUserInfo(user string) (*User, error) {
values := url.Values{ values := url.Values{
"token": {api.config.token}, "token": {api.config.token},

2
vendor/manifest vendored
View File

@ -146,7 +146,7 @@
"importpath": "github.com/nlopes/slack", "importpath": "github.com/nlopes/slack",
"repository": "https://github.com/nlopes/slack", "repository": "https://github.com/nlopes/slack",
"vcs": "git", "vcs": "git",
"revision": "e595e9d8590a04ff76407e4e7d1791d25b095c66", "revision": "248e1d53d27901137764ae625890c127bf67e7aa",
"branch": "master", "branch": "master",
"notests": true "notests": true
}, },