repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/util.go
HandleCrash
func HandleCrash(additionalHandlers ...func(interface{})) { if ReallyCrash { return } if r := recover(); r != nil { for _, fn := range PanicHandlers { fn(r) } for _, fn := range additionalHandlers { fn(r) } } }
go
func HandleCrash(additionalHandlers ...func(interface{})) { if ReallyCrash { return } if r := recover(); r != nil { for _, fn := range PanicHandlers { fn(r) } for _, fn := range additionalHandlers { fn(r) } } }
[ "func", "HandleCrash", "(", "additionalHandlers", "...", "func", "(", "interface", "{", "}", ")", ")", "{", "if", "ReallyCrash", "{", "return", "\n", "}", "\n", "if", "r", ":=", "recover", "(", ")", ";", "r", "!=", "nil", "{", "for", "_", ",", "fn", ":=", "range", "PanicHandlers", "{", "fn", "(", "r", ")", "\n", "}", "\n", "for", "_", ",", "fn", ":=", "range", "additionalHandlers", "{", "fn", "(", "r", ")", "\n", "}", "\n", "}", "\n", "}" ]
// HandleCrash simply catches a crash and logs an error. Meant to be called via defer. // Additional context-specific handlers can be provided, and will be called in case of panic
[ "HandleCrash", "simply", "catches", "a", "crash", "and", "logs", "an", "error", ".", "Meant", "to", "be", "called", "via", "defer", ".", "Additional", "context", "-", "specific", "handlers", "can", "be", "provided", "and", "will", "be", "called", "in", "case", "of", "panic" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/util.go#L58-L70
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/util.go
Until
func Until(f func(), period time.Duration, stopCh <-chan struct{}) { select { case <-stopCh: return default: } for { func() { defer HandleCrash() f() }() select { case <-stopCh: return case <-time.After(period): } } }
go
func Until(f func(), period time.Duration, stopCh <-chan struct{}) { select { case <-stopCh: return default: } for { func() { defer HandleCrash() f() }() select { case <-stopCh: return case <-time.After(period): } } }
[ "func", "Until", "(", "f", "func", "(", ")", ",", "period", "time", ".", "Duration", ",", "stopCh", "<-", "chan", "struct", "{", "}", ")", "{", "select", "{", "case", "<-", "stopCh", ":", "return", "\n", "default", ":", "}", "\n\n", "for", "{", "func", "(", ")", "{", "defer", "HandleCrash", "(", ")", "\n", "f", "(", ")", "\n", "}", "(", ")", "\n", "select", "{", "case", "<-", "stopCh", ":", "return", "\n", "case", "<-", "time", ".", "After", "(", "period", ")", ":", "}", "\n", "}", "\n", "}" ]
// Until loops until stop channel is closed, running f every period. // Catches any panics, and keeps going. f may not be invoked if // stop channel is already closed. Pass NeverStop to Until if you // don't want it stop.
[ "Until", "loops", "until", "stop", "channel", "is", "closed", "running", "f", "every", "period", ".", "Catches", "any", "panics", "and", "keeps", "going", ".", "f", "may", "not", "be", "invoked", "if", "stop", "channel", "is", "already", "closed", ".", "Pass", "NeverStop", "to", "Until", "if", "you", "don", "t", "want", "it", "stop", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/util.go#L116-L134
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/util.go
SplitQualifiedName
func SplitQualifiedName(str string) (string, string) { parts := strings.Split(str, "/") if len(parts) < 2 { return "", str } return parts[0], parts[1] }
go
func SplitQualifiedName(str string) (string, string) { parts := strings.Split(str, "/") if len(parts) < 2 { return "", str } return parts[0], parts[1] }
[ "func", "SplitQualifiedName", "(", "str", "string", ")", "(", "string", ",", "string", ")", "{", "parts", ":=", "strings", ".", "Split", "(", "str", ",", "\"", "\"", ")", "\n", "if", "len", "(", "parts", ")", "<", "2", "{", "return", "\"", "\"", ",", "str", "\n", "}", "\n\n", "return", "parts", "[", "0", "]", ",", "parts", "[", "1", "]", "\n", "}" ]
// Splits a fully qualified name and returns its namespace and name. // Assumes that the input 'str' has been validated.
[ "Splits", "a", "fully", "qualified", "name", "and", "returns", "its", "namespace", "and", "name", ".", "Assumes", "that", "the", "input", "str", "has", "been", "validated", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/util.go#L209-L216
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/util.go
getFinalIP
func getFinalIP(addrs []net.Addr) (net.IP, error) { if len(addrs) > 0 { for i := range addrs { glog.V(4).Infof("Checking addr %s.", addrs[i].String()) ip, _, err := net.ParseCIDR(addrs[i].String()) if err != nil { return nil, err } //Only IPv4 //TODO : add IPv6 support if ip.To4() != nil { if !ip.IsLoopback() && !ip.IsLinkLocalMulticast() && !ip.IsLinkLocalUnicast() { glog.V(4).Infof("IP found %v", ip) return ip, nil } else { glog.V(4).Infof("Loopback/link-local found %v", ip) } } else { glog.V(4).Infof("%v is not a valid IPv4 address", ip) } } } return nil, nil }
go
func getFinalIP(addrs []net.Addr) (net.IP, error) { if len(addrs) > 0 { for i := range addrs { glog.V(4).Infof("Checking addr %s.", addrs[i].String()) ip, _, err := net.ParseCIDR(addrs[i].String()) if err != nil { return nil, err } //Only IPv4 //TODO : add IPv6 support if ip.To4() != nil { if !ip.IsLoopback() && !ip.IsLinkLocalMulticast() && !ip.IsLinkLocalUnicast() { glog.V(4).Infof("IP found %v", ip) return ip, nil } else { glog.V(4).Infof("Loopback/link-local found %v", ip) } } else { glog.V(4).Infof("%v is not a valid IPv4 address", ip) } } } return nil, nil }
[ "func", "getFinalIP", "(", "addrs", "[", "]", "net", ".", "Addr", ")", "(", "net", ".", "IP", ",", "error", ")", "{", "if", "len", "(", "addrs", ")", ">", "0", "{", "for", "i", ":=", "range", "addrs", "{", "glog", ".", "V", "(", "4", ")", ".", "Infof", "(", "\"", "\"", ",", "addrs", "[", "i", "]", ".", "String", "(", ")", ")", "\n", "ip", ",", "_", ",", "err", ":=", "net", ".", "ParseCIDR", "(", "addrs", "[", "i", "]", ".", "String", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "//Only IPv4", "//TODO : add IPv6 support", "if", "ip", ".", "To4", "(", ")", "!=", "nil", "{", "if", "!", "ip", ".", "IsLoopback", "(", ")", "&&", "!", "ip", ".", "IsLinkLocalMulticast", "(", ")", "&&", "!", "ip", ".", "IsLinkLocalUnicast", "(", ")", "{", "glog", ".", "V", "(", "4", ")", ".", "Infof", "(", "\"", "\"", ",", "ip", ")", "\n", "return", "ip", ",", "nil", "\n", "}", "else", "{", "glog", ".", "V", "(", "4", ")", ".", "Infof", "(", "\"", "\"", ",", "ip", ")", "\n", "}", "\n", "}", "else", "{", "glog", ".", "V", "(", "4", ")", ".", "Infof", "(", "\"", "\"", ",", "ip", ")", "\n", "}", "\n\n", "}", "\n", "}", "\n", "return", "nil", ",", "nil", "\n", "}" ]
//getFinalIP method receives all the IP addrs of a Interface //and returns a nil if the address is Loopback, Ipv6, link-local or nil. //It returns a valid IPv4 if an Ipv4 address is found in the array.
[ "getFinalIP", "method", "receives", "all", "the", "IP", "addrs", "of", "a", "Interface", "and", "returns", "a", "nil", "if", "the", "address", "is", "Loopback", "Ipv6", "link", "-", "local", "or", "nil", ".", "It", "returns", "a", "valid", "IPv4", "if", "an", "Ipv4", "address", "is", "found", "in", "the", "array", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/util.go#L294-L318
train
nlopes/slack
conversation.go
GetUsersInConversation
func (api *Client) GetUsersInConversation(params *GetUsersInConversationParameters) ([]string, string, error) { return api.GetUsersInConversationContext(context.Background(), params) }
go
func (api *Client) GetUsersInConversation(params *GetUsersInConversationParameters) ([]string, string, error) { return api.GetUsersInConversationContext(context.Background(), params) }
[ "func", "(", "api", "*", "Client", ")", "GetUsersInConversation", "(", "params", "*", "GetUsersInConversationParameters", ")", "(", "[", "]", "string", ",", "string", ",", "error", ")", "{", "return", "api", ".", "GetUsersInConversationContext", "(", "context", ".", "Background", "(", ")", ",", "params", ")", "\n", "}" ]
// GetUsersInConversation returns the list of users in a conversation
[ "GetUsersInConversation", "returns", "the", "list", "of", "users", "in", "a", "conversation" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L81-L83
train
nlopes/slack
conversation.go
GetUsersInConversationContext
func (api *Client) GetUsersInConversationContext(ctx context.Context, params *GetUsersInConversationParameters) ([]string, string, error) { values := url.Values{ "token": {api.token}, "channel": {params.ChannelID}, } if params.Cursor != "" { values.Add("cursor", params.Cursor) } if params.Limit != 0 { values.Add("limit", strconv.Itoa(params.Limit)) } response := struct { Members []string `json:"members"` ResponseMetaData responseMetaData `json:"response_metadata"` SlackResponse }{} err := api.postMethod(ctx, "conversations.members", values, &response) if err != nil { return nil, "", err } if err := response.Err(); err != nil { return nil, "", err } return response.Members, response.ResponseMetaData.NextCursor, nil }
go
func (api *Client) GetUsersInConversationContext(ctx context.Context, params *GetUsersInConversationParameters) ([]string, string, error) { values := url.Values{ "token": {api.token}, "channel": {params.ChannelID}, } if params.Cursor != "" { values.Add("cursor", params.Cursor) } if params.Limit != 0 { values.Add("limit", strconv.Itoa(params.Limit)) } response := struct { Members []string `json:"members"` ResponseMetaData responseMetaData `json:"response_metadata"` SlackResponse }{} err := api.postMethod(ctx, "conversations.members", values, &response) if err != nil { return nil, "", err } if err := response.Err(); err != nil { return nil, "", err } return response.Members, response.ResponseMetaData.NextCursor, nil }
[ "func", "(", "api", "*", "Client", ")", "GetUsersInConversationContext", "(", "ctx", "context", ".", "Context", ",", "params", "*", "GetUsersInConversationParameters", ")", "(", "[", "]", "string", ",", "string", ",", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "params", ".", "ChannelID", "}", ",", "}", "\n", "if", "params", ".", "Cursor", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "Cursor", ")", "\n", "}", "\n", "if", "params", ".", "Limit", "!=", "0", "{", "values", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "params", ".", "Limit", ")", ")", "\n", "}", "\n", "response", ":=", "struct", "{", "Members", "[", "]", "string", "`json:\"members\"`", "\n", "ResponseMetaData", "responseMetaData", "`json:\"response_metadata\"`", "\n", "SlackResponse", "\n", "}", "{", "}", "\n", "err", ":=", "api", ".", "postMethod", "(", "ctx", ",", "\"", "\"", ",", "values", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "response", ".", "Err", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "response", ".", "Members", ",", "response", ".", "ResponseMetaData", ".", "NextCursor", ",", "nil", "\n", "}" ]
// GetUsersInConversationContext returns the list of users in a conversation with a custom context
[ "GetUsersInConversationContext", "returns", "the", "list", "of", "users", "in", "a", "conversation", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L86-L112
train
nlopes/slack
conversation.go
GetConversationsForUser
func (api *Client) GetConversationsForUser(params *GetConversationsForUserParameters) (channels []Channel, nextCursor string, err error) { return api.GetConversationsForUserContext(context.Background(), params) }
go
func (api *Client) GetConversationsForUser(params *GetConversationsForUserParameters) (channels []Channel, nextCursor string, err error) { return api.GetConversationsForUserContext(context.Background(), params) }
[ "func", "(", "api", "*", "Client", ")", "GetConversationsForUser", "(", "params", "*", "GetConversationsForUserParameters", ")", "(", "channels", "[", "]", "Channel", ",", "nextCursor", "string", ",", "err", "error", ")", "{", "return", "api", ".", "GetConversationsForUserContext", "(", "context", ".", "Background", "(", ")", ",", "params", ")", "\n", "}" ]
// GetConversationsForUser returns the list conversations for a given user
[ "GetConversationsForUser", "returns", "the", "list", "conversations", "for", "a", "given", "user" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L115-L117
train
nlopes/slack
conversation.go
ArchiveConversation
func (api *Client) ArchiveConversation(channelID string) error { return api.ArchiveConversationContext(context.Background(), channelID) }
go
func (api *Client) ArchiveConversation(channelID string) error { return api.ArchiveConversationContext(context.Background(), channelID) }
[ "func", "(", "api", "*", "Client", ")", "ArchiveConversation", "(", "channelID", "string", ")", "error", "{", "return", "api", ".", "ArchiveConversationContext", "(", "context", ".", "Background", "(", ")", ",", "channelID", ")", "\n", "}" ]
// ArchiveConversation archives a conversation
[ "ArchiveConversation", "archives", "a", "conversation" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L153-L155
train
nlopes/slack
conversation.go
UnArchiveConversation
func (api *Client) UnArchiveConversation(channelID string) error { return api.UnArchiveConversationContext(context.Background(), channelID) }
go
func (api *Client) UnArchiveConversation(channelID string) error { return api.UnArchiveConversationContext(context.Background(), channelID) }
[ "func", "(", "api", "*", "Client", ")", "UnArchiveConversation", "(", "channelID", "string", ")", "error", "{", "return", "api", ".", "UnArchiveConversationContext", "(", "context", ".", "Background", "(", ")", ",", "channelID", ")", "\n", "}" ]
// UnArchiveConversation reverses conversation archival
[ "UnArchiveConversation", "reverses", "conversation", "archival" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L173-L175
train
nlopes/slack
conversation.go
SetTopicOfConversation
func (api *Client) SetTopicOfConversation(channelID, topic string) (*Channel, error) { return api.SetTopicOfConversationContext(context.Background(), channelID, topic) }
go
func (api *Client) SetTopicOfConversation(channelID, topic string) (*Channel, error) { return api.SetTopicOfConversationContext(context.Background(), channelID, topic) }
[ "func", "(", "api", "*", "Client", ")", "SetTopicOfConversation", "(", "channelID", ",", "topic", "string", ")", "(", "*", "Channel", ",", "error", ")", "{", "return", "api", ".", "SetTopicOfConversationContext", "(", "context", ".", "Background", "(", ")", ",", "channelID", ",", "topic", ")", "\n", "}" ]
// SetTopicOfConversation sets the topic for a conversation
[ "SetTopicOfConversation", "sets", "the", "topic", "for", "a", "conversation" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L193-L195
train
nlopes/slack
conversation.go
SetPurposeOfConversation
func (api *Client) SetPurposeOfConversation(channelID, purpose string) (*Channel, error) { return api.SetPurposeOfConversationContext(context.Background(), channelID, purpose) }
go
func (api *Client) SetPurposeOfConversation(channelID, purpose string) (*Channel, error) { return api.SetPurposeOfConversationContext(context.Background(), channelID, purpose) }
[ "func", "(", "api", "*", "Client", ")", "SetPurposeOfConversation", "(", "channelID", ",", "purpose", "string", ")", "(", "*", "Channel", ",", "error", ")", "{", "return", "api", ".", "SetPurposeOfConversationContext", "(", "context", ".", "Background", "(", ")", ",", "channelID", ",", "purpose", ")", "\n", "}" ]
// SetPurposeOfConversation sets the purpose for a conversation
[ "SetPurposeOfConversation", "sets", "the", "purpose", "for", "a", "conversation" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L217-L219
train
nlopes/slack
conversation.go
RenameConversation
func (api *Client) RenameConversation(channelID, channelName string) (*Channel, error) { return api.RenameConversationContext(context.Background(), channelID, channelName) }
go
func (api *Client) RenameConversation(channelID, channelName string) (*Channel, error) { return api.RenameConversationContext(context.Background(), channelID, channelName) }
[ "func", "(", "api", "*", "Client", ")", "RenameConversation", "(", "channelID", ",", "channelName", "string", ")", "(", "*", "Channel", ",", "error", ")", "{", "return", "api", ".", "RenameConversationContext", "(", "context", ".", "Background", "(", ")", ",", "channelID", ",", "channelName", ")", "\n", "}" ]
// RenameConversation renames a conversation
[ "RenameConversation", "renames", "a", "conversation" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L241-L243
train
nlopes/slack
conversation.go
RenameConversationContext
func (api *Client) RenameConversationContext(ctx context.Context, channelID, channelName string) (*Channel, error) { values := url.Values{ "token": {api.token}, "channel": {channelID}, "name": {channelName}, } response := struct { SlackResponse Channel *Channel `json:"channel"` }{} err := api.postMethod(ctx, "conversations.rename", values, &response) if err != nil { return nil, err } return response.Channel, response.Err() }
go
func (api *Client) RenameConversationContext(ctx context.Context, channelID, channelName string) (*Channel, error) { values := url.Values{ "token": {api.token}, "channel": {channelID}, "name": {channelName}, } response := struct { SlackResponse Channel *Channel `json:"channel"` }{} err := api.postMethod(ctx, "conversations.rename", values, &response) if err != nil { return nil, err } return response.Channel, response.Err() }
[ "func", "(", "api", "*", "Client", ")", "RenameConversationContext", "(", "ctx", "context", ".", "Context", ",", "channelID", ",", "channelName", "string", ")", "(", "*", "Channel", ",", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "channelID", "}", ",", "\"", "\"", ":", "{", "channelName", "}", ",", "}", "\n", "response", ":=", "struct", "{", "SlackResponse", "\n", "Channel", "*", "Channel", "`json:\"channel\"`", "\n", "}", "{", "}", "\n", "err", ":=", "api", ".", "postMethod", "(", "ctx", ",", "\"", "\"", ",", "values", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "response", ".", "Channel", ",", "response", ".", "Err", "(", ")", "\n", "}" ]
// RenameConversationContext renames a conversation with a custom context
[ "RenameConversationContext", "renames", "a", "conversation", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L246-L262
train
nlopes/slack
conversation.go
InviteUsersToConversation
func (api *Client) InviteUsersToConversation(channelID string, users ...string) (*Channel, error) { return api.InviteUsersToConversationContext(context.Background(), channelID, users...) }
go
func (api *Client) InviteUsersToConversation(channelID string, users ...string) (*Channel, error) { return api.InviteUsersToConversationContext(context.Background(), channelID, users...) }
[ "func", "(", "api", "*", "Client", ")", "InviteUsersToConversation", "(", "channelID", "string", ",", "users", "...", "string", ")", "(", "*", "Channel", ",", "error", ")", "{", "return", "api", ".", "InviteUsersToConversationContext", "(", "context", ".", "Background", "(", ")", ",", "channelID", ",", "users", "...", ")", "\n", "}" ]
// InviteUsersToConversation invites users to a channel
[ "InviteUsersToConversation", "invites", "users", "to", "a", "channel" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L265-L267
train
nlopes/slack
conversation.go
InviteUsersToConversationContext
func (api *Client) InviteUsersToConversationContext(ctx context.Context, channelID string, users ...string) (*Channel, error) { values := url.Values{ "token": {api.token}, "channel": {channelID}, "users": {strings.Join(users, ",")}, } response := struct { SlackResponse Channel *Channel `json:"channel"` }{} err := api.postMethod(ctx, "conversations.invite", values, &response) if err != nil { return nil, err } return response.Channel, response.Err() }
go
func (api *Client) InviteUsersToConversationContext(ctx context.Context, channelID string, users ...string) (*Channel, error) { values := url.Values{ "token": {api.token}, "channel": {channelID}, "users": {strings.Join(users, ",")}, } response := struct { SlackResponse Channel *Channel `json:"channel"` }{} err := api.postMethod(ctx, "conversations.invite", values, &response) if err != nil { return nil, err } return response.Channel, response.Err() }
[ "func", "(", "api", "*", "Client", ")", "InviteUsersToConversationContext", "(", "ctx", "context", ".", "Context", ",", "channelID", "string", ",", "users", "...", "string", ")", "(", "*", "Channel", ",", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "channelID", "}", ",", "\"", "\"", ":", "{", "strings", ".", "Join", "(", "users", ",", "\"", "\"", ")", "}", ",", "}", "\n", "response", ":=", "struct", "{", "SlackResponse", "\n", "Channel", "*", "Channel", "`json:\"channel\"`", "\n", "}", "{", "}", "\n", "err", ":=", "api", ".", "postMethod", "(", "ctx", ",", "\"", "\"", ",", "values", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "response", ".", "Channel", ",", "response", ".", "Err", "(", ")", "\n", "}" ]
// InviteUsersToConversationContext invites users to a channel with a custom context
[ "InviteUsersToConversationContext", "invites", "users", "to", "a", "channel", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L270-L286
train
nlopes/slack
conversation.go
KickUserFromConversation
func (api *Client) KickUserFromConversation(channelID string, user string) error { return api.KickUserFromConversationContext(context.Background(), channelID, user) }
go
func (api *Client) KickUserFromConversation(channelID string, user string) error { return api.KickUserFromConversationContext(context.Background(), channelID, user) }
[ "func", "(", "api", "*", "Client", ")", "KickUserFromConversation", "(", "channelID", "string", ",", "user", "string", ")", "error", "{", "return", "api", ".", "KickUserFromConversationContext", "(", "context", ".", "Background", "(", ")", ",", "channelID", ",", "user", ")", "\n", "}" ]
// KickUserFromConversation removes a user from a conversation
[ "KickUserFromConversation", "removes", "a", "user", "from", "a", "conversation" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L289-L291
train
nlopes/slack
conversation.go
CloseConversation
func (api *Client) CloseConversation(channelID string) (noOp bool, alreadyClosed bool, err error) { return api.CloseConversationContext(context.Background(), channelID) }
go
func (api *Client) CloseConversation(channelID string) (noOp bool, alreadyClosed bool, err error) { return api.CloseConversationContext(context.Background(), channelID) }
[ "func", "(", "api", "*", "Client", ")", "CloseConversation", "(", "channelID", "string", ")", "(", "noOp", "bool", ",", "alreadyClosed", "bool", ",", "err", "error", ")", "{", "return", "api", ".", "CloseConversationContext", "(", "context", ".", "Background", "(", ")", ",", "channelID", ")", "\n", "}" ]
// CloseConversation closes a direct message or multi-person direct message
[ "CloseConversation", "closes", "a", "direct", "message", "or", "multi", "-", "person", "direct", "message" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L310-L312
train
nlopes/slack
conversation.go
CloseConversationContext
func (api *Client) CloseConversationContext(ctx context.Context, channelID string) (noOp bool, alreadyClosed bool, err error) { values := url.Values{ "token": {api.token}, "channel": {channelID}, } response := struct { SlackResponse NoOp bool `json:"no_op"` AlreadyClosed bool `json:"already_closed"` }{} err = api.postMethod(ctx, "conversations.close", values, &response) if err != nil { return false, false, err } return response.NoOp, response.AlreadyClosed, response.Err() }
go
func (api *Client) CloseConversationContext(ctx context.Context, channelID string) (noOp bool, alreadyClosed bool, err error) { values := url.Values{ "token": {api.token}, "channel": {channelID}, } response := struct { SlackResponse NoOp bool `json:"no_op"` AlreadyClosed bool `json:"already_closed"` }{} err = api.postMethod(ctx, "conversations.close", values, &response) if err != nil { return false, false, err } return response.NoOp, response.AlreadyClosed, response.Err() }
[ "func", "(", "api", "*", "Client", ")", "CloseConversationContext", "(", "ctx", "context", ".", "Context", ",", "channelID", "string", ")", "(", "noOp", "bool", ",", "alreadyClosed", "bool", ",", "err", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "channelID", "}", ",", "}", "\n", "response", ":=", "struct", "{", "SlackResponse", "\n", "NoOp", "bool", "`json:\"no_op\"`", "\n", "AlreadyClosed", "bool", "`json:\"already_closed\"`", "\n", "}", "{", "}", "\n\n", "err", "=", "api", ".", "postMethod", "(", "ctx", ",", "\"", "\"", ",", "values", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "false", ",", "err", "\n", "}", "\n\n", "return", "response", ".", "NoOp", ",", "response", ".", "AlreadyClosed", ",", "response", ".", "Err", "(", ")", "\n", "}" ]
// CloseConversationContext closes a direct message or multi-person direct message with a custom context
[ "CloseConversationContext", "closes", "a", "direct", "message", "or", "multi", "-", "person", "direct", "message", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L315-L332
train
nlopes/slack
conversation.go
CreateConversation
func (api *Client) CreateConversation(channelName string, isPrivate bool) (*Channel, error) { return api.CreateConversationContext(context.Background(), channelName, isPrivate) }
go
func (api *Client) CreateConversation(channelName string, isPrivate bool) (*Channel, error) { return api.CreateConversationContext(context.Background(), channelName, isPrivate) }
[ "func", "(", "api", "*", "Client", ")", "CreateConversation", "(", "channelName", "string", ",", "isPrivate", "bool", ")", "(", "*", "Channel", ",", "error", ")", "{", "return", "api", ".", "CreateConversationContext", "(", "context", ".", "Background", "(", ")", ",", "channelName", ",", "isPrivate", ")", "\n", "}" ]
// CreateConversation initiates a public or private channel-based conversation
[ "CreateConversation", "initiates", "a", "public", "or", "private", "channel", "-", "based", "conversation" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L335-L337
train
nlopes/slack
conversation.go
CreateConversationContext
func (api *Client) CreateConversationContext(ctx context.Context, channelName string, isPrivate bool) (*Channel, error) { values := url.Values{ "token": {api.token}, "name": {channelName}, "is_private": {strconv.FormatBool(isPrivate)}, } response, err := api.channelRequest(ctx, "conversations.create", values) if err != nil { return nil, err } return &response.Channel, nil }
go
func (api *Client) CreateConversationContext(ctx context.Context, channelName string, isPrivate bool) (*Channel, error) { values := url.Values{ "token": {api.token}, "name": {channelName}, "is_private": {strconv.FormatBool(isPrivate)}, } response, err := api.channelRequest(ctx, "conversations.create", values) if err != nil { return nil, err } return &response.Channel, nil }
[ "func", "(", "api", "*", "Client", ")", "CreateConversationContext", "(", "ctx", "context", ".", "Context", ",", "channelName", "string", ",", "isPrivate", "bool", ")", "(", "*", "Channel", ",", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "channelName", "}", ",", "\"", "\"", ":", "{", "strconv", ".", "FormatBool", "(", "isPrivate", ")", "}", ",", "}", "\n", "response", ",", "err", ":=", "api", ".", "channelRequest", "(", "ctx", ",", "\"", "\"", ",", "values", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "response", ".", "Channel", ",", "nil", "\n", "}" ]
// CreateConversationContext initiates a public or private channel-based conversation with a custom context
[ "CreateConversationContext", "initiates", "a", "public", "or", "private", "channel", "-", "based", "conversation", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L340-L352
train
nlopes/slack
conversation.go
GetConversationInfo
func (api *Client) GetConversationInfo(channelID string, includeLocale bool) (*Channel, error) { return api.GetConversationInfoContext(context.Background(), channelID, includeLocale) }
go
func (api *Client) GetConversationInfo(channelID string, includeLocale bool) (*Channel, error) { return api.GetConversationInfoContext(context.Background(), channelID, includeLocale) }
[ "func", "(", "api", "*", "Client", ")", "GetConversationInfo", "(", "channelID", "string", ",", "includeLocale", "bool", ")", "(", "*", "Channel", ",", "error", ")", "{", "return", "api", ".", "GetConversationInfoContext", "(", "context", ".", "Background", "(", ")", ",", "channelID", ",", "includeLocale", ")", "\n", "}" ]
// GetConversationInfo retrieves information about a conversation
[ "GetConversationInfo", "retrieves", "information", "about", "a", "conversation" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L355-L357
train
nlopes/slack
conversation.go
GetConversationInfoContext
func (api *Client) GetConversationInfoContext(ctx context.Context, channelID string, includeLocale bool) (*Channel, error) { values := url.Values{ "token": {api.token}, "channel": {channelID}, "include_locale": {strconv.FormatBool(includeLocale)}, } response, err := api.channelRequest(ctx, "conversations.info", values) if err != nil { return nil, err } return &response.Channel, response.Err() }
go
func (api *Client) GetConversationInfoContext(ctx context.Context, channelID string, includeLocale bool) (*Channel, error) { values := url.Values{ "token": {api.token}, "channel": {channelID}, "include_locale": {strconv.FormatBool(includeLocale)}, } response, err := api.channelRequest(ctx, "conversations.info", values) if err != nil { return nil, err } return &response.Channel, response.Err() }
[ "func", "(", "api", "*", "Client", ")", "GetConversationInfoContext", "(", "ctx", "context", ".", "Context", ",", "channelID", "string", ",", "includeLocale", "bool", ")", "(", "*", "Channel", ",", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "channelID", "}", ",", "\"", "\"", ":", "{", "strconv", ".", "FormatBool", "(", "includeLocale", ")", "}", ",", "}", "\n", "response", ",", "err", ":=", "api", ".", "channelRequest", "(", "ctx", ",", "\"", "\"", ",", "values", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "response", ".", "Channel", ",", "response", ".", "Err", "(", ")", "\n", "}" ]
// GetConversationInfoContext retrieves information about a conversation with a custom context
[ "GetConversationInfoContext", "retrieves", "information", "about", "a", "conversation", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L360-L372
train
nlopes/slack
conversation.go
LeaveConversation
func (api *Client) LeaveConversation(channelID string) (bool, error) { return api.LeaveConversationContext(context.Background(), channelID) }
go
func (api *Client) LeaveConversation(channelID string) (bool, error) { return api.LeaveConversationContext(context.Background(), channelID) }
[ "func", "(", "api", "*", "Client", ")", "LeaveConversation", "(", "channelID", "string", ")", "(", "bool", ",", "error", ")", "{", "return", "api", ".", "LeaveConversationContext", "(", "context", ".", "Background", "(", ")", ",", "channelID", ")", "\n", "}" ]
// LeaveConversation leaves a conversation
[ "LeaveConversation", "leaves", "a", "conversation" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L375-L377
train
nlopes/slack
conversation.go
GetConversationReplies
func (api *Client) GetConversationReplies(params *GetConversationRepliesParameters) (msgs []Message, hasMore bool, nextCursor string, err error) { return api.GetConversationRepliesContext(context.Background(), params) }
go
func (api *Client) GetConversationReplies(params *GetConversationRepliesParameters) (msgs []Message, hasMore bool, nextCursor string, err error) { return api.GetConversationRepliesContext(context.Background(), params) }
[ "func", "(", "api", "*", "Client", ")", "GetConversationReplies", "(", "params", "*", "GetConversationRepliesParameters", ")", "(", "msgs", "[", "]", "Message", ",", "hasMore", "bool", ",", "nextCursor", "string", ",", "err", "error", ")", "{", "return", "api", ".", "GetConversationRepliesContext", "(", "context", ".", "Background", "(", ")", ",", "params", ")", "\n", "}" ]
// GetConversationReplies retrieves a thread of messages posted to a conversation
[ "GetConversationReplies", "retrieves", "a", "thread", "of", "messages", "posted", "to", "a", "conversation" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L405-L407
train
nlopes/slack
conversation.go
GetConversationRepliesContext
func (api *Client) GetConversationRepliesContext(ctx context.Context, params *GetConversationRepliesParameters) (msgs []Message, hasMore bool, nextCursor string, err error) { values := url.Values{ "token": {api.token}, "channel": {params.ChannelID}, "ts": {params.Timestamp}, } if params.Cursor != "" { values.Add("cursor", params.Cursor) } if params.Latest != "" { values.Add("latest", params.Latest) } if params.Limit != 0 { values.Add("limit", strconv.Itoa(params.Limit)) } if params.Oldest != "" { values.Add("oldest", params.Oldest) } if params.Inclusive { values.Add("inclusive", "1") } else { values.Add("inclusive", "0") } response := struct { SlackResponse HasMore bool `json:"has_more"` ResponseMetaData struct { NextCursor string `json:"next_cursor"` } `json:"response_metadata"` Messages []Message `json:"messages"` }{} err = api.postMethod(ctx, "conversations.replies", values, &response) if err != nil { return nil, false, "", err } return response.Messages, response.HasMore, response.ResponseMetaData.NextCursor, response.Err() }
go
func (api *Client) GetConversationRepliesContext(ctx context.Context, params *GetConversationRepliesParameters) (msgs []Message, hasMore bool, nextCursor string, err error) { values := url.Values{ "token": {api.token}, "channel": {params.ChannelID}, "ts": {params.Timestamp}, } if params.Cursor != "" { values.Add("cursor", params.Cursor) } if params.Latest != "" { values.Add("latest", params.Latest) } if params.Limit != 0 { values.Add("limit", strconv.Itoa(params.Limit)) } if params.Oldest != "" { values.Add("oldest", params.Oldest) } if params.Inclusive { values.Add("inclusive", "1") } else { values.Add("inclusive", "0") } response := struct { SlackResponse HasMore bool `json:"has_more"` ResponseMetaData struct { NextCursor string `json:"next_cursor"` } `json:"response_metadata"` Messages []Message `json:"messages"` }{} err = api.postMethod(ctx, "conversations.replies", values, &response) if err != nil { return nil, false, "", err } return response.Messages, response.HasMore, response.ResponseMetaData.NextCursor, response.Err() }
[ "func", "(", "api", "*", "Client", ")", "GetConversationRepliesContext", "(", "ctx", "context", ".", "Context", ",", "params", "*", "GetConversationRepliesParameters", ")", "(", "msgs", "[", "]", "Message", ",", "hasMore", "bool", ",", "nextCursor", "string", ",", "err", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "params", ".", "ChannelID", "}", ",", "\"", "\"", ":", "{", "params", ".", "Timestamp", "}", ",", "}", "\n", "if", "params", ".", "Cursor", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "Cursor", ")", "\n", "}", "\n", "if", "params", ".", "Latest", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "Latest", ")", "\n", "}", "\n", "if", "params", ".", "Limit", "!=", "0", "{", "values", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "params", ".", "Limit", ")", ")", "\n", "}", "\n", "if", "params", ".", "Oldest", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "Oldest", ")", "\n", "}", "\n", "if", "params", ".", "Inclusive", "{", "values", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "else", "{", "values", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "\n", "response", ":=", "struct", "{", "SlackResponse", "\n", "HasMore", "bool", "`json:\"has_more\"`", "\n", "ResponseMetaData", "struct", "{", "NextCursor", "string", "`json:\"next_cursor\"`", "\n", "}", "`json:\"response_metadata\"`", "\n", "Messages", "[", "]", "Message", "`json:\"messages\"`", "\n", "}", "{", "}", "\n\n", "err", "=", "api", ".", "postMethod", "(", "ctx", ",", "\"", "\"", ",", "values", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "false", ",", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "response", ".", "Messages", ",", "response", ".", "HasMore", ",", "response", ".", "ResponseMetaData", ".", "NextCursor", ",", "response", ".", "Err", "(", ")", "\n", "}" ]
// GetConversationRepliesContext retrieves a thread of messages posted to a conversation with a custom context
[ "GetConversationRepliesContext", "retrieves", "a", "thread", "of", "messages", "posted", "to", "a", "conversation", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L410-L448
train
nlopes/slack
conversation.go
GetConversations
func (api *Client) GetConversations(params *GetConversationsParameters) (channels []Channel, nextCursor string, err error) { return api.GetConversationsContext(context.Background(), params) }
go
func (api *Client) GetConversations(params *GetConversationsParameters) (channels []Channel, nextCursor string, err error) { return api.GetConversationsContext(context.Background(), params) }
[ "func", "(", "api", "*", "Client", ")", "GetConversations", "(", "params", "*", "GetConversationsParameters", ")", "(", "channels", "[", "]", "Channel", ",", "nextCursor", "string", ",", "err", "error", ")", "{", "return", "api", ".", "GetConversationsContext", "(", "context", ".", "Background", "(", ")", ",", "params", ")", "\n", "}" ]
// GetConversations returns the list of channels in a Slack team
[ "GetConversations", "returns", "the", "list", "of", "channels", "in", "a", "Slack", "team" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L458-L460
train
nlopes/slack
conversation.go
GetConversationsContext
func (api *Client) GetConversationsContext(ctx context.Context, params *GetConversationsParameters) (channels []Channel, nextCursor string, err error) { values := url.Values{ "token": {api.token}, "exclude_archived": {params.ExcludeArchived}, } if params.Cursor != "" { values.Add("cursor", params.Cursor) } if params.Limit != 0 { values.Add("limit", strconv.Itoa(params.Limit)) } if params.Types != nil { values.Add("types", strings.Join(params.Types, ",")) } response := struct { Channels []Channel `json:"channels"` ResponseMetaData responseMetaData `json:"response_metadata"` SlackResponse }{} err = api.postMethod(ctx, "conversations.list", values, &response) if err != nil { return nil, "", err } return response.Channels, response.ResponseMetaData.NextCursor, response.Err() }
go
func (api *Client) GetConversationsContext(ctx context.Context, params *GetConversationsParameters) (channels []Channel, nextCursor string, err error) { values := url.Values{ "token": {api.token}, "exclude_archived": {params.ExcludeArchived}, } if params.Cursor != "" { values.Add("cursor", params.Cursor) } if params.Limit != 0 { values.Add("limit", strconv.Itoa(params.Limit)) } if params.Types != nil { values.Add("types", strings.Join(params.Types, ",")) } response := struct { Channels []Channel `json:"channels"` ResponseMetaData responseMetaData `json:"response_metadata"` SlackResponse }{} err = api.postMethod(ctx, "conversations.list", values, &response) if err != nil { return nil, "", err } return response.Channels, response.ResponseMetaData.NextCursor, response.Err() }
[ "func", "(", "api", "*", "Client", ")", "GetConversationsContext", "(", "ctx", "context", ".", "Context", ",", "params", "*", "GetConversationsParameters", ")", "(", "channels", "[", "]", "Channel", ",", "nextCursor", "string", ",", "err", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "params", ".", "ExcludeArchived", "}", ",", "}", "\n", "if", "params", ".", "Cursor", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "Cursor", ")", "\n", "}", "\n", "if", "params", ".", "Limit", "!=", "0", "{", "values", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "params", ".", "Limit", ")", ")", "\n", "}", "\n", "if", "params", ".", "Types", "!=", "nil", "{", "values", ".", "Add", "(", "\"", "\"", ",", "strings", ".", "Join", "(", "params", ".", "Types", ",", "\"", "\"", ")", ")", "\n", "}", "\n", "response", ":=", "struct", "{", "Channels", "[", "]", "Channel", "`json:\"channels\"`", "\n", "ResponseMetaData", "responseMetaData", "`json:\"response_metadata\"`", "\n", "SlackResponse", "\n", "}", "{", "}", "\n", "err", "=", "api", ".", "postMethod", "(", "ctx", ",", "\"", "\"", ",", "values", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "response", ".", "Channels", ",", "response", ".", "ResponseMetaData", ".", "NextCursor", ",", "response", ".", "Err", "(", ")", "\n", "}" ]
// GetConversationsContext returns the list of channels in a Slack team with a custom context
[ "GetConversationsContext", "returns", "the", "list", "of", "channels", "in", "a", "Slack", "team", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L463-L488
train
nlopes/slack
conversation.go
OpenConversation
func (api *Client) OpenConversation(params *OpenConversationParameters) (*Channel, bool, bool, error) { return api.OpenConversationContext(context.Background(), params) }
go
func (api *Client) OpenConversation(params *OpenConversationParameters) (*Channel, bool, bool, error) { return api.OpenConversationContext(context.Background(), params) }
[ "func", "(", "api", "*", "Client", ")", "OpenConversation", "(", "params", "*", "OpenConversationParameters", ")", "(", "*", "Channel", ",", "bool", ",", "bool", ",", "error", ")", "{", "return", "api", ".", "OpenConversationContext", "(", "context", ".", "Background", "(", ")", ",", "params", ")", "\n", "}" ]
// OpenConversation opens or resumes a direct message or multi-person direct message
[ "OpenConversation", "opens", "or", "resumes", "a", "direct", "message", "or", "multi", "-", "person", "direct", "message" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L497-L499
train
nlopes/slack
conversation.go
OpenConversationContext
func (api *Client) OpenConversationContext(ctx context.Context, params *OpenConversationParameters) (*Channel, bool, bool, error) { values := url.Values{ "token": {api.token}, "return_im": {strconv.FormatBool(params.ReturnIM)}, } if params.ChannelID != "" { values.Add("channel", params.ChannelID) } if params.Users != nil { values.Add("users", strings.Join(params.Users, ",")) } response := struct { Channel *Channel `json:"channel"` NoOp bool `json:"no_op"` AlreadyOpen bool `json:"already_open"` SlackResponse }{} err := api.postMethod(ctx, "conversations.open", values, &response) if err != nil { return nil, false, false, err } return response.Channel, response.NoOp, response.AlreadyOpen, response.Err() }
go
func (api *Client) OpenConversationContext(ctx context.Context, params *OpenConversationParameters) (*Channel, bool, bool, error) { values := url.Values{ "token": {api.token}, "return_im": {strconv.FormatBool(params.ReturnIM)}, } if params.ChannelID != "" { values.Add("channel", params.ChannelID) } if params.Users != nil { values.Add("users", strings.Join(params.Users, ",")) } response := struct { Channel *Channel `json:"channel"` NoOp bool `json:"no_op"` AlreadyOpen bool `json:"already_open"` SlackResponse }{} err := api.postMethod(ctx, "conversations.open", values, &response) if err != nil { return nil, false, false, err } return response.Channel, response.NoOp, response.AlreadyOpen, response.Err() }
[ "func", "(", "api", "*", "Client", ")", "OpenConversationContext", "(", "ctx", "context", ".", "Context", ",", "params", "*", "OpenConversationParameters", ")", "(", "*", "Channel", ",", "bool", ",", "bool", ",", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "strconv", ".", "FormatBool", "(", "params", ".", "ReturnIM", ")", "}", ",", "}", "\n", "if", "params", ".", "ChannelID", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "ChannelID", ")", "\n", "}", "\n", "if", "params", ".", "Users", "!=", "nil", "{", "values", ".", "Add", "(", "\"", "\"", ",", "strings", ".", "Join", "(", "params", ".", "Users", ",", "\"", "\"", ")", ")", "\n", "}", "\n", "response", ":=", "struct", "{", "Channel", "*", "Channel", "`json:\"channel\"`", "\n", "NoOp", "bool", "`json:\"no_op\"`", "\n", "AlreadyOpen", "bool", "`json:\"already_open\"`", "\n", "SlackResponse", "\n", "}", "{", "}", "\n", "err", ":=", "api", ".", "postMethod", "(", "ctx", ",", "\"", "\"", ",", "values", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "false", ",", "false", ",", "err", "\n", "}", "\n\n", "return", "response", ".", "Channel", ",", "response", ".", "NoOp", ",", "response", ".", "AlreadyOpen", ",", "response", ".", "Err", "(", ")", "\n", "}" ]
// OpenConversationContext opens or resumes a direct message or multi-person direct message with a custom context
[ "OpenConversationContext", "opens", "or", "resumes", "a", "direct", "message", "or", "multi", "-", "person", "direct", "message", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L502-L525
train
nlopes/slack
conversation.go
JoinConversation
func (api *Client) JoinConversation(channelID string) (*Channel, string, []string, error) { return api.JoinConversationContext(context.Background(), channelID) }
go
func (api *Client) JoinConversation(channelID string) (*Channel, string, []string, error) { return api.JoinConversationContext(context.Background(), channelID) }
[ "func", "(", "api", "*", "Client", ")", "JoinConversation", "(", "channelID", "string", ")", "(", "*", "Channel", ",", "string", ",", "[", "]", "string", ",", "error", ")", "{", "return", "api", ".", "JoinConversationContext", "(", "context", ".", "Background", "(", ")", ",", "channelID", ")", "\n", "}" ]
// JoinConversation joins an existing conversation
[ "JoinConversation", "joins", "an", "existing", "conversation" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L528-L530
train
nlopes/slack
conversation.go
JoinConversationContext
func (api *Client) JoinConversationContext(ctx context.Context, channelID string) (*Channel, string, []string, error) { values := url.Values{"token": {api.token}, "channel": {channelID}} response := struct { Channel *Channel `json:"channel"` Warning string `json:"warning"` ResponseMetaData *struct { Warnings []string `json:"warnings"` } `json:"response_metadata"` SlackResponse }{} err := api.postMethod(ctx, "conversations.join", values, &response) if err != nil { return nil, "", nil, err } if response.Err() != nil { return nil, "", nil, response.Err() } var warnings []string if response.ResponseMetaData != nil { warnings = response.ResponseMetaData.Warnings } return response.Channel, response.Warning, warnings, nil }
go
func (api *Client) JoinConversationContext(ctx context.Context, channelID string) (*Channel, string, []string, error) { values := url.Values{"token": {api.token}, "channel": {channelID}} response := struct { Channel *Channel `json:"channel"` Warning string `json:"warning"` ResponseMetaData *struct { Warnings []string `json:"warnings"` } `json:"response_metadata"` SlackResponse }{} err := api.postMethod(ctx, "conversations.join", values, &response) if err != nil { return nil, "", nil, err } if response.Err() != nil { return nil, "", nil, response.Err() } var warnings []string if response.ResponseMetaData != nil { warnings = response.ResponseMetaData.Warnings } return response.Channel, response.Warning, warnings, nil }
[ "func", "(", "api", "*", "Client", ")", "JoinConversationContext", "(", "ctx", "context", ".", "Context", ",", "channelID", "string", ")", "(", "*", "Channel", ",", "string", ",", "[", "]", "string", ",", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "channelID", "}", "}", "\n", "response", ":=", "struct", "{", "Channel", "*", "Channel", "`json:\"channel\"`", "\n", "Warning", "string", "`json:\"warning\"`", "\n", "ResponseMetaData", "*", "struct", "{", "Warnings", "[", "]", "string", "`json:\"warnings\"`", "\n", "}", "`json:\"response_metadata\"`", "\n", "SlackResponse", "\n", "}", "{", "}", "\n", "err", ":=", "api", ".", "postMethod", "(", "ctx", ",", "\"", "\"", ",", "values", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "nil", ",", "err", "\n", "}", "\n", "if", "response", ".", "Err", "(", ")", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "nil", ",", "response", ".", "Err", "(", ")", "\n", "}", "\n", "var", "warnings", "[", "]", "string", "\n", "if", "response", ".", "ResponseMetaData", "!=", "nil", "{", "warnings", "=", "response", ".", "ResponseMetaData", ".", "Warnings", "\n", "}", "\n", "return", "response", ".", "Channel", ",", "response", ".", "Warning", ",", "warnings", ",", "nil", "\n", "}" ]
// JoinConversationContext joins an existing conversation with a custom context
[ "JoinConversationContext", "joins", "an", "existing", "conversation", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L533-L555
train
nlopes/slack
conversation.go
GetConversationHistory
func (api *Client) GetConversationHistory(params *GetConversationHistoryParameters) (*GetConversationHistoryResponse, error) { return api.GetConversationHistoryContext(context.Background(), params) }
go
func (api *Client) GetConversationHistory(params *GetConversationHistoryParameters) (*GetConversationHistoryResponse, error) { return api.GetConversationHistoryContext(context.Background(), params) }
[ "func", "(", "api", "*", "Client", ")", "GetConversationHistory", "(", "params", "*", "GetConversationHistoryParameters", ")", "(", "*", "GetConversationHistoryResponse", ",", "error", ")", "{", "return", "api", ".", "GetConversationHistoryContext", "(", "context", ".", "Background", "(", ")", ",", "params", ")", "\n", "}" ]
// GetConversationHistory joins an existing conversation
[ "GetConversationHistory", "joins", "an", "existing", "conversation" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L578-L580
train
nlopes/slack
conversation.go
GetConversationHistoryContext
func (api *Client) GetConversationHistoryContext(ctx context.Context, params *GetConversationHistoryParameters) (*GetConversationHistoryResponse, error) { values := url.Values{"token": {api.token}, "channel": {params.ChannelID}} if params.Cursor != "" { values.Add("cursor", params.Cursor) } if params.Inclusive { values.Add("inclusive", "1") } else { values.Add("inclusive", "0") } if params.Latest != "" { values.Add("latest", params.Latest) } if params.Limit != 0 { values.Add("limit", strconv.Itoa(params.Limit)) } if params.Oldest != "" { values.Add("oldest", params.Oldest) } response := GetConversationHistoryResponse{} err := api.postMethod(ctx, "conversations.history", values, &response) if err != nil { return nil, err } return &response, response.Err() }
go
func (api *Client) GetConversationHistoryContext(ctx context.Context, params *GetConversationHistoryParameters) (*GetConversationHistoryResponse, error) { values := url.Values{"token": {api.token}, "channel": {params.ChannelID}} if params.Cursor != "" { values.Add("cursor", params.Cursor) } if params.Inclusive { values.Add("inclusive", "1") } else { values.Add("inclusive", "0") } if params.Latest != "" { values.Add("latest", params.Latest) } if params.Limit != 0 { values.Add("limit", strconv.Itoa(params.Limit)) } if params.Oldest != "" { values.Add("oldest", params.Oldest) } response := GetConversationHistoryResponse{} err := api.postMethod(ctx, "conversations.history", values, &response) if err != nil { return nil, err } return &response, response.Err() }
[ "func", "(", "api", "*", "Client", ")", "GetConversationHistoryContext", "(", "ctx", "context", ".", "Context", ",", "params", "*", "GetConversationHistoryParameters", ")", "(", "*", "GetConversationHistoryResponse", ",", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "params", ".", "ChannelID", "}", "}", "\n", "if", "params", ".", "Cursor", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "Cursor", ")", "\n", "}", "\n", "if", "params", ".", "Inclusive", "{", "values", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "else", "{", "values", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "params", ".", "Latest", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "Latest", ")", "\n", "}", "\n", "if", "params", ".", "Limit", "!=", "0", "{", "values", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "params", ".", "Limit", ")", ")", "\n", "}", "\n", "if", "params", ".", "Oldest", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "Oldest", ")", "\n", "}", "\n\n", "response", ":=", "GetConversationHistoryResponse", "{", "}", "\n\n", "err", ":=", "api", ".", "postMethod", "(", "ctx", ",", "\"", "\"", ",", "values", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "response", ",", "response", ".", "Err", "(", ")", "\n", "}" ]
// GetConversationHistoryContext joins an existing conversation with a custom context
[ "GetConversationHistoryContext", "joins", "an", "existing", "conversation", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/conversation.go#L583-L611
train
nlopes/slack
slack.go
OptionLog
func OptionLog(l logger) func(*Client) { return func(c *Client) { c.log = internalLog{logger: l} } }
go
func OptionLog(l logger) func(*Client) { return func(c *Client) { c.log = internalLog{logger: l} } }
[ "func", "OptionLog", "(", "l", "logger", ")", "func", "(", "*", "Client", ")", "{", "return", "func", "(", "c", "*", "Client", ")", "{", "c", ".", "log", "=", "internalLog", "{", "logger", ":", "l", "}", "\n", "}", "\n", "}" ]
// OptionLog set logging for client.
[ "OptionLog", "set", "logging", "for", "client", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/slack.go#L80-L84
train
nlopes/slack
slack.go
New
func New(token string, options ...Option) *Client { s := &Client{ token: token, endpoint: APIURL, httpclient: &http.Client{}, log: log.New(os.Stderr, "nlopes/slack", log.LstdFlags|log.Lshortfile), } for _, opt := range options { opt(s) } return s }
go
func New(token string, options ...Option) *Client { s := &Client{ token: token, endpoint: APIURL, httpclient: &http.Client{}, log: log.New(os.Stderr, "nlopes/slack", log.LstdFlags|log.Lshortfile), } for _, opt := range options { opt(s) } return s }
[ "func", "New", "(", "token", "string", ",", "options", "...", "Option", ")", "*", "Client", "{", "s", ":=", "&", "Client", "{", "token", ":", "token", ",", "endpoint", ":", "APIURL", ",", "httpclient", ":", "&", "http", ".", "Client", "{", "}", ",", "log", ":", "log", ".", "New", "(", "os", ".", "Stderr", ",", "\"", "\"", ",", "log", ".", "LstdFlags", "|", "log", ".", "Lshortfile", ")", ",", "}", "\n\n", "for", "_", ",", "opt", ":=", "range", "options", "{", "opt", "(", "s", ")", "\n", "}", "\n\n", "return", "s", "\n", "}" ]
// New builds a slack client from the provided token and options.
[ "New", "builds", "a", "slack", "client", "from", "the", "provided", "token", "and", "options", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/slack.go#L92-L105
train
nlopes/slack
slack.go
Debugf
func (api *Client) Debugf(format string, v ...interface{}) { if api.debug { api.log.Output(2, fmt.Sprintf(format, v...)) } }
go
func (api *Client) Debugf(format string, v ...interface{}) { if api.debug { api.log.Output(2, fmt.Sprintf(format, v...)) } }
[ "func", "(", "api", "*", "Client", ")", "Debugf", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "if", "api", ".", "debug", "{", "api", ".", "log", ".", "Output", "(", "2", ",", "fmt", ".", "Sprintf", "(", "format", ",", "v", "...", ")", ")", "\n", "}", "\n", "}" ]
// Debugf print a formatted debug line.
[ "Debugf", "print", "a", "formatted", "debug", "line", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/slack.go#L125-L129
train
nlopes/slack
slack.go
Debugln
func (api *Client) Debugln(v ...interface{}) { if api.debug { api.log.Output(2, fmt.Sprintln(v...)) } }
go
func (api *Client) Debugln(v ...interface{}) { if api.debug { api.log.Output(2, fmt.Sprintln(v...)) } }
[ "func", "(", "api", "*", "Client", ")", "Debugln", "(", "v", "...", "interface", "{", "}", ")", "{", "if", "api", ".", "debug", "{", "api", ".", "log", ".", "Output", "(", "2", ",", "fmt", ".", "Sprintln", "(", "v", "...", ")", ")", "\n", "}", "\n", "}" ]
// Debugln print a debug line.
[ "Debugln", "print", "a", "debug", "line", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/slack.go#L132-L136
train
nlopes/slack
slack.go
postMethod
func (api *Client) postMethod(ctx context.Context, path string, values url.Values, intf interface{}) error { return postForm(ctx, api.httpclient, api.endpoint+path, values, intf, api) }
go
func (api *Client) postMethod(ctx context.Context, path string, values url.Values, intf interface{}) error { return postForm(ctx, api.httpclient, api.endpoint+path, values, intf, api) }
[ "func", "(", "api", "*", "Client", ")", "postMethod", "(", "ctx", "context", ".", "Context", ",", "path", "string", ",", "values", "url", ".", "Values", ",", "intf", "interface", "{", "}", ")", "error", "{", "return", "postForm", "(", "ctx", ",", "api", ".", "httpclient", ",", "api", ".", "endpoint", "+", "path", ",", "values", ",", "intf", ",", "api", ")", "\n", "}" ]
// post to a slack web method.
[ "post", "to", "a", "slack", "web", "method", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/slack.go#L144-L146
train
nlopes/slack
slack.go
getMethod
func (api *Client) getMethod(ctx context.Context, path string, values url.Values, intf interface{}) error { return getResource(ctx, api.httpclient, api.endpoint+path, values, intf, api) }
go
func (api *Client) getMethod(ctx context.Context, path string, values url.Values, intf interface{}) error { return getResource(ctx, api.httpclient, api.endpoint+path, values, intf, api) }
[ "func", "(", "api", "*", "Client", ")", "getMethod", "(", "ctx", "context", ".", "Context", ",", "path", "string", ",", "values", "url", ".", "Values", ",", "intf", "interface", "{", "}", ")", "error", "{", "return", "getResource", "(", "ctx", ",", "api", ".", "httpclient", ",", "api", ".", "endpoint", "+", "path", ",", "values", ",", "intf", ",", "api", ")", "\n", "}" ]
// get a slack web method.
[ "get", "a", "slack", "web", "method", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/slack.go#L149-L151
train
nlopes/slack
block.go
AddBlockMessage
func AddBlockMessage(message Message, newBlk Block) Message { message.Msg.Blocks = append(message.Msg.Blocks, newBlk) return message }
go
func AddBlockMessage(message Message, newBlk Block) Message { message.Msg.Blocks = append(message.Msg.Blocks, newBlk) return message }
[ "func", "AddBlockMessage", "(", "message", "Message", ",", "newBlk", "Block", ")", "Message", "{", "message", ".", "Msg", ".", "Blocks", "=", "append", "(", "message", ".", "Msg", ".", "Blocks", ",", "newBlk", ")", "\n", "return", "message", "\n", "}" ]
// AddBlockMessage appends a block to the end of the existing list of blocks
[ "AddBlockMessage", "appends", "a", "block", "to", "the", "end", "of", "the", "existing", "list", "of", "blocks" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block.go#L48-L51
train
nlopes/slack
messages.go
NewOutgoingMessage
func (rtm *RTM) NewOutgoingMessage(text string, channelID string, options ...RTMsgOption) *OutgoingMessage { id := rtm.idGen.Next() msg := OutgoingMessage{ ID: id, Type: "message", Channel: channelID, Text: text, } for _, option := range options { option(&msg) } return &msg }
go
func (rtm *RTM) NewOutgoingMessage(text string, channelID string, options ...RTMsgOption) *OutgoingMessage { id := rtm.idGen.Next() msg := OutgoingMessage{ ID: id, Type: "message", Channel: channelID, Text: text, } for _, option := range options { option(&msg) } return &msg }
[ "func", "(", "rtm", "*", "RTM", ")", "NewOutgoingMessage", "(", "text", "string", ",", "channelID", "string", ",", "options", "...", "RTMsgOption", ")", "*", "OutgoingMessage", "{", "id", ":=", "rtm", ".", "idGen", ".", "Next", "(", ")", "\n", "msg", ":=", "OutgoingMessage", "{", "ID", ":", "id", ",", "Type", ":", "\"", "\"", ",", "Channel", ":", "channelID", ",", "Text", ":", "text", ",", "}", "\n", "for", "_", ",", "option", ":=", "range", "options", "{", "option", "(", "&", "msg", ")", "\n", "}", "\n", "return", "&", "msg", "\n", "}" ]
// NewOutgoingMessage prepares an OutgoingMessage that the user can // use to send a message. Use this function to properly set the // messageID.
[ "NewOutgoingMessage", "prepares", "an", "OutgoingMessage", "that", "the", "user", "can", "use", "to", "send", "a", "message", ".", "Use", "this", "function", "to", "properly", "set", "the", "messageID", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/messages.go#L141-L153
train
nlopes/slack
messages.go
NewSubscribeUserPresence
func (rtm *RTM) NewSubscribeUserPresence(ids []string) *OutgoingMessage { return &OutgoingMessage{ Type: "presence_sub", IDs: ids, } }
go
func (rtm *RTM) NewSubscribeUserPresence(ids []string) *OutgoingMessage { return &OutgoingMessage{ Type: "presence_sub", IDs: ids, } }
[ "func", "(", "rtm", "*", "RTM", ")", "NewSubscribeUserPresence", "(", "ids", "[", "]", "string", ")", "*", "OutgoingMessage", "{", "return", "&", "OutgoingMessage", "{", "Type", ":", "\"", "\"", ",", "IDs", ":", "ids", ",", "}", "\n", "}" ]
// NewSubscribeUserPresence prepares an OutgoingMessage that the user can // use to subscribe presence events for the specified users.
[ "NewSubscribeUserPresence", "prepares", "an", "OutgoingMessage", "that", "the", "user", "can", "use", "to", "subscribe", "presence", "events", "for", "the", "specified", "users", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/messages.go#L157-L162
train
nlopes/slack
messages.go
NewTypingMessage
func (rtm *RTM) NewTypingMessage(channelID string) *OutgoingMessage { id := rtm.idGen.Next() return &OutgoingMessage{ ID: id, Type: "typing", Channel: channelID, } }
go
func (rtm *RTM) NewTypingMessage(channelID string) *OutgoingMessage { id := rtm.idGen.Next() return &OutgoingMessage{ ID: id, Type: "typing", Channel: channelID, } }
[ "func", "(", "rtm", "*", "RTM", ")", "NewTypingMessage", "(", "channelID", "string", ")", "*", "OutgoingMessage", "{", "id", ":=", "rtm", ".", "idGen", ".", "Next", "(", ")", "\n", "return", "&", "OutgoingMessage", "{", "ID", ":", "id", ",", "Type", ":", "\"", "\"", ",", "Channel", ":", "channelID", ",", "}", "\n", "}" ]
// NewTypingMessage prepares an OutgoingMessage that the user can // use to send as a typing indicator. Use this function to properly set the // messageID.
[ "NewTypingMessage", "prepares", "an", "OutgoingMessage", "that", "the", "user", "can", "use", "to", "send", "as", "a", "typing", "indicator", ".", "Use", "this", "function", "to", "properly", "set", "the", "messageID", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/messages.go#L167-L174
train
nlopes/slack
emoji.go
GetEmoji
func (api *Client) GetEmoji() (map[string]string, error) { return api.GetEmojiContext(context.Background()) }
go
func (api *Client) GetEmoji() (map[string]string, error) { return api.GetEmojiContext(context.Background()) }
[ "func", "(", "api", "*", "Client", ")", "GetEmoji", "(", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "return", "api", ".", "GetEmojiContext", "(", "context", ".", "Background", "(", ")", ")", "\n", "}" ]
// GetEmoji retrieves all the emojis
[ "GetEmoji", "retrieves", "all", "the", "emojis" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/emoji.go#L14-L16
train
nlopes/slack
emoji.go
GetEmojiContext
func (api *Client) GetEmojiContext(ctx context.Context) (map[string]string, error) { values := url.Values{ "token": {api.token}, } response := &emojiResponseFull{} err := api.postMethod(ctx, "emoji.list", values, response) if err != nil { return nil, err } if response.Err() != nil { return nil, response.Err() } return response.Emoji, nil }
go
func (api *Client) GetEmojiContext(ctx context.Context) (map[string]string, error) { values := url.Values{ "token": {api.token}, } response := &emojiResponseFull{} err := api.postMethod(ctx, "emoji.list", values, response) if err != nil { return nil, err } if response.Err() != nil { return nil, response.Err() } return response.Emoji, nil }
[ "func", "(", "api", "*", "Client", ")", "GetEmojiContext", "(", "ctx", "context", ".", "Context", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "}", "\n", "response", ":=", "&", "emojiResponseFull", "{", "}", "\n\n", "err", ":=", "api", ".", "postMethod", "(", "ctx", ",", "\"", "\"", ",", "values", ",", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "response", ".", "Err", "(", ")", "!=", "nil", "{", "return", "nil", ",", "response", ".", "Err", "(", ")", "\n", "}", "\n\n", "return", "response", ".", "Emoji", ",", "nil", "\n", "}" ]
// GetEmojiContext retrieves all the emojis with a custom context
[ "GetEmojiContext", "retrieves", "all", "the", "emojis", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/emoji.go#L19-L35
train
nlopes/slack
security.go
NewSecretsVerifier
func NewSecretsVerifier(header http.Header, secret string) (sv SecretsVerifier, err error) { var ( timestamp int64 ) stimestamp := header.Get(hTimestamp) if sv, err = unsafeSignatureVerifier(header, secret); err != nil { return SecretsVerifier{}, err } if timestamp, err = strconv.ParseInt(stimestamp, 10, 64); err != nil { return SecretsVerifier{}, err } diff := absDuration(time.Since(time.Unix(timestamp, 0))) if diff > 5*time.Minute { return SecretsVerifier{}, ErrExpiredTimestamp } return sv, err }
go
func NewSecretsVerifier(header http.Header, secret string) (sv SecretsVerifier, err error) { var ( timestamp int64 ) stimestamp := header.Get(hTimestamp) if sv, err = unsafeSignatureVerifier(header, secret); err != nil { return SecretsVerifier{}, err } if timestamp, err = strconv.ParseInt(stimestamp, 10, 64); err != nil { return SecretsVerifier{}, err } diff := absDuration(time.Since(time.Unix(timestamp, 0))) if diff > 5*time.Minute { return SecretsVerifier{}, ErrExpiredTimestamp } return sv, err }
[ "func", "NewSecretsVerifier", "(", "header", "http", ".", "Header", ",", "secret", "string", ")", "(", "sv", "SecretsVerifier", ",", "err", "error", ")", "{", "var", "(", "timestamp", "int64", "\n", ")", "\n\n", "stimestamp", ":=", "header", ".", "Get", "(", "hTimestamp", ")", "\n\n", "if", "sv", ",", "err", "=", "unsafeSignatureVerifier", "(", "header", ",", "secret", ")", ";", "err", "!=", "nil", "{", "return", "SecretsVerifier", "{", "}", ",", "err", "\n", "}", "\n\n", "if", "timestamp", ",", "err", "=", "strconv", ".", "ParseInt", "(", "stimestamp", ",", "10", ",", "64", ")", ";", "err", "!=", "nil", "{", "return", "SecretsVerifier", "{", "}", ",", "err", "\n", "}", "\n\n", "diff", ":=", "absDuration", "(", "time", ".", "Since", "(", "time", ".", "Unix", "(", "timestamp", ",", "0", ")", ")", ")", "\n", "if", "diff", ">", "5", "*", "time", ".", "Minute", "{", "return", "SecretsVerifier", "{", "}", ",", "ErrExpiredTimestamp", "\n", "}", "\n\n", "return", "sv", ",", "err", "\n", "}" ]
// NewSecretsVerifier returns a SecretsVerifier object in exchange for an http.Header object and signing secret
[ "NewSecretsVerifier", "returns", "a", "SecretsVerifier", "object", "in", "exchange", "for", "an", "http", ".", "Header", "object", "and", "signing", "secret" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/security.go#L55-L76
train
nlopes/slack
security.go
Ensure
func (v SecretsVerifier) Ensure() error { computed := v.hmac.Sum(nil) // use hmac.Equal prevent leaking timing information. if hmac.Equal(computed, v.signature) { return nil } return fmt.Errorf("Expected signing signature: %s, but computed: %s", hex.EncodeToString(v.signature), hex.EncodeToString(computed)) }
go
func (v SecretsVerifier) Ensure() error { computed := v.hmac.Sum(nil) // use hmac.Equal prevent leaking timing information. if hmac.Equal(computed, v.signature) { return nil } return fmt.Errorf("Expected signing signature: %s, but computed: %s", hex.EncodeToString(v.signature), hex.EncodeToString(computed)) }
[ "func", "(", "v", "SecretsVerifier", ")", "Ensure", "(", ")", "error", "{", "computed", ":=", "v", ".", "hmac", ".", "Sum", "(", "nil", ")", "\n", "// use hmac.Equal prevent leaking timing information.", "if", "hmac", ".", "Equal", "(", "computed", ",", "v", ".", "signature", ")", "{", "return", "nil", "\n", "}", "\n\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "hex", ".", "EncodeToString", "(", "v", ".", "signature", ")", ",", "hex", ".", "EncodeToString", "(", "computed", ")", ")", "\n", "}" ]
// Ensure compares the signature sent from Slack with the actual computed hash to judge validity
[ "Ensure", "compares", "the", "signature", "sent", "from", "Slack", "with", "the", "actual", "computed", "hash", "to", "judge", "validity" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/security.go#L83-L91
train
nlopes/slack
files.go
NewGetFilesParameters
func NewGetFilesParameters() GetFilesParameters { return GetFilesParameters{ User: DEFAULT_FILES_USER, Channel: DEFAULT_FILES_CHANNEL, TimestampFrom: DEFAULT_FILES_TS_FROM, TimestampTo: DEFAULT_FILES_TS_TO, Types: DEFAULT_FILES_TYPES, Count: DEFAULT_FILES_COUNT, Page: DEFAULT_FILES_PAGE, } }
go
func NewGetFilesParameters() GetFilesParameters { return GetFilesParameters{ User: DEFAULT_FILES_USER, Channel: DEFAULT_FILES_CHANNEL, TimestampFrom: DEFAULT_FILES_TS_FROM, TimestampTo: DEFAULT_FILES_TS_TO, Types: DEFAULT_FILES_TYPES, Count: DEFAULT_FILES_COUNT, Page: DEFAULT_FILES_PAGE, } }
[ "func", "NewGetFilesParameters", "(", ")", "GetFilesParameters", "{", "return", "GetFilesParameters", "{", "User", ":", "DEFAULT_FILES_USER", ",", "Channel", ":", "DEFAULT_FILES_CHANNEL", ",", "TimestampFrom", ":", "DEFAULT_FILES_TS_FROM", ",", "TimestampTo", ":", "DEFAULT_FILES_TS_TO", ",", "Types", ":", "DEFAULT_FILES_TYPES", ",", "Count", ":", "DEFAULT_FILES_COUNT", ",", "Page", ":", "DEFAULT_FILES_PAGE", ",", "}", "\n", "}" ]
// NewGetFilesParameters provides an instance of GetFilesParameters with all the sane default values set
[ "NewGetFilesParameters", "provides", "an", "instance", "of", "GetFilesParameters", "with", "all", "the", "sane", "default", "values", "set" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/files.go#L146-L156
train
nlopes/slack
files.go
GetFileInfo
func (api *Client) GetFileInfo(fileID string, count, page int) (*File, []Comment, *Paging, error) { return api.GetFileInfoContext(context.Background(), fileID, count, page) }
go
func (api *Client) GetFileInfo(fileID string, count, page int) (*File, []Comment, *Paging, error) { return api.GetFileInfoContext(context.Background(), fileID, count, page) }
[ "func", "(", "api", "*", "Client", ")", "GetFileInfo", "(", "fileID", "string", ",", "count", ",", "page", "int", ")", "(", "*", "File", ",", "[", "]", "Comment", ",", "*", "Paging", ",", "error", ")", "{", "return", "api", ".", "GetFileInfoContext", "(", "context", ".", "Background", "(", ")", ",", "fileID", ",", "count", ",", "page", ")", "\n", "}" ]
// GetFileInfo retrieves a file and related comments
[ "GetFileInfo", "retrieves", "a", "file", "and", "related", "comments" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/files.go#L169-L171
train
nlopes/slack
files.go
GetFileInfoContext
func (api *Client) GetFileInfoContext(ctx context.Context, fileID string, count, page int) (*File, []Comment, *Paging, error) { values := url.Values{ "token": {api.token}, "file": {fileID}, "count": {strconv.Itoa(count)}, "page": {strconv.Itoa(page)}, } response, err := api.fileRequest(ctx, "files.info", values) if err != nil { return nil, nil, nil, err } return &response.File, response.Comments, &response.Paging, nil }
go
func (api *Client) GetFileInfoContext(ctx context.Context, fileID string, count, page int) (*File, []Comment, *Paging, error) { values := url.Values{ "token": {api.token}, "file": {fileID}, "count": {strconv.Itoa(count)}, "page": {strconv.Itoa(page)}, } response, err := api.fileRequest(ctx, "files.info", values) if err != nil { return nil, nil, nil, err } return &response.File, response.Comments, &response.Paging, nil }
[ "func", "(", "api", "*", "Client", ")", "GetFileInfoContext", "(", "ctx", "context", ".", "Context", ",", "fileID", "string", ",", "count", ",", "page", "int", ")", "(", "*", "File", ",", "[", "]", "Comment", ",", "*", "Paging", ",", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "fileID", "}", ",", "\"", "\"", ":", "{", "strconv", ".", "Itoa", "(", "count", ")", "}", ",", "\"", "\"", ":", "{", "strconv", ".", "Itoa", "(", "page", ")", "}", ",", "}", "\n\n", "response", ",", "err", ":=", "api", ".", "fileRequest", "(", "ctx", ",", "\"", "\"", ",", "values", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "return", "&", "response", ".", "File", ",", "response", ".", "Comments", ",", "&", "response", ".", "Paging", ",", "nil", "\n", "}" ]
// GetFileInfoContext retrieves a file and related comments with a custom context
[ "GetFileInfoContext", "retrieves", "a", "file", "and", "related", "comments", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/files.go#L174-L187
train
nlopes/slack
files.go
GetFile
func (api *Client) GetFile(downloadURL string, writer io.Writer) error { return downloadFile(api.httpclient, api.token, downloadURL, writer, api) }
go
func (api *Client) GetFile(downloadURL string, writer io.Writer) error { return downloadFile(api.httpclient, api.token, downloadURL, writer, api) }
[ "func", "(", "api", "*", "Client", ")", "GetFile", "(", "downloadURL", "string", ",", "writer", "io", ".", "Writer", ")", "error", "{", "return", "downloadFile", "(", "api", ".", "httpclient", ",", "api", ".", "token", ",", "downloadURL", ",", "writer", ",", "api", ")", "\n", "}" ]
// GetFile retreives a given file from its private download URL
[ "GetFile", "retreives", "a", "given", "file", "from", "its", "private", "download", "URL" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/files.go#L190-L192
train
nlopes/slack
files.go
GetFiles
func (api *Client) GetFiles(params GetFilesParameters) ([]File, *Paging, error) { return api.GetFilesContext(context.Background(), params) }
go
func (api *Client) GetFiles(params GetFilesParameters) ([]File, *Paging, error) { return api.GetFilesContext(context.Background(), params) }
[ "func", "(", "api", "*", "Client", ")", "GetFiles", "(", "params", "GetFilesParameters", ")", "(", "[", "]", "File", ",", "*", "Paging", ",", "error", ")", "{", "return", "api", ".", "GetFilesContext", "(", "context", ".", "Background", "(", ")", ",", "params", ")", "\n", "}" ]
// GetFiles retrieves all files according to the parameters given
[ "GetFiles", "retrieves", "all", "files", "according", "to", "the", "parameters", "given" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/files.go#L195-L197
train
nlopes/slack
files.go
GetFilesContext
func (api *Client) GetFilesContext(ctx context.Context, params GetFilesParameters) ([]File, *Paging, error) { values := url.Values{ "token": {api.token}, } if params.User != DEFAULT_FILES_USER { values.Add("user", params.User) } if params.Channel != DEFAULT_FILES_CHANNEL { values.Add("channel", params.Channel) } if params.TimestampFrom != DEFAULT_FILES_TS_FROM { values.Add("ts_from", strconv.FormatInt(int64(params.TimestampFrom), 10)) } if params.TimestampTo != DEFAULT_FILES_TS_TO { values.Add("ts_to", strconv.FormatInt(int64(params.TimestampTo), 10)) } if params.Types != DEFAULT_FILES_TYPES { values.Add("types", params.Types) } if params.Count != DEFAULT_FILES_COUNT { values.Add("count", strconv.Itoa(params.Count)) } if params.Page != DEFAULT_FILES_PAGE { values.Add("page", strconv.Itoa(params.Page)) } response, err := api.fileRequest(ctx, "files.list", values) if err != nil { return nil, nil, err } return response.Files, &response.Paging, nil }
go
func (api *Client) GetFilesContext(ctx context.Context, params GetFilesParameters) ([]File, *Paging, error) { values := url.Values{ "token": {api.token}, } if params.User != DEFAULT_FILES_USER { values.Add("user", params.User) } if params.Channel != DEFAULT_FILES_CHANNEL { values.Add("channel", params.Channel) } if params.TimestampFrom != DEFAULT_FILES_TS_FROM { values.Add("ts_from", strconv.FormatInt(int64(params.TimestampFrom), 10)) } if params.TimestampTo != DEFAULT_FILES_TS_TO { values.Add("ts_to", strconv.FormatInt(int64(params.TimestampTo), 10)) } if params.Types != DEFAULT_FILES_TYPES { values.Add("types", params.Types) } if params.Count != DEFAULT_FILES_COUNT { values.Add("count", strconv.Itoa(params.Count)) } if params.Page != DEFAULT_FILES_PAGE { values.Add("page", strconv.Itoa(params.Page)) } response, err := api.fileRequest(ctx, "files.list", values) if err != nil { return nil, nil, err } return response.Files, &response.Paging, nil }
[ "func", "(", "api", "*", "Client", ")", "GetFilesContext", "(", "ctx", "context", ".", "Context", ",", "params", "GetFilesParameters", ")", "(", "[", "]", "File", ",", "*", "Paging", ",", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "}", "\n", "if", "params", ".", "User", "!=", "DEFAULT_FILES_USER", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "User", ")", "\n", "}", "\n", "if", "params", ".", "Channel", "!=", "DEFAULT_FILES_CHANNEL", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "Channel", ")", "\n", "}", "\n", "if", "params", ".", "TimestampFrom", "!=", "DEFAULT_FILES_TS_FROM", "{", "values", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "FormatInt", "(", "int64", "(", "params", ".", "TimestampFrom", ")", ",", "10", ")", ")", "\n", "}", "\n", "if", "params", ".", "TimestampTo", "!=", "DEFAULT_FILES_TS_TO", "{", "values", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "FormatInt", "(", "int64", "(", "params", ".", "TimestampTo", ")", ",", "10", ")", ")", "\n", "}", "\n", "if", "params", ".", "Types", "!=", "DEFAULT_FILES_TYPES", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "Types", ")", "\n", "}", "\n", "if", "params", ".", "Count", "!=", "DEFAULT_FILES_COUNT", "{", "values", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "params", ".", "Count", ")", ")", "\n", "}", "\n", "if", "params", ".", "Page", "!=", "DEFAULT_FILES_PAGE", "{", "values", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "params", ".", "Page", ")", ")", "\n", "}", "\n\n", "response", ",", "err", ":=", "api", ".", "fileRequest", "(", "ctx", ",", "\"", "\"", ",", "values", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "return", "response", ".", "Files", ",", "&", "response", ".", "Paging", ",", "nil", "\n", "}" ]
// GetFilesContext retrieves all files according to the parameters given with a custom context
[ "GetFilesContext", "retrieves", "all", "files", "according", "to", "the", "parameters", "given", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/files.go#L200-L231
train
nlopes/slack
files.go
UploadFile
func (api *Client) UploadFile(params FileUploadParameters) (file *File, err error) { return api.UploadFileContext(context.Background(), params) }
go
func (api *Client) UploadFile(params FileUploadParameters) (file *File, err error) { return api.UploadFileContext(context.Background(), params) }
[ "func", "(", "api", "*", "Client", ")", "UploadFile", "(", "params", "FileUploadParameters", ")", "(", "file", "*", "File", ",", "err", "error", ")", "{", "return", "api", ".", "UploadFileContext", "(", "context", ".", "Background", "(", ")", ",", "params", ")", "\n", "}" ]
// UploadFile uploads a file
[ "UploadFile", "uploads", "a", "file" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/files.go#L234-L236
train
nlopes/slack
files.go
UploadFileContext
func (api *Client) UploadFileContext(ctx context.Context, params FileUploadParameters) (file *File, err error) { // Test if user token is valid. This helps because client.Do doesn't like this for some reason. XXX: More // investigation needed, but for now this will do. _, err = api.AuthTest() if err != nil { return nil, err } if params.Filename == "" { return nil, fmt.Errorf("files.upload: FileUploadParameters.Filename is mandatory") } response := &fileResponseFull{} values := url.Values{ "token": {api.token}, } if params.Filetype != "" { values.Add("filetype", params.Filetype) } if params.Filename != "" { values.Add("filename", params.Filename) } if params.Title != "" { values.Add("title", params.Title) } if params.InitialComment != "" { values.Add("initial_comment", params.InitialComment) } if params.ThreadTimestamp != "" { values.Add("thread_ts", params.ThreadTimestamp) } if len(params.Channels) != 0 { values.Add("channels", strings.Join(params.Channels, ",")) } if params.Content != "" { values.Add("content", params.Content) err = api.postMethod(ctx, "files.upload", values, response) } else if params.File != "" { err = postLocalWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.File, "file", values, response, api) } else if params.Reader != nil { err = postWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.Filename, "file", values, params.Reader, response, api) } if err != nil { return nil, err } return &response.File, response.Err() }
go
func (api *Client) UploadFileContext(ctx context.Context, params FileUploadParameters) (file *File, err error) { // Test if user token is valid. This helps because client.Do doesn't like this for some reason. XXX: More // investigation needed, but for now this will do. _, err = api.AuthTest() if err != nil { return nil, err } if params.Filename == "" { return nil, fmt.Errorf("files.upload: FileUploadParameters.Filename is mandatory") } response := &fileResponseFull{} values := url.Values{ "token": {api.token}, } if params.Filetype != "" { values.Add("filetype", params.Filetype) } if params.Filename != "" { values.Add("filename", params.Filename) } if params.Title != "" { values.Add("title", params.Title) } if params.InitialComment != "" { values.Add("initial_comment", params.InitialComment) } if params.ThreadTimestamp != "" { values.Add("thread_ts", params.ThreadTimestamp) } if len(params.Channels) != 0 { values.Add("channels", strings.Join(params.Channels, ",")) } if params.Content != "" { values.Add("content", params.Content) err = api.postMethod(ctx, "files.upload", values, response) } else if params.File != "" { err = postLocalWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.File, "file", values, response, api) } else if params.Reader != nil { err = postWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.Filename, "file", values, params.Reader, response, api) } if err != nil { return nil, err } return &response.File, response.Err() }
[ "func", "(", "api", "*", "Client", ")", "UploadFileContext", "(", "ctx", "context", ".", "Context", ",", "params", "FileUploadParameters", ")", "(", "file", "*", "File", ",", "err", "error", ")", "{", "// Test if user token is valid. This helps because client.Do doesn't like this for some reason. XXX: More", "// investigation needed, but for now this will do.", "_", ",", "err", "=", "api", ".", "AuthTest", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "params", ".", "Filename", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "response", ":=", "&", "fileResponseFull", "{", "}", "\n", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "}", "\n", "if", "params", ".", "Filetype", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "Filetype", ")", "\n", "}", "\n", "if", "params", ".", "Filename", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "Filename", ")", "\n", "}", "\n", "if", "params", ".", "Title", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "Title", ")", "\n", "}", "\n", "if", "params", ".", "InitialComment", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "InitialComment", ")", "\n", "}", "\n", "if", "params", ".", "ThreadTimestamp", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "ThreadTimestamp", ")", "\n", "}", "\n", "if", "len", "(", "params", ".", "Channels", ")", "!=", "0", "{", "values", ".", "Add", "(", "\"", "\"", ",", "strings", ".", "Join", "(", "params", ".", "Channels", ",", "\"", "\"", ")", ")", "\n", "}", "\n", "if", "params", ".", "Content", "!=", "\"", "\"", "{", "values", ".", "Add", "(", "\"", "\"", ",", "params", ".", "Content", ")", "\n", "err", "=", "api", ".", "postMethod", "(", "ctx", ",", "\"", "\"", ",", "values", ",", "response", ")", "\n", "}", "else", "if", "params", ".", "File", "!=", "\"", "\"", "{", "err", "=", "postLocalWithMultipartResponse", "(", "ctx", ",", "api", ".", "httpclient", ",", "api", ".", "endpoint", "+", "\"", "\"", ",", "params", ".", "File", ",", "\"", "\"", ",", "values", ",", "response", ",", "api", ")", "\n", "}", "else", "if", "params", ".", "Reader", "!=", "nil", "{", "err", "=", "postWithMultipartResponse", "(", "ctx", ",", "api", ".", "httpclient", ",", "api", ".", "endpoint", "+", "\"", "\"", ",", "params", ".", "Filename", ",", "\"", "\"", ",", "values", ",", "params", ".", "Reader", ",", "response", ",", "api", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "response", ".", "File", ",", "response", ".", "Err", "(", ")", "\n", "}" ]
// UploadFileContext uploads a file and setting a custom context
[ "UploadFileContext", "uploads", "a", "file", "and", "setting", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/files.go#L239-L284
train
nlopes/slack
files.go
DeleteFileComment
func (api *Client) DeleteFileComment(commentID, fileID string) error { return api.DeleteFileCommentContext(context.Background(), fileID, commentID) }
go
func (api *Client) DeleteFileComment(commentID, fileID string) error { return api.DeleteFileCommentContext(context.Background(), fileID, commentID) }
[ "func", "(", "api", "*", "Client", ")", "DeleteFileComment", "(", "commentID", ",", "fileID", "string", ")", "error", "{", "return", "api", ".", "DeleteFileCommentContext", "(", "context", ".", "Background", "(", ")", ",", "fileID", ",", "commentID", ")", "\n", "}" ]
// DeleteFileComment deletes a file's comment
[ "DeleteFileComment", "deletes", "a", "file", "s", "comment" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/files.go#L287-L289
train
nlopes/slack
files.go
DeleteFileCommentContext
func (api *Client) DeleteFileCommentContext(ctx context.Context, fileID, commentID string) (err error) { if fileID == "" || commentID == "" { return ErrParametersMissing } values := url.Values{ "token": {api.token}, "file": {fileID}, "id": {commentID}, } _, err = api.fileRequest(ctx, "files.comments.delete", values) return err }
go
func (api *Client) DeleteFileCommentContext(ctx context.Context, fileID, commentID string) (err error) { if fileID == "" || commentID == "" { return ErrParametersMissing } values := url.Values{ "token": {api.token}, "file": {fileID}, "id": {commentID}, } _, err = api.fileRequest(ctx, "files.comments.delete", values) return err }
[ "func", "(", "api", "*", "Client", ")", "DeleteFileCommentContext", "(", "ctx", "context", ".", "Context", ",", "fileID", ",", "commentID", "string", ")", "(", "err", "error", ")", "{", "if", "fileID", "==", "\"", "\"", "||", "commentID", "==", "\"", "\"", "{", "return", "ErrParametersMissing", "\n", "}", "\n\n", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "fileID", "}", ",", "\"", "\"", ":", "{", "commentID", "}", ",", "}", "\n", "_", ",", "err", "=", "api", ".", "fileRequest", "(", "ctx", ",", "\"", "\"", ",", "values", ")", "\n", "return", "err", "\n", "}" ]
// DeleteFileCommentContext deletes a file's comment with a custom context
[ "DeleteFileCommentContext", "deletes", "a", "file", "s", "comment", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/files.go#L292-L304
train
nlopes/slack
files.go
DeleteFile
func (api *Client) DeleteFile(fileID string) error { return api.DeleteFileContext(context.Background(), fileID) }
go
func (api *Client) DeleteFile(fileID string) error { return api.DeleteFileContext(context.Background(), fileID) }
[ "func", "(", "api", "*", "Client", ")", "DeleteFile", "(", "fileID", "string", ")", "error", "{", "return", "api", ".", "DeleteFileContext", "(", "context", ".", "Background", "(", ")", ",", "fileID", ")", "\n", "}" ]
// DeleteFile deletes a file
[ "DeleteFile", "deletes", "a", "file" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/files.go#L307-L309
train
nlopes/slack
files.go
DeleteFileContext
func (api *Client) DeleteFileContext(ctx context.Context, fileID string) (err error) { values := url.Values{ "token": {api.token}, "file": {fileID}, } _, err = api.fileRequest(ctx, "files.delete", values) return err }
go
func (api *Client) DeleteFileContext(ctx context.Context, fileID string) (err error) { values := url.Values{ "token": {api.token}, "file": {fileID}, } _, err = api.fileRequest(ctx, "files.delete", values) return err }
[ "func", "(", "api", "*", "Client", ")", "DeleteFileContext", "(", "ctx", "context", ".", "Context", ",", "fileID", "string", ")", "(", "err", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "fileID", "}", ",", "}", "\n\n", "_", ",", "err", "=", "api", ".", "fileRequest", "(", "ctx", ",", "\"", "\"", ",", "values", ")", "\n", "return", "err", "\n", "}" ]
// DeleteFileContext deletes a file with a custom context
[ "DeleteFileContext", "deletes", "a", "file", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/files.go#L312-L320
train
nlopes/slack
im.go
CloseIMChannel
func (api *Client) CloseIMChannel(channel string) (bool, bool, error) { return api.CloseIMChannelContext(context.Background(), channel) }
go
func (api *Client) CloseIMChannel(channel string) (bool, bool, error) { return api.CloseIMChannelContext(context.Background(), channel) }
[ "func", "(", "api", "*", "Client", ")", "CloseIMChannel", "(", "channel", "string", ")", "(", "bool", ",", "bool", ",", "error", ")", "{", "return", "api", ".", "CloseIMChannelContext", "(", "context", ".", "Background", "(", ")", ",", "channel", ")", "\n", "}" ]
// CloseIMChannel closes the direct message channel
[ "CloseIMChannel", "closes", "the", "direct", "message", "channel" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/im.go#L40-L42
train
nlopes/slack
im.go
CloseIMChannelContext
func (api *Client) CloseIMChannelContext(ctx context.Context, channel string) (bool, bool, error) { values := url.Values{ "token": {api.token}, "channel": {channel}, } response, err := api.imRequest(ctx, "im.close", values) if err != nil { return false, false, err } return response.NoOp, response.AlreadyClosed, nil }
go
func (api *Client) CloseIMChannelContext(ctx context.Context, channel string) (bool, bool, error) { values := url.Values{ "token": {api.token}, "channel": {channel}, } response, err := api.imRequest(ctx, "im.close", values) if err != nil { return false, false, err } return response.NoOp, response.AlreadyClosed, nil }
[ "func", "(", "api", "*", "Client", ")", "CloseIMChannelContext", "(", "ctx", "context", ".", "Context", ",", "channel", "string", ")", "(", "bool", ",", "bool", ",", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "channel", "}", ",", "}", "\n\n", "response", ",", "err", ":=", "api", ".", "imRequest", "(", "ctx", ",", "\"", "\"", ",", "values", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "false", ",", "err", "\n", "}", "\n", "return", "response", ".", "NoOp", ",", "response", ".", "AlreadyClosed", ",", "nil", "\n", "}" ]
// CloseIMChannelContext closes the direct message channel with a custom context
[ "CloseIMChannelContext", "closes", "the", "direct", "message", "channel", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/im.go#L45-L56
train
nlopes/slack
im.go
OpenIMChannel
func (api *Client) OpenIMChannel(user string) (bool, bool, string, error) { return api.OpenIMChannelContext(context.Background(), user) }
go
func (api *Client) OpenIMChannel(user string) (bool, bool, string, error) { return api.OpenIMChannelContext(context.Background(), user) }
[ "func", "(", "api", "*", "Client", ")", "OpenIMChannel", "(", "user", "string", ")", "(", "bool", ",", "bool", ",", "string", ",", "error", ")", "{", "return", "api", ".", "OpenIMChannelContext", "(", "context", ".", "Background", "(", ")", ",", "user", ")", "\n", "}" ]
// OpenIMChannel opens a direct message channel to the user provided as argument // Returns some status and the channel ID
[ "OpenIMChannel", "opens", "a", "direct", "message", "channel", "to", "the", "user", "provided", "as", "argument", "Returns", "some", "status", "and", "the", "channel", "ID" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/im.go#L60-L62
train
nlopes/slack
im.go
OpenIMChannelContext
func (api *Client) OpenIMChannelContext(ctx context.Context, user string) (bool, bool, string, error) { values := url.Values{ "token": {api.token}, "user": {user}, } response, err := api.imRequest(ctx, "im.open", values) if err != nil { return false, false, "", err } return response.NoOp, response.AlreadyOpen, response.Channel.ID, nil }
go
func (api *Client) OpenIMChannelContext(ctx context.Context, user string) (bool, bool, string, error) { values := url.Values{ "token": {api.token}, "user": {user}, } response, err := api.imRequest(ctx, "im.open", values) if err != nil { return false, false, "", err } return response.NoOp, response.AlreadyOpen, response.Channel.ID, nil }
[ "func", "(", "api", "*", "Client", ")", "OpenIMChannelContext", "(", "ctx", "context", ".", "Context", ",", "user", "string", ")", "(", "bool", ",", "bool", ",", "string", ",", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "user", "}", ",", "}", "\n\n", "response", ",", "err", ":=", "api", ".", "imRequest", "(", "ctx", ",", "\"", "\"", ",", "values", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "false", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "response", ".", "NoOp", ",", "response", ".", "AlreadyOpen", ",", "response", ".", "Channel", ".", "ID", ",", "nil", "\n", "}" ]
// OpenIMChannelContext opens a direct message channel to the user provided as argument with a custom context // Returns some status and the channel ID
[ "OpenIMChannelContext", "opens", "a", "direct", "message", "channel", "to", "the", "user", "provided", "as", "argument", "with", "a", "custom", "context", "Returns", "some", "status", "and", "the", "channel", "ID" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/im.go#L66-L77
train
nlopes/slack
im.go
MarkIMChannel
func (api *Client) MarkIMChannel(channel, ts string) (err error) { return api.MarkIMChannelContext(context.Background(), channel, ts) }
go
func (api *Client) MarkIMChannel(channel, ts string) (err error) { return api.MarkIMChannelContext(context.Background(), channel, ts) }
[ "func", "(", "api", "*", "Client", ")", "MarkIMChannel", "(", "channel", ",", "ts", "string", ")", "(", "err", "error", ")", "{", "return", "api", ".", "MarkIMChannelContext", "(", "context", ".", "Background", "(", ")", ",", "channel", ",", "ts", ")", "\n", "}" ]
// MarkIMChannel sets the read mark of a direct message channel to a specific point
[ "MarkIMChannel", "sets", "the", "read", "mark", "of", "a", "direct", "message", "channel", "to", "a", "specific", "point" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/im.go#L80-L82
train
nlopes/slack
im.go
MarkIMChannelContext
func (api *Client) MarkIMChannelContext(ctx context.Context, channel, ts string) error { values := url.Values{ "token": {api.token}, "channel": {channel}, "ts": {ts}, } _, err := api.imRequest(ctx, "im.mark", values) return err }
go
func (api *Client) MarkIMChannelContext(ctx context.Context, channel, ts string) error { values := url.Values{ "token": {api.token}, "channel": {channel}, "ts": {ts}, } _, err := api.imRequest(ctx, "im.mark", values) return err }
[ "func", "(", "api", "*", "Client", ")", "MarkIMChannelContext", "(", "ctx", "context", ".", "Context", ",", "channel", ",", "ts", "string", ")", "error", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "channel", "}", ",", "\"", "\"", ":", "{", "ts", "}", ",", "}", "\n\n", "_", ",", "err", ":=", "api", ".", "imRequest", "(", "ctx", ",", "\"", "\"", ",", "values", ")", "\n", "return", "err", "\n", "}" ]
// MarkIMChannelContext sets the read mark of a direct message channel to a specific point with a custom context
[ "MarkIMChannelContext", "sets", "the", "read", "mark", "of", "a", "direct", "message", "channel", "to", "a", "specific", "point", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/im.go#L85-L94
train
nlopes/slack
im.go
GetIMHistory
func (api *Client) GetIMHistory(channel string, params HistoryParameters) (*History, error) { return api.GetIMHistoryContext(context.Background(), channel, params) }
go
func (api *Client) GetIMHistory(channel string, params HistoryParameters) (*History, error) { return api.GetIMHistoryContext(context.Background(), channel, params) }
[ "func", "(", "api", "*", "Client", ")", "GetIMHistory", "(", "channel", "string", ",", "params", "HistoryParameters", ")", "(", "*", "History", ",", "error", ")", "{", "return", "api", ".", "GetIMHistoryContext", "(", "context", ".", "Background", "(", ")", ",", "channel", ",", "params", ")", "\n", "}" ]
// GetIMHistory retrieves the direct message channel history
[ "GetIMHistory", "retrieves", "the", "direct", "message", "channel", "history" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/im.go#L97-L99
train
nlopes/slack
im.go
GetIMChannelsContext
func (api *Client) GetIMChannelsContext(ctx context.Context) ([]IM, error) { values := url.Values{ "token": {api.token}, } response, err := api.imRequest(ctx, "im.list", values) if err != nil { return nil, err } return response.IMs, nil }
go
func (api *Client) GetIMChannelsContext(ctx context.Context) ([]IM, error) { values := url.Values{ "token": {api.token}, } response, err := api.imRequest(ctx, "im.list", values) if err != nil { return nil, err } return response.IMs, nil }
[ "func", "(", "api", "*", "Client", ")", "GetIMChannelsContext", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "IM", ",", "error", ")", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "}", "\n\n", "response", ",", "err", ":=", "api", ".", "imRequest", "(", "ctx", ",", "\"", "\"", ",", "values", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "response", ".", "IMs", ",", "nil", "\n", "}" ]
// GetIMChannelsContext returns the list of direct message channels with a custom context
[ "GetIMChannelsContext", "returns", "the", "list", "of", "direct", "message", "channels", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/im.go#L144-L154
train
nlopes/slack
websocket.go
Disconnect
func (rtm *RTM) Disconnect() error { // always push into the kill channel when invoked, // this lets the ManagedConnection() function properly clean up. // if the buffer is full then just continue on. select { case rtm.killChannel <- true: return nil case <-rtm.disconnected: return ErrAlreadyDisconnected } }
go
func (rtm *RTM) Disconnect() error { // always push into the kill channel when invoked, // this lets the ManagedConnection() function properly clean up. // if the buffer is full then just continue on. select { case rtm.killChannel <- true: return nil case <-rtm.disconnected: return ErrAlreadyDisconnected } }
[ "func", "(", "rtm", "*", "RTM", ")", "Disconnect", "(", ")", "error", "{", "// always push into the kill channel when invoked,", "// this lets the ManagedConnection() function properly clean up.", "// if the buffer is full then just continue on.", "select", "{", "case", "rtm", ".", "killChannel", "<-", "true", ":", "return", "nil", "\n", "case", "<-", "rtm", ".", "disconnected", ":", "return", "ErrAlreadyDisconnected", "\n", "}", "\n", "}" ]
// Disconnect and wait, blocking until a successful disconnection.
[ "Disconnect", "and", "wait", "blocking", "until", "a", "successful", "disconnection", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/websocket.go#L68-L78
train
nlopes/slack
websocket.go
SendMessage
func (rtm *RTM) SendMessage(msg *OutgoingMessage) { if msg == nil { rtm.Debugln("Error: Attempted to SendMessage(nil)") return } rtm.outgoingMessages <- *msg }
go
func (rtm *RTM) SendMessage(msg *OutgoingMessage) { if msg == nil { rtm.Debugln("Error: Attempted to SendMessage(nil)") return } rtm.outgoingMessages <- *msg }
[ "func", "(", "rtm", "*", "RTM", ")", "SendMessage", "(", "msg", "*", "OutgoingMessage", ")", "{", "if", "msg", "==", "nil", "{", "rtm", ".", "Debugln", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "rtm", ".", "outgoingMessages", "<-", "*", "msg", "\n", "}" ]
// SendMessage submits a simple message through the websocket. For // more complicated messages, use `rtm.PostMessage` with a complete // struct describing your attachments and all.
[ "SendMessage", "submits", "a", "simple", "message", "through", "the", "websocket", ".", "For", "more", "complicated", "messages", "use", "rtm", ".", "PostMessage", "with", "a", "complete", "struct", "describing", "your", "attachments", "and", "all", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/websocket.go#L91-L98
train
nlopes/slack
admin.go
DisableUser
func (api *Client) DisableUser(teamName string, uid string) error { return api.DisableUserContext(context.Background(), teamName, uid) }
go
func (api *Client) DisableUser(teamName string, uid string) error { return api.DisableUserContext(context.Background(), teamName, uid) }
[ "func", "(", "api", "*", "Client", ")", "DisableUser", "(", "teamName", "string", ",", "uid", "string", ")", "error", "{", "return", "api", ".", "DisableUserContext", "(", "context", ".", "Background", "(", ")", ",", "teamName", ",", "uid", ")", "\n", "}" ]
// DisableUser disabled a user account, given a user ID
[ "DisableUser", "disabled", "a", "user", "account", "given", "a", "user", "ID" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/admin.go#L21-L23
train
nlopes/slack
admin.go
InviteGuest
func (api *Client) InviteGuest(teamName, channel, firstName, lastName, emailAddress string) error { return api.InviteGuestContext(context.Background(), teamName, channel, firstName, lastName, emailAddress) }
go
func (api *Client) InviteGuest(teamName, channel, firstName, lastName, emailAddress string) error { return api.InviteGuestContext(context.Background(), teamName, channel, firstName, lastName, emailAddress) }
[ "func", "(", "api", "*", "Client", ")", "InviteGuest", "(", "teamName", ",", "channel", ",", "firstName", ",", "lastName", ",", "emailAddress", "string", ")", "error", "{", "return", "api", ".", "InviteGuestContext", "(", "context", ".", "Background", "(", ")", ",", "teamName", ",", "channel", ",", "firstName", ",", "lastName", ",", "emailAddress", ")", "\n", "}" ]
// InviteGuest invites a user to Slack as a single-channel guest
[ "InviteGuest", "invites", "a", "user", "to", "Slack", "as", "a", "single", "-", "channel", "guest" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/admin.go#L42-L44
train
nlopes/slack
admin.go
InviteGuestContext
func (api *Client) InviteGuestContext(ctx context.Context, teamName, channel, firstName, lastName, emailAddress string) error { values := url.Values{ "email": {emailAddress}, "channels": {channel}, "first_name": {firstName}, "last_name": {lastName}, "ultra_restricted": {"1"}, "token": {api.token}, "resend": {"true"}, "set_active": {"true"}, "_attempts": {"1"}, } err := api.adminRequest(ctx, "invite", teamName, values) if err != nil { return fmt.Errorf("Failed to invite single-channel guest: %s", err) } return nil }
go
func (api *Client) InviteGuestContext(ctx context.Context, teamName, channel, firstName, lastName, emailAddress string) error { values := url.Values{ "email": {emailAddress}, "channels": {channel}, "first_name": {firstName}, "last_name": {lastName}, "ultra_restricted": {"1"}, "token": {api.token}, "resend": {"true"}, "set_active": {"true"}, "_attempts": {"1"}, } err := api.adminRequest(ctx, "invite", teamName, values) if err != nil { return fmt.Errorf("Failed to invite single-channel guest: %s", err) } return nil }
[ "func", "(", "api", "*", "Client", ")", "InviteGuestContext", "(", "ctx", "context", ".", "Context", ",", "teamName", ",", "channel", ",", "firstName", ",", "lastName", ",", "emailAddress", "string", ")", "error", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "emailAddress", "}", ",", "\"", "\"", ":", "{", "channel", "}", ",", "\"", "\"", ":", "{", "firstName", "}", ",", "\"", "\"", ":", "{", "lastName", "}", ",", "\"", "\"", ":", "{", "\"", "\"", "}", ",", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "\"", "\"", "}", ",", "\"", "\"", ":", "{", "\"", "\"", "}", ",", "\"", "\"", ":", "{", "\"", "\"", "}", ",", "}", "\n\n", "err", ":=", "api", ".", "adminRequest", "(", "ctx", ",", "\"", "\"", ",", "teamName", ",", "values", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// InviteGuestContext invites a user to Slack as a single-channel guest with a custom context
[ "InviteGuestContext", "invites", "a", "user", "to", "Slack", "as", "a", "single", "-", "channel", "guest", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/admin.go#L47-L66
train
nlopes/slack
admin.go
InviteRestricted
func (api *Client) InviteRestricted(teamName, channel, firstName, lastName, emailAddress string) error { return api.InviteRestrictedContext(context.Background(), teamName, channel, firstName, lastName, emailAddress) }
go
func (api *Client) InviteRestricted(teamName, channel, firstName, lastName, emailAddress string) error { return api.InviteRestrictedContext(context.Background(), teamName, channel, firstName, lastName, emailAddress) }
[ "func", "(", "api", "*", "Client", ")", "InviteRestricted", "(", "teamName", ",", "channel", ",", "firstName", ",", "lastName", ",", "emailAddress", "string", ")", "error", "{", "return", "api", ".", "InviteRestrictedContext", "(", "context", ".", "Background", "(", ")", ",", "teamName", ",", "channel", ",", "firstName", ",", "lastName", ",", "emailAddress", ")", "\n", "}" ]
// InviteRestricted invites a user to Slack as a restricted account
[ "InviteRestricted", "invites", "a", "user", "to", "Slack", "as", "a", "restricted", "account" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/admin.go#L69-L71
train
nlopes/slack
admin.go
InviteToTeam
func (api *Client) InviteToTeam(teamName, firstName, lastName, emailAddress string) error { return api.InviteToTeamContext(context.Background(), teamName, firstName, lastName, emailAddress) }
go
func (api *Client) InviteToTeam(teamName, firstName, lastName, emailAddress string) error { return api.InviteToTeamContext(context.Background(), teamName, firstName, lastName, emailAddress) }
[ "func", "(", "api", "*", "Client", ")", "InviteToTeam", "(", "teamName", ",", "firstName", ",", "lastName", ",", "emailAddress", "string", ")", "error", "{", "return", "api", ".", "InviteToTeamContext", "(", "context", ".", "Background", "(", ")", ",", "teamName", ",", "firstName", ",", "lastName", ",", "emailAddress", ")", "\n", "}" ]
// InviteToTeam invites a user to a Slack team
[ "InviteToTeam", "invites", "a", "user", "to", "a", "Slack", "team" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/admin.go#L96-L98
train
nlopes/slack
admin.go
SetRegular
func (api *Client) SetRegular(teamName, user string) error { return api.SetRegularContext(context.Background(), teamName, user) }
go
func (api *Client) SetRegular(teamName, user string) error { return api.SetRegularContext(context.Background(), teamName, user) }
[ "func", "(", "api", "*", "Client", ")", "SetRegular", "(", "teamName", ",", "user", "string", ")", "error", "{", "return", "api", ".", "SetRegularContext", "(", "context", ".", "Background", "(", ")", ",", "teamName", ",", "user", ")", "\n", "}" ]
// SetRegular enables the specified user
[ "SetRegular", "enables", "the", "specified", "user" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/admin.go#L120-L122
train
nlopes/slack
admin.go
SetRegularContext
func (api *Client) SetRegularContext(ctx context.Context, teamName, user string) error { values := url.Values{ "user": {user}, "token": {api.token}, "set_active": {"true"}, "_attempts": {"1"}, } err := api.adminRequest(ctx, "setRegular", teamName, values) if err != nil { return fmt.Errorf("Failed to change the user (%s) to a regular user: %s", user, err) } return nil }
go
func (api *Client) SetRegularContext(ctx context.Context, teamName, user string) error { values := url.Values{ "user": {user}, "token": {api.token}, "set_active": {"true"}, "_attempts": {"1"}, } err := api.adminRequest(ctx, "setRegular", teamName, values) if err != nil { return fmt.Errorf("Failed to change the user (%s) to a regular user: %s", user, err) } return nil }
[ "func", "(", "api", "*", "Client", ")", "SetRegularContext", "(", "ctx", "context", ".", "Context", ",", "teamName", ",", "user", "string", ")", "error", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "user", "}", ",", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "\"", "\"", "}", ",", "\"", "\"", ":", "{", "\"", "\"", "}", ",", "}", "\n\n", "err", ":=", "api", ".", "adminRequest", "(", "ctx", ",", "\"", "\"", ",", "teamName", ",", "values", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "user", ",", "err", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// SetRegularContext enables the specified user with a custom context
[ "SetRegularContext", "enables", "the", "specified", "user", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/admin.go#L125-L139
train
nlopes/slack
admin.go
SendSSOBindingEmail
func (api *Client) SendSSOBindingEmail(teamName, user string) error { return api.SendSSOBindingEmailContext(context.Background(), teamName, user) }
go
func (api *Client) SendSSOBindingEmail(teamName, user string) error { return api.SendSSOBindingEmailContext(context.Background(), teamName, user) }
[ "func", "(", "api", "*", "Client", ")", "SendSSOBindingEmail", "(", "teamName", ",", "user", "string", ")", "error", "{", "return", "api", ".", "SendSSOBindingEmailContext", "(", "context", ".", "Background", "(", ")", ",", "teamName", ",", "user", ")", "\n", "}" ]
// SendSSOBindingEmail sends an SSO binding email to the specified user
[ "SendSSOBindingEmail", "sends", "an", "SSO", "binding", "email", "to", "the", "specified", "user" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/admin.go#L142-L144
train
nlopes/slack
admin.go
SetUltraRestricted
func (api *Client) SetUltraRestricted(teamName, uid, channel string) error { return api.SetUltraRestrictedContext(context.Background(), teamName, uid, channel) }
go
func (api *Client) SetUltraRestricted(teamName, uid, channel string) error { return api.SetUltraRestrictedContext(context.Background(), teamName, uid, channel) }
[ "func", "(", "api", "*", "Client", ")", "SetUltraRestricted", "(", "teamName", ",", "uid", ",", "channel", "string", ")", "error", "{", "return", "api", ".", "SetUltraRestrictedContext", "(", "context", ".", "Background", "(", ")", ",", "teamName", ",", "uid", ",", "channel", ")", "\n", "}" ]
// SetUltraRestricted converts a user into a single-channel guest
[ "SetUltraRestricted", "converts", "a", "user", "into", "a", "single", "-", "channel", "guest" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/admin.go#L164-L166
train
nlopes/slack
admin.go
SetRestricted
func (api *Client) SetRestricted(teamName, uid string, channelIds ...string) error { return api.SetRestrictedContext(context.Background(), teamName, uid, channelIds...) }
go
func (api *Client) SetRestricted(teamName, uid string, channelIds ...string) error { return api.SetRestrictedContext(context.Background(), teamName, uid, channelIds...) }
[ "func", "(", "api", "*", "Client", ")", "SetRestricted", "(", "teamName", ",", "uid", "string", ",", "channelIds", "...", "string", ")", "error", "{", "return", "api", ".", "SetRestrictedContext", "(", "context", ".", "Background", "(", ")", ",", "teamName", ",", "uid", ",", "channelIds", "...", ")", "\n", "}" ]
// SetRestricted converts a user into a restricted account
[ "SetRestricted", "converts", "a", "user", "into", "a", "restricted", "account" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/admin.go#L187-L189
train
nlopes/slack
admin.go
SetRestrictedContext
func (api *Client) SetRestrictedContext(ctx context.Context, teamName, uid string, channelIds ...string) error { values := url.Values{ "user": {uid}, "token": {api.token}, "set_active": {"true"}, "_attempts": {"1"}, "channels": {strings.Join(channelIds, ",")}, } err := api.adminRequest(ctx, "setRestricted", teamName, values) if err != nil { return fmt.Errorf("failed to restrict account: %s", err) } return nil }
go
func (api *Client) SetRestrictedContext(ctx context.Context, teamName, uid string, channelIds ...string) error { values := url.Values{ "user": {uid}, "token": {api.token}, "set_active": {"true"}, "_attempts": {"1"}, "channels": {strings.Join(channelIds, ",")}, } err := api.adminRequest(ctx, "setRestricted", teamName, values) if err != nil { return fmt.Errorf("failed to restrict account: %s", err) } return nil }
[ "func", "(", "api", "*", "Client", ")", "SetRestrictedContext", "(", "ctx", "context", ".", "Context", ",", "teamName", ",", "uid", "string", ",", "channelIds", "...", "string", ")", "error", "{", "values", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "uid", "}", ",", "\"", "\"", ":", "{", "api", ".", "token", "}", ",", "\"", "\"", ":", "{", "\"", "\"", "}", ",", "\"", "\"", ":", "{", "\"", "\"", "}", ",", "\"", "\"", ":", "{", "strings", ".", "Join", "(", "channelIds", ",", "\"", "\"", ")", "}", ",", "}", "\n\n", "err", ":=", "api", ".", "adminRequest", "(", "ctx", ",", "\"", "\"", ",", "teamName", ",", "values", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// SetRestrictedContext converts a user into a restricted account with a custom context
[ "SetRestrictedContext", "converts", "a", "user", "into", "a", "restricted", "account", "with", "a", "custom", "context" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/admin.go#L192-L207
train
nlopes/slack
block_object.go
NewImageBlockObject
func NewImageBlockObject(imageURL, altText string) *ImageBlockObject { return &ImageBlockObject{ Type: motImage, ImageURL: imageURL, AltText: altText, } }
go
func NewImageBlockObject(imageURL, altText string) *ImageBlockObject { return &ImageBlockObject{ Type: motImage, ImageURL: imageURL, AltText: altText, } }
[ "func", "NewImageBlockObject", "(", "imageURL", ",", "altText", "string", ")", "*", "ImageBlockObject", "{", "return", "&", "ImageBlockObject", "{", "Type", ":", "motImage", ",", "ImageURL", ":", "imageURL", ",", "AltText", ":", "altText", ",", "}", "\n", "}" ]
// NewImageBlockObject returns a new instance of an image block element
[ "NewImageBlockObject", "returns", "a", "new", "instance", "of", "an", "image", "block", "element" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block_object.go#L37-L43
train
nlopes/slack
block_object.go
NewTextBlockObject
func NewTextBlockObject(elementType, text string, emoji, verbatim bool) *TextBlockObject { return &TextBlockObject{ Type: elementType, Text: text, Emoji: emoji, Verbatim: verbatim, } }
go
func NewTextBlockObject(elementType, text string, emoji, verbatim bool) *TextBlockObject { return &TextBlockObject{ Type: elementType, Text: text, Emoji: emoji, Verbatim: verbatim, } }
[ "func", "NewTextBlockObject", "(", "elementType", ",", "text", "string", ",", "emoji", ",", "verbatim", "bool", ")", "*", "TextBlockObject", "{", "return", "&", "TextBlockObject", "{", "Type", ":", "elementType", ",", "Text", ":", "text", ",", "Emoji", ":", "emoji", ",", "Verbatim", ":", "verbatim", ",", "}", "\n", "}" ]
// NewTextBlockObject returns an instance of a new Text Block Object
[ "NewTextBlockObject", "returns", "an", "instance", "of", "a", "new", "Text", "Block", "Object" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block_object.go#L61-L68
train
nlopes/slack
block_object.go
NewConfirmationBlockObject
func NewConfirmationBlockObject(title, text, confirm, deny *TextBlockObject) *ConfirmationBlockObject { return &ConfirmationBlockObject{ Title: title, Text: text, Confirm: confirm, Deny: deny, } }
go
func NewConfirmationBlockObject(title, text, confirm, deny *TextBlockObject) *ConfirmationBlockObject { return &ConfirmationBlockObject{ Title: title, Text: text, Confirm: confirm, Deny: deny, } }
[ "func", "NewConfirmationBlockObject", "(", "title", ",", "text", ",", "confirm", ",", "deny", "*", "TextBlockObject", ")", "*", "ConfirmationBlockObject", "{", "return", "&", "ConfirmationBlockObject", "{", "Title", ":", "title", ",", "Text", ":", "text", ",", "Confirm", ":", "confirm", ",", "Deny", ":", "deny", ",", "}", "\n", "}" ]
// NewConfirmationBlockObject returns an instance of a new Confirmation Block Object
[ "NewConfirmationBlockObject", "returns", "an", "instance", "of", "a", "new", "Confirmation", "Block", "Object" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block_object.go#L88-L95
train
nlopes/slack
block_object.go
NewOptionBlockObject
func NewOptionBlockObject(value string, text *TextBlockObject) *OptionBlockObject { return &OptionBlockObject{ Text: text, Value: value, } }
go
func NewOptionBlockObject(value string, text *TextBlockObject) *OptionBlockObject { return &OptionBlockObject{ Text: text, Value: value, } }
[ "func", "NewOptionBlockObject", "(", "value", "string", ",", "text", "*", "TextBlockObject", ")", "*", "OptionBlockObject", "{", "return", "&", "OptionBlockObject", "{", "Text", ":", "text", ",", "Value", ":", "value", ",", "}", "\n", "}" ]
// NewOptionBlockObject returns an instance of a new Option Block Element
[ "NewOptionBlockObject", "returns", "an", "instance", "of", "a", "new", "Option", "Block", "Element" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block_object.go#L106-L111
train
nlopes/slack
block_object.go
NewOptionGroupBlockElement
func NewOptionGroupBlockElement(label *TextBlockObject, options ...*OptionBlockObject) *OptionGroupBlockObject { return &OptionGroupBlockObject{ Label: label, Options: options, } }
go
func NewOptionGroupBlockElement(label *TextBlockObject, options ...*OptionBlockObject) *OptionGroupBlockObject { return &OptionGroupBlockObject{ Label: label, Options: options, } }
[ "func", "NewOptionGroupBlockElement", "(", "label", "*", "TextBlockObject", ",", "options", "...", "*", "OptionBlockObject", ")", "*", "OptionGroupBlockObject", "{", "return", "&", "OptionGroupBlockObject", "{", "Label", ":", "label", ",", "Options", ":", "options", ",", "}", "\n", "}" ]
// NewOptionGroupBlockElement returns an instance of a new option group block element
[ "NewOptionGroupBlockElement", "returns", "an", "instance", "of", "a", "new", "option", "group", "block", "element" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block_object.go#L132-L137
train
nlopes/slack
dialog_text.go
NewTextInput
func NewTextInput(name, label, text string) *TextInputElement { return &TextInputElement{ DialogInput: DialogInput{ Type: InputTypeText, Name: name, Label: label, }, Value: text, } }
go
func NewTextInput(name, label, text string) *TextInputElement { return &TextInputElement{ DialogInput: DialogInput{ Type: InputTypeText, Name: name, Label: label, }, Value: text, } }
[ "func", "NewTextInput", "(", "name", ",", "label", ",", "text", "string", ")", "*", "TextInputElement", "{", "return", "&", "TextInputElement", "{", "DialogInput", ":", "DialogInput", "{", "Type", ":", "InputTypeText", ",", "Name", ":", "name", ",", "Label", ":", "label", ",", "}", ",", "Value", ":", "text", ",", "}", "\n", "}" ]
// NewTextInput constructor for a `text` input
[ "NewTextInput", "constructor", "for", "a", "text", "input" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/dialog_text.go#L29-L38
train
nlopes/slack
dialog_text.go
NewTextAreaInput
func NewTextAreaInput(name, label, text string) *TextInputElement { return &TextInputElement{ DialogInput: DialogInput{ Type: InputTypeTextArea, Name: name, Label: label, }, Value: text, } }
go
func NewTextAreaInput(name, label, text string) *TextInputElement { return &TextInputElement{ DialogInput: DialogInput{ Type: InputTypeTextArea, Name: name, Label: label, }, Value: text, } }
[ "func", "NewTextAreaInput", "(", "name", ",", "label", ",", "text", "string", ")", "*", "TextInputElement", "{", "return", "&", "TextInputElement", "{", "DialogInput", ":", "DialogInput", "{", "Type", ":", "InputTypeTextArea", ",", "Name", ":", "name", ",", "Label", ":", "label", ",", "}", ",", "Value", ":", "text", ",", "}", "\n", "}" ]
// NewTextAreaInput constructor for a `textarea` input
[ "NewTextAreaInput", "constructor", "for", "a", "textarea", "input" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/dialog_text.go#L41-L50
train
nlopes/slack
block_element.go
NewImageBlockElement
func NewImageBlockElement(imageURL, altText string) *ImageBlockElement { return &ImageBlockElement{ Type: metImage, ImageURL: imageURL, AltText: altText, } }
go
func NewImageBlockElement(imageURL, altText string) *ImageBlockElement { return &ImageBlockElement{ Type: metImage, ImageURL: imageURL, AltText: altText, } }
[ "func", "NewImageBlockElement", "(", "imageURL", ",", "altText", "string", ")", "*", "ImageBlockElement", "{", "return", "&", "ImageBlockElement", "{", "Type", ":", "metImage", ",", "ImageURL", ":", "imageURL", ",", "AltText", ":", "altText", ",", "}", "\n", "}" ]
// NewImageBlockElement returns a new instance of an image block element
[ "NewImageBlockElement", "returns", "a", "new", "instance", "of", "an", "image", "block", "element" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block_element.go#L27-L33
train
nlopes/slack
block_element.go
NewButtonBlockElement
func NewButtonBlockElement(actionID, value string, text *TextBlockObject) *ButtonBlockElement { return &ButtonBlockElement{ Type: metButton, ActionID: actionID, Text: text, Value: value, } }
go
func NewButtonBlockElement(actionID, value string, text *TextBlockObject) *ButtonBlockElement { return &ButtonBlockElement{ Type: metButton, ActionID: actionID, Text: text, Value: value, } }
[ "func", "NewButtonBlockElement", "(", "actionID", ",", "value", "string", ",", "text", "*", "TextBlockObject", ")", "*", "ButtonBlockElement", "{", "return", "&", "ButtonBlockElement", "{", "Type", ":", "metButton", ",", "ActionID", ":", "actionID", ",", "Text", ":", "text", ",", "Value", ":", "value", ",", "}", "\n", "}" ]
// NewButtonBlockElement returns an instance of a new button element to be used within a block
[ "NewButtonBlockElement", "returns", "an", "instance", "of", "a", "new", "button", "element", "to", "be", "used", "within", "a", "block" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block_element.go#L55-L62
train
nlopes/slack
block_element.go
NewOptionsSelectBlockElement
func NewOptionsSelectBlockElement(optType string, placeholder *TextBlockObject, actionID string, options ...*OptionBlockObject) *SelectBlockElement { return &SelectBlockElement{ Type: optType, Placeholder: placeholder, ActionID: actionID, Options: options, } }
go
func NewOptionsSelectBlockElement(optType string, placeholder *TextBlockObject, actionID string, options ...*OptionBlockObject) *SelectBlockElement { return &SelectBlockElement{ Type: optType, Placeholder: placeholder, ActionID: actionID, Options: options, } }
[ "func", "NewOptionsSelectBlockElement", "(", "optType", "string", ",", "placeholder", "*", "TextBlockObject", ",", "actionID", "string", ",", "options", "...", "*", "OptionBlockObject", ")", "*", "SelectBlockElement", "{", "return", "&", "SelectBlockElement", "{", "Type", ":", "optType", ",", "Placeholder", ":", "placeholder", ",", "ActionID", ":", "actionID", ",", "Options", ":", "options", ",", "}", "\n", "}" ]
// NewOptionsSelectBlockElement returns a new instance of SelectBlockElement for use with // the Options object only.
[ "NewOptionsSelectBlockElement", "returns", "a", "new", "instance", "of", "SelectBlockElement", "for", "use", "with", "the", "Options", "object", "only", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block_element.go#L85-L92
train
nlopes/slack
block_element.go
NewOptionsGroupSelectBlockElement
func NewOptionsGroupSelectBlockElement( optType string, placeholder *TextBlockObject, actionID string, optGroups ...*OptionGroupBlockObject, ) *SelectBlockElement { return &SelectBlockElement{ Type: optType, Placeholder: placeholder, ActionID: actionID, OptionGroups: optGroups, } }
go
func NewOptionsGroupSelectBlockElement( optType string, placeholder *TextBlockObject, actionID string, optGroups ...*OptionGroupBlockObject, ) *SelectBlockElement { return &SelectBlockElement{ Type: optType, Placeholder: placeholder, ActionID: actionID, OptionGroups: optGroups, } }
[ "func", "NewOptionsGroupSelectBlockElement", "(", "optType", "string", ",", "placeholder", "*", "TextBlockObject", ",", "actionID", "string", ",", "optGroups", "...", "*", "OptionGroupBlockObject", ",", ")", "*", "SelectBlockElement", "{", "return", "&", "SelectBlockElement", "{", "Type", ":", "optType", ",", "Placeholder", ":", "placeholder", ",", "ActionID", ":", "actionID", ",", "OptionGroups", ":", "optGroups", ",", "}", "\n", "}" ]
// NewOptionsGroupSelectBlockElement returns a new instance of SelectBlockElement for use with // the Options object only.
[ "NewOptionsGroupSelectBlockElement", "returns", "a", "new", "instance", "of", "SelectBlockElement", "for", "use", "with", "the", "Options", "object", "only", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block_element.go#L96-L108
train
nlopes/slack
block_element.go
NewOverflowBlockElement
func NewOverflowBlockElement(actionID string, options ...*OptionBlockObject) *OverflowBlockElement { return &OverflowBlockElement{ Type: metOverflow, ActionID: actionID, Options: options, } }
go
func NewOverflowBlockElement(actionID string, options ...*OptionBlockObject) *OverflowBlockElement { return &OverflowBlockElement{ Type: metOverflow, ActionID: actionID, Options: options, } }
[ "func", "NewOverflowBlockElement", "(", "actionID", "string", ",", "options", "...", "*", "OptionBlockObject", ")", "*", "OverflowBlockElement", "{", "return", "&", "OverflowBlockElement", "{", "Type", ":", "metOverflow", ",", "ActionID", ":", "actionID", ",", "Options", ":", "options", ",", "}", "\n", "}" ]
// NewOverflowBlockElement returns an instance of a new Overflow Block Element
[ "NewOverflowBlockElement", "returns", "an", "instance", "of", "a", "new", "Overflow", "Block", "Element" ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block_element.go#L129-L135
train
nlopes/slack
rtm.go
RTMOptionDialer
func RTMOptionDialer(d *websocket.Dialer) RTMOption { return func(rtm *RTM) { rtm.dialer = d } }
go
func RTMOptionDialer(d *websocket.Dialer) RTMOption { return func(rtm *RTM) { rtm.dialer = d } }
[ "func", "RTMOptionDialer", "(", "d", "*", "websocket", ".", "Dialer", ")", "RTMOption", "{", "return", "func", "(", "rtm", "*", "RTM", ")", "{", "rtm", ".", "dialer", "=", "d", "\n", "}", "\n", "}" ]
// RTMOptionDialer takes a gorilla websocket Dialer and uses it as the // Dialer when opening the websocket for the RTM connection.
[ "RTMOptionDialer", "takes", "a", "gorilla", "websocket", "Dialer", "and", "uses", "it", "as", "the", "Dialer", "when", "opening", "the", "websocket", "for", "the", "RTM", "connection", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/rtm.go#L89-L93
train
nlopes/slack
rtm.go
RTMOptionPingInterval
func RTMOptionPingInterval(d time.Duration) RTMOption { return func(rtm *RTM) { rtm.pingInterval = d rtm.resetDeadman() } }
go
func RTMOptionPingInterval(d time.Duration) RTMOption { return func(rtm *RTM) { rtm.pingInterval = d rtm.resetDeadman() } }
[ "func", "RTMOptionPingInterval", "(", "d", "time", ".", "Duration", ")", "RTMOption", "{", "return", "func", "(", "rtm", "*", "RTM", ")", "{", "rtm", ".", "pingInterval", "=", "d", "\n", "rtm", ".", "resetDeadman", "(", ")", "\n", "}", "\n", "}" ]
// RTMOptionPingInterval determines how often to deliver a ping message to slack.
[ "RTMOptionPingInterval", "determines", "how", "often", "to", "deliver", "a", "ping", "message", "to", "slack", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/rtm.go#L96-L101
train
nlopes/slack
rtm.go
RTMOptionConnParams
func RTMOptionConnParams(connParams url.Values) RTMOption { return func(rtm *RTM) { rtm.connParams = connParams } }
go
func RTMOptionConnParams(connParams url.Values) RTMOption { return func(rtm *RTM) { rtm.connParams = connParams } }
[ "func", "RTMOptionConnParams", "(", "connParams", "url", ".", "Values", ")", "RTMOption", "{", "return", "func", "(", "rtm", "*", "RTM", ")", "{", "rtm", ".", "connParams", "=", "connParams", "\n", "}", "\n", "}" ]
// RTMOptionConnParams installs parameters to embed into the connection URL.
[ "RTMOptionConnParams", "installs", "parameters", "to", "embed", "into", "the", "connection", "URL", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/rtm.go#L104-L108
train
nlopes/slack
rtm.go
NewRTM
func (api *Client) NewRTM(options ...RTMOption) *RTM { result := &RTM{ Client: *api, IncomingEvents: make(chan RTMEvent, 50), outgoingMessages: make(chan OutgoingMessage, 20), pingInterval: defaultPingInterval, pingDeadman: time.NewTimer(deadmanDuration(defaultPingInterval)), killChannel: make(chan bool), disconnected: make(chan struct{}), disconnectedm: &sync.Once{}, forcePing: make(chan bool), rawEvents: make(chan json.RawMessage), idGen: NewSafeID(1), mu: &sync.Mutex{}, } for _, opt := range options { opt(result) } return result }
go
func (api *Client) NewRTM(options ...RTMOption) *RTM { result := &RTM{ Client: *api, IncomingEvents: make(chan RTMEvent, 50), outgoingMessages: make(chan OutgoingMessage, 20), pingInterval: defaultPingInterval, pingDeadman: time.NewTimer(deadmanDuration(defaultPingInterval)), killChannel: make(chan bool), disconnected: make(chan struct{}), disconnectedm: &sync.Once{}, forcePing: make(chan bool), rawEvents: make(chan json.RawMessage), idGen: NewSafeID(1), mu: &sync.Mutex{}, } for _, opt := range options { opt(result) } return result }
[ "func", "(", "api", "*", "Client", ")", "NewRTM", "(", "options", "...", "RTMOption", ")", "*", "RTM", "{", "result", ":=", "&", "RTM", "{", "Client", ":", "*", "api", ",", "IncomingEvents", ":", "make", "(", "chan", "RTMEvent", ",", "50", ")", ",", "outgoingMessages", ":", "make", "(", "chan", "OutgoingMessage", ",", "20", ")", ",", "pingInterval", ":", "defaultPingInterval", ",", "pingDeadman", ":", "time", ".", "NewTimer", "(", "deadmanDuration", "(", "defaultPingInterval", ")", ")", ",", "killChannel", ":", "make", "(", "chan", "bool", ")", ",", "disconnected", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "disconnectedm", ":", "&", "sync", ".", "Once", "{", "}", ",", "forcePing", ":", "make", "(", "chan", "bool", ")", ",", "rawEvents", ":", "make", "(", "chan", "json", ".", "RawMessage", ")", ",", "idGen", ":", "NewSafeID", "(", "1", ")", ",", "mu", ":", "&", "sync", ".", "Mutex", "{", "}", ",", "}", "\n\n", "for", "_", ",", "opt", ":=", "range", "options", "{", "opt", "(", "result", ")", "\n", "}", "\n\n", "return", "result", "\n", "}" ]
// NewRTM returns a RTM, which provides a fully managed connection to // Slack's websocket-based Real-Time Messaging protocol.
[ "NewRTM", "returns", "a", "RTM", "which", "provides", "a", "fully", "managed", "connection", "to", "Slack", "s", "websocket", "-", "based", "Real", "-", "Time", "Messaging", "protocol", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/rtm.go#L112-L133
train
nlopes/slack
reactions.go
NewListReactionsParameters
func NewListReactionsParameters() ListReactionsParameters { return ListReactionsParameters{ User: DEFAULT_REACTIONS_USER, Count: DEFAULT_REACTIONS_COUNT, Page: DEFAULT_REACTIONS_PAGE, Full: DEFAULT_REACTIONS_FULL, } }
go
func NewListReactionsParameters() ListReactionsParameters { return ListReactionsParameters{ User: DEFAULT_REACTIONS_USER, Count: DEFAULT_REACTIONS_COUNT, Page: DEFAULT_REACTIONS_PAGE, Full: DEFAULT_REACTIONS_FULL, } }
[ "func", "NewListReactionsParameters", "(", ")", "ListReactionsParameters", "{", "return", "ListReactionsParameters", "{", "User", ":", "DEFAULT_REACTIONS_USER", ",", "Count", ":", "DEFAULT_REACTIONS_COUNT", ",", "Page", ":", "DEFAULT_REACTIONS_PAGE", ",", "Full", ":", "DEFAULT_REACTIONS_FULL", ",", "}", "\n", "}" ]
// NewListReactionsParameters initializes the inputs to find all reactions // performed by a user.
[ "NewListReactionsParameters", "initializes", "the", "inputs", "to", "find", "all", "reactions", "performed", "by", "a", "user", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/reactions.go#L78-L85
train
nlopes/slack
reactions.go
AddReaction
func (api *Client) AddReaction(name string, item ItemRef) error { return api.AddReactionContext(context.Background(), name, item) }
go
func (api *Client) AddReaction(name string, item ItemRef) error { return api.AddReactionContext(context.Background(), name, item) }
[ "func", "(", "api", "*", "Client", ")", "AddReaction", "(", "name", "string", ",", "item", "ItemRef", ")", "error", "{", "return", "api", ".", "AddReactionContext", "(", "context", ".", "Background", "(", ")", ",", "name", ",", "item", ")", "\n", "}" ]
// AddReaction adds a reaction emoji to a message, file or file comment.
[ "AddReaction", "adds", "a", "reaction", "emoji", "to", "a", "message", "file", "or", "file", "comment", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/reactions.go#L131-L133
train
nlopes/slack
reactions.go
RemoveReaction
func (api *Client) RemoveReaction(name string, item ItemRef) error { return api.RemoveReactionContext(context.Background(), name, item) }
go
func (api *Client) RemoveReaction(name string, item ItemRef) error { return api.RemoveReactionContext(context.Background(), name, item) }
[ "func", "(", "api", "*", "Client", ")", "RemoveReaction", "(", "name", "string", ",", "item", "ItemRef", ")", "error", "{", "return", "api", ".", "RemoveReactionContext", "(", "context", ".", "Background", "(", ")", ",", "name", ",", "item", ")", "\n", "}" ]
// RemoveReaction removes a reaction emoji from a message, file or file comment.
[ "RemoveReaction", "removes", "a", "reaction", "emoji", "from", "a", "message", "file", "or", "file", "comment", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/reactions.go#L165-L167
train
nlopes/slack
reactions.go
GetReactions
func (api *Client) GetReactions(item ItemRef, params GetReactionsParameters) ([]ItemReaction, error) { return api.GetReactionsContext(context.Background(), item, params) }
go
func (api *Client) GetReactions(item ItemRef, params GetReactionsParameters) ([]ItemReaction, error) { return api.GetReactionsContext(context.Background(), item, params) }
[ "func", "(", "api", "*", "Client", ")", "GetReactions", "(", "item", "ItemRef", ",", "params", "GetReactionsParameters", ")", "(", "[", "]", "ItemReaction", ",", "error", ")", "{", "return", "api", ".", "GetReactionsContext", "(", "context", ".", "Background", "(", ")", ",", "item", ",", "params", ")", "\n", "}" ]
// GetReactions returns details about the reactions on an item.
[ "GetReactions", "returns", "details", "about", "the", "reactions", "on", "an", "item", "." ]
65ea2b979a7ffe628676bdb6b924e2498d66c1bf
https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/reactions.go#L199-L201
train