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 |
---|---|---|---|---|---|---|---|---|---|---|---|
nlopes/slack | reactions.go | GetReactionsContext | func (api *Client) GetReactionsContext(ctx context.Context, item ItemRef, params GetReactionsParameters) ([]ItemReaction, error) {
values := url.Values{
"token": {api.token},
}
if item.Channel != "" {
values.Set("channel", item.Channel)
}
if item.Timestamp != "" {
values.Set("timestamp", item.Timestamp)
}
if item.File != "" {
values.Set("file", item.File)
}
if item.Comment != "" {
values.Set("file_comment", item.Comment)
}
if params.Full != DEFAULT_REACTIONS_FULL {
values.Set("full", strconv.FormatBool(params.Full))
}
response := &getReactionsResponseFull{}
if err := api.postMethod(ctx, "reactions.get", values, response); err != nil {
return nil, err
}
if err := response.Err(); err != nil {
return nil, err
}
return response.extractReactions(), nil
} | go | func (api *Client) GetReactionsContext(ctx context.Context, item ItemRef, params GetReactionsParameters) ([]ItemReaction, error) {
values := url.Values{
"token": {api.token},
}
if item.Channel != "" {
values.Set("channel", item.Channel)
}
if item.Timestamp != "" {
values.Set("timestamp", item.Timestamp)
}
if item.File != "" {
values.Set("file", item.File)
}
if item.Comment != "" {
values.Set("file_comment", item.Comment)
}
if params.Full != DEFAULT_REACTIONS_FULL {
values.Set("full", strconv.FormatBool(params.Full))
}
response := &getReactionsResponseFull{}
if err := api.postMethod(ctx, "reactions.get", values, response); err != nil {
return nil, err
}
if err := response.Err(); err != nil {
return nil, err
}
return response.extractReactions(), nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetReactionsContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"item",
"ItemRef",
",",
"params",
"GetReactionsParameters",
")",
"(",
"[",
"]",
"ItemReaction",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"}",
"\n",
"if",
"item",
".",
"Channel",
"!=",
"\"",
"\"",
"{",
"values",
".",
"Set",
"(",
"\"",
"\"",
",",
"item",
".",
"Channel",
")",
"\n",
"}",
"\n",
"if",
"item",
".",
"Timestamp",
"!=",
"\"",
"\"",
"{",
"values",
".",
"Set",
"(",
"\"",
"\"",
",",
"item",
".",
"Timestamp",
")",
"\n",
"}",
"\n",
"if",
"item",
".",
"File",
"!=",
"\"",
"\"",
"{",
"values",
".",
"Set",
"(",
"\"",
"\"",
",",
"item",
".",
"File",
")",
"\n",
"}",
"\n",
"if",
"item",
".",
"Comment",
"!=",
"\"",
"\"",
"{",
"values",
".",
"Set",
"(",
"\"",
"\"",
",",
"item",
".",
"Comment",
")",
"\n",
"}",
"\n",
"if",
"params",
".",
"Full",
"!=",
"DEFAULT_REACTIONS_FULL",
"{",
"values",
".",
"Set",
"(",
"\"",
"\"",
",",
"strconv",
".",
"FormatBool",
"(",
"params",
".",
"Full",
")",
")",
"\n",
"}",
"\n\n",
"response",
":=",
"&",
"getReactionsResponseFull",
"{",
"}",
"\n",
"if",
"err",
":=",
"api",
".",
"postMethod",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
",",
"response",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"response",
".",
"Err",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"response",
".",
"extractReactions",
"(",
")",
",",
"nil",
"\n",
"}"
] | // GetReactionsContext returns details about the reactions on an item with a custom context | [
"GetReactionsContext",
"returns",
"details",
"about",
"the",
"reactions",
"on",
"an",
"item",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/reactions.go#L204-L234 | train |
nlopes/slack | reactions.go | ListReactions | func (api *Client) ListReactions(params ListReactionsParameters) ([]ReactedItem, *Paging, error) {
return api.ListReactionsContext(context.Background(), params)
} | go | func (api *Client) ListReactions(params ListReactionsParameters) ([]ReactedItem, *Paging, error) {
return api.ListReactionsContext(context.Background(), params)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"ListReactions",
"(",
"params",
"ListReactionsParameters",
")",
"(",
"[",
"]",
"ReactedItem",
",",
"*",
"Paging",
",",
"error",
")",
"{",
"return",
"api",
".",
"ListReactionsContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"params",
")",
"\n",
"}"
] | // ListReactions returns information about the items a user reacted to. | [
"ListReactions",
"returns",
"information",
"about",
"the",
"items",
"a",
"user",
"reacted",
"to",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/reactions.go#L237-L239 | train |
nlopes/slack | reactions.go | ListReactionsContext | func (api *Client) ListReactionsContext(ctx context.Context, params ListReactionsParameters) ([]ReactedItem, *Paging, error) {
values := url.Values{
"token": {api.token},
}
if params.User != DEFAULT_REACTIONS_USER {
values.Add("user", params.User)
}
if params.Count != DEFAULT_REACTIONS_COUNT {
values.Add("count", strconv.Itoa(params.Count))
}
if params.Page != DEFAULT_REACTIONS_PAGE {
values.Add("page", strconv.Itoa(params.Page))
}
if params.Full != DEFAULT_REACTIONS_FULL {
values.Add("full", strconv.FormatBool(params.Full))
}
response := &listReactionsResponseFull{}
err := api.postMethod(ctx, "reactions.list", values, response)
if err != nil {
return nil, nil, err
}
if err := response.Err(); err != nil {
return nil, nil, err
}
return response.extractReactedItems(), &response.Paging, nil
} | go | func (api *Client) ListReactionsContext(ctx context.Context, params ListReactionsParameters) ([]ReactedItem, *Paging, error) {
values := url.Values{
"token": {api.token},
}
if params.User != DEFAULT_REACTIONS_USER {
values.Add("user", params.User)
}
if params.Count != DEFAULT_REACTIONS_COUNT {
values.Add("count", strconv.Itoa(params.Count))
}
if params.Page != DEFAULT_REACTIONS_PAGE {
values.Add("page", strconv.Itoa(params.Page))
}
if params.Full != DEFAULT_REACTIONS_FULL {
values.Add("full", strconv.FormatBool(params.Full))
}
response := &listReactionsResponseFull{}
err := api.postMethod(ctx, "reactions.list", values, response)
if err != nil {
return nil, nil, err
}
if err := response.Err(); err != nil {
return nil, nil, err
}
return response.extractReactedItems(), &response.Paging, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"ListReactionsContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"ListReactionsParameters",
")",
"(",
"[",
"]",
"ReactedItem",
",",
"*",
"Paging",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"}",
"\n",
"if",
"params",
".",
"User",
"!=",
"DEFAULT_REACTIONS_USER",
"{",
"values",
".",
"Add",
"(",
"\"",
"\"",
",",
"params",
".",
"User",
")",
"\n",
"}",
"\n",
"if",
"params",
".",
"Count",
"!=",
"DEFAULT_REACTIONS_COUNT",
"{",
"values",
".",
"Add",
"(",
"\"",
"\"",
",",
"strconv",
".",
"Itoa",
"(",
"params",
".",
"Count",
")",
")",
"\n",
"}",
"\n",
"if",
"params",
".",
"Page",
"!=",
"DEFAULT_REACTIONS_PAGE",
"{",
"values",
".",
"Add",
"(",
"\"",
"\"",
",",
"strconv",
".",
"Itoa",
"(",
"params",
".",
"Page",
")",
")",
"\n",
"}",
"\n",
"if",
"params",
".",
"Full",
"!=",
"DEFAULT_REACTIONS_FULL",
"{",
"values",
".",
"Add",
"(",
"\"",
"\"",
",",
"strconv",
".",
"FormatBool",
"(",
"params",
".",
"Full",
")",
")",
"\n",
"}",
"\n\n",
"response",
":=",
"&",
"listReactionsResponseFull",
"{",
"}",
"\n",
"err",
":=",
"api",
".",
"postMethod",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
",",
"response",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"response",
".",
"Err",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"response",
".",
"extractReactedItems",
"(",
")",
",",
"&",
"response",
".",
"Paging",
",",
"nil",
"\n",
"}"
] | // ListReactionsContext returns information about the items a user reacted to with a custom context. | [
"ListReactionsContext",
"returns",
"information",
"about",
"the",
"items",
"a",
"user",
"reacted",
"to",
"with",
"a",
"custom",
"context",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/reactions.go#L242-L270 | train |
nlopes/slack | logger.go | Printf | func (t internalLog) Printf(format string, v ...interface{}) {
t.Output(2, fmt.Sprintf(format, v...))
} | go | func (t internalLog) Printf(format string, v ...interface{}) {
t.Output(2, fmt.Sprintf(format, v...))
} | [
"func",
"(",
"t",
"internalLog",
")",
"Printf",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"t",
".",
"Output",
"(",
"2",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"v",
"...",
")",
")",
"\n",
"}"
] | // Printf replicates the behaviour of the standard logger. | [
"Printf",
"replicates",
"the",
"behaviour",
"of",
"the",
"standard",
"logger",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/logger.go#L41-L43 | train |
nlopes/slack | info.go | String | func (t JSONTime) String() string {
tm := t.Time()
return fmt.Sprintf("\"%s\"", tm.Format("Mon Jan _2"))
} | go | func (t JSONTime) String() string {
tm := t.Time()
return fmt.Sprintf("\"%s\"", tm.Format("Mon Jan _2"))
} | [
"func",
"(",
"t",
"JSONTime",
")",
"String",
"(",
")",
"string",
"{",
"tm",
":=",
"t",
".",
"Time",
"(",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"tm",
".",
"Format",
"(",
"\"",
"\"",
")",
")",
"\n",
"}"
] | // String converts the unix timestamp into a string | [
"String",
"converts",
"the",
"unix",
"timestamp",
"into",
"a",
"string"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/info.go#L122-L125 | train |
nlopes/slack | info.go | UnmarshalJSON | func (t *JSONTime) UnmarshalJSON(buf []byte) error {
s := bytes.Trim(buf, `"`)
v, err := strconv.Atoi(string(s))
if err != nil {
return err
}
*t = JSONTime(int64(v))
return nil
} | go | func (t *JSONTime) UnmarshalJSON(buf []byte) error {
s := bytes.Trim(buf, `"`)
v, err := strconv.Atoi(string(s))
if err != nil {
return err
}
*t = JSONTime(int64(v))
return nil
} | [
"func",
"(",
"t",
"*",
"JSONTime",
")",
"UnmarshalJSON",
"(",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"s",
":=",
"bytes",
".",
"Trim",
"(",
"buf",
",",
"`\"`",
")",
"\n\n",
"v",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"string",
"(",
"s",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"t",
"=",
"JSONTime",
"(",
"int64",
"(",
"v",
")",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalJSON will unmarshal both string and int JSON values | [
"UnmarshalJSON",
"will",
"unmarshal",
"both",
"string",
"and",
"int",
"JSON",
"values"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/info.go#L133-L143 | train |
nlopes/slack | info.go | GetBotByID | func (info Info) GetBotByID(botID string) *Bot {
for _, bot := range info.Bots {
if bot.ID == botID {
return &bot
}
}
return nil
} | go | func (info Info) GetBotByID(botID string) *Bot {
for _, bot := range info.Bots {
if bot.ID == botID {
return &bot
}
}
return nil
} | [
"func",
"(",
"info",
"Info",
")",
"GetBotByID",
"(",
"botID",
"string",
")",
"*",
"Bot",
"{",
"for",
"_",
",",
"bot",
":=",
"range",
"info",
".",
"Bots",
"{",
"if",
"bot",
".",
"ID",
"==",
"botID",
"{",
"return",
"&",
"bot",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // GetBotByID returns a bot given a bot id | [
"GetBotByID",
"returns",
"a",
"bot",
"given",
"a",
"bot",
"id"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/info.go#L178-L185 | train |
nlopes/slack | info.go | GetUserByID | func (info Info) GetUserByID(userID string) *User {
for _, user := range info.Users {
if user.ID == userID {
return &user
}
}
return nil
} | go | func (info Info) GetUserByID(userID string) *User {
for _, user := range info.Users {
if user.ID == userID {
return &user
}
}
return nil
} | [
"func",
"(",
"info",
"Info",
")",
"GetUserByID",
"(",
"userID",
"string",
")",
"*",
"User",
"{",
"for",
"_",
",",
"user",
":=",
"range",
"info",
".",
"Users",
"{",
"if",
"user",
".",
"ID",
"==",
"userID",
"{",
"return",
"&",
"user",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // GetUserByID returns a user given a user id | [
"GetUserByID",
"returns",
"a",
"user",
"given",
"a",
"user",
"id"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/info.go#L188-L195 | train |
nlopes/slack | info.go | GetChannelByID | func (info Info) GetChannelByID(channelID string) *Channel {
for _, channel := range info.Channels {
if channel.ID == channelID {
return &channel
}
}
return nil
} | go | func (info Info) GetChannelByID(channelID string) *Channel {
for _, channel := range info.Channels {
if channel.ID == channelID {
return &channel
}
}
return nil
} | [
"func",
"(",
"info",
"Info",
")",
"GetChannelByID",
"(",
"channelID",
"string",
")",
"*",
"Channel",
"{",
"for",
"_",
",",
"channel",
":=",
"range",
"info",
".",
"Channels",
"{",
"if",
"channel",
".",
"ID",
"==",
"channelID",
"{",
"return",
"&",
"channel",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // GetChannelByID returns a channel given a channel id | [
"GetChannelByID",
"returns",
"a",
"channel",
"given",
"a",
"channel",
"id"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/info.go#L198-L205 | train |
nlopes/slack | info.go | GetGroupByID | func (info Info) GetGroupByID(groupID string) *Group {
for _, group := range info.Groups {
if group.ID == groupID {
return &group
}
}
return nil
} | go | func (info Info) GetGroupByID(groupID string) *Group {
for _, group := range info.Groups {
if group.ID == groupID {
return &group
}
}
return nil
} | [
"func",
"(",
"info",
"Info",
")",
"GetGroupByID",
"(",
"groupID",
"string",
")",
"*",
"Group",
"{",
"for",
"_",
",",
"group",
":=",
"range",
"info",
".",
"Groups",
"{",
"if",
"group",
".",
"ID",
"==",
"groupID",
"{",
"return",
"&",
"group",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // GetGroupByID returns a group given a group id | [
"GetGroupByID",
"returns",
"a",
"group",
"given",
"a",
"group",
"id"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/info.go#L208-L215 | train |
nlopes/slack | info.go | GetIMByID | func (info Info) GetIMByID(imID string) *IM {
for _, im := range info.IMs {
if im.ID == imID {
return &im
}
}
return nil
} | go | func (info Info) GetIMByID(imID string) *IM {
for _, im := range info.IMs {
if im.ID == imID {
return &im
}
}
return nil
} | [
"func",
"(",
"info",
"Info",
")",
"GetIMByID",
"(",
"imID",
"string",
")",
"*",
"IM",
"{",
"for",
"_",
",",
"im",
":=",
"range",
"info",
".",
"IMs",
"{",
"if",
"im",
".",
"ID",
"==",
"imID",
"{",
"return",
"&",
"im",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // GetIMByID returns an IM given an IM id | [
"GetIMByID",
"returns",
"an",
"IM",
"given",
"an",
"IM",
"id"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/info.go#L218-L225 | train |
nlopes/slack | slackevents/inner_events.go | IsEdited | func (e MessageEvent) IsEdited() bool {
return e.Message != nil &&
e.Message.Edited != nil
} | go | func (e MessageEvent) IsEdited() bool {
return e.Message != nil &&
e.Message.Edited != nil
} | [
"func",
"(",
"e",
"MessageEvent",
")",
"IsEdited",
"(",
")",
"bool",
"{",
"return",
"e",
".",
"Message",
"!=",
"nil",
"&&",
"e",
".",
"Message",
".",
"Edited",
"!=",
"nil",
"\n",
"}"
] | // IsEdited checks if the MessageEvent is caused by an edit | [
"IsEdited",
"checks",
"if",
"the",
"MessageEvent",
"is",
"caused",
"by",
"an",
"edit"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/slackevents/inner_events.go#L212-L215 | train |
nlopes/slack | block_section.go | NewSectionBlock | func NewSectionBlock(textObj *TextBlockObject, fields []*TextBlockObject, accessory BlockElement) *SectionBlock {
return &SectionBlock{
Type: mbtSection,
Text: textObj,
Fields: fields,
Accessory: accessory,
}
} | go | func NewSectionBlock(textObj *TextBlockObject, fields []*TextBlockObject, accessory BlockElement) *SectionBlock {
return &SectionBlock{
Type: mbtSection,
Text: textObj,
Fields: fields,
Accessory: accessory,
}
} | [
"func",
"NewSectionBlock",
"(",
"textObj",
"*",
"TextBlockObject",
",",
"fields",
"[",
"]",
"*",
"TextBlockObject",
",",
"accessory",
"BlockElement",
")",
"*",
"SectionBlock",
"{",
"return",
"&",
"SectionBlock",
"{",
"Type",
":",
"mbtSection",
",",
"Text",
":",
"textObj",
",",
"Fields",
":",
"fields",
",",
"Accessory",
":",
"accessory",
",",
"}",
"\n",
"}"
] | // NewSectionBlock returns a new instance of a section block to be rendered | [
"NewSectionBlock",
"returns",
"a",
"new",
"instance",
"of",
"a",
"section",
"block",
"to",
"be",
"rendered"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block_section.go#L20-L27 | train |
nlopes/slack | stars.go | AddStar | func (api *Client) AddStar(channel string, item ItemRef) error {
return api.AddStarContext(context.Background(), channel, item)
} | go | func (api *Client) AddStar(channel string, item ItemRef) error {
return api.AddStarContext(context.Background(), channel, item)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"AddStar",
"(",
"channel",
"string",
",",
"item",
"ItemRef",
")",
"error",
"{",
"return",
"api",
".",
"AddStarContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"channel",
",",
"item",
")",
"\n",
"}"
] | // AddStar stars an item in a channel | [
"AddStar",
"stars",
"an",
"item",
"in",
"a",
"channel"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/stars.go#L39-L41 | train |
nlopes/slack | stars.go | RemoveStar | func (api *Client) RemoveStar(channel string, item ItemRef) error {
return api.RemoveStarContext(context.Background(), channel, item)
} | go | func (api *Client) RemoveStar(channel string, item ItemRef) error {
return api.RemoveStarContext(context.Background(), channel, item)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"RemoveStar",
"(",
"channel",
"string",
",",
"item",
"ItemRef",
")",
"error",
"{",
"return",
"api",
".",
"RemoveStarContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"channel",
",",
"item",
")",
"\n",
"}"
] | // RemoveStar removes a starred item from a channel | [
"RemoveStar",
"removes",
"a",
"starred",
"item",
"from",
"a",
"channel"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/stars.go#L68-L70 | train |
nlopes/slack | stars.go | ListStars | func (api *Client) ListStars(params StarsParameters) ([]Item, *Paging, error) {
return api.ListStarsContext(context.Background(), params)
} | go | func (api *Client) ListStars(params StarsParameters) ([]Item, *Paging, error) {
return api.ListStarsContext(context.Background(), params)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"ListStars",
"(",
"params",
"StarsParameters",
")",
"(",
"[",
"]",
"Item",
",",
"*",
"Paging",
",",
"error",
")",
"{",
"return",
"api",
".",
"ListStarsContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"params",
")",
"\n",
"}"
] | // ListStars returns information about the stars a user added | [
"ListStars",
"returns",
"information",
"about",
"the",
"stars",
"a",
"user",
"added"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/stars.go#L97-L99 | train |
nlopes/slack | stars.go | ListStarsContext | func (api *Client) ListStarsContext(ctx context.Context, params StarsParameters) ([]Item, *Paging, error) {
values := url.Values{
"token": {api.token},
}
if params.User != DEFAULT_STARS_USER {
values.Add("user", params.User)
}
if params.Count != DEFAULT_STARS_COUNT {
values.Add("count", strconv.Itoa(params.Count))
}
if params.Page != DEFAULT_STARS_PAGE {
values.Add("page", strconv.Itoa(params.Page))
}
response := &listResponseFull{}
err := api.postMethod(ctx, "stars.list", values, response)
if err != nil {
return nil, nil, err
}
if err := response.Err(); err != nil {
return nil, nil, err
}
return response.Items, &response.Paging, nil
} | go | func (api *Client) ListStarsContext(ctx context.Context, params StarsParameters) ([]Item, *Paging, error) {
values := url.Values{
"token": {api.token},
}
if params.User != DEFAULT_STARS_USER {
values.Add("user", params.User)
}
if params.Count != DEFAULT_STARS_COUNT {
values.Add("count", strconv.Itoa(params.Count))
}
if params.Page != DEFAULT_STARS_PAGE {
values.Add("page", strconv.Itoa(params.Page))
}
response := &listResponseFull{}
err := api.postMethod(ctx, "stars.list", values, response)
if err != nil {
return nil, nil, err
}
if err := response.Err(); err != nil {
return nil, nil, err
}
return response.Items, &response.Paging, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"ListStarsContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"StarsParameters",
")",
"(",
"[",
"]",
"Item",
",",
"*",
"Paging",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"}",
"\n",
"if",
"params",
".",
"User",
"!=",
"DEFAULT_STARS_USER",
"{",
"values",
".",
"Add",
"(",
"\"",
"\"",
",",
"params",
".",
"User",
")",
"\n",
"}",
"\n",
"if",
"params",
".",
"Count",
"!=",
"DEFAULT_STARS_COUNT",
"{",
"values",
".",
"Add",
"(",
"\"",
"\"",
",",
"strconv",
".",
"Itoa",
"(",
"params",
".",
"Count",
")",
")",
"\n",
"}",
"\n",
"if",
"params",
".",
"Page",
"!=",
"DEFAULT_STARS_PAGE",
"{",
"values",
".",
"Add",
"(",
"\"",
"\"",
",",
"strconv",
".",
"Itoa",
"(",
"params",
".",
"Page",
")",
")",
"\n",
"}",
"\n\n",
"response",
":=",
"&",
"listResponseFull",
"{",
"}",
"\n",
"err",
":=",
"api",
".",
"postMethod",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
",",
"response",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"response",
".",
"Err",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"response",
".",
"Items",
",",
"&",
"response",
".",
"Paging",
",",
"nil",
"\n",
"}"
] | // ListStarsContext returns information about the stars a user added with a custom context | [
"ListStarsContext",
"returns",
"information",
"about",
"the",
"stars",
"a",
"user",
"added",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/stars.go#L102-L127 | train |
nlopes/slack | stars.go | GetStarredContext | func (api *Client) GetStarredContext(ctx context.Context, params StarsParameters) ([]StarredItem, *Paging, error) {
items, paging, err := api.ListStarsContext(ctx, params)
if err != nil {
return nil, nil, err
}
starredItems := make([]StarredItem, len(items))
for i, item := range items {
starredItems[i] = StarredItem(item)
}
return starredItems, paging, nil
} | go | func (api *Client) GetStarredContext(ctx context.Context, params StarsParameters) ([]StarredItem, *Paging, error) {
items, paging, err := api.ListStarsContext(ctx, params)
if err != nil {
return nil, nil, err
}
starredItems := make([]StarredItem, len(items))
for i, item := range items {
starredItems[i] = StarredItem(item)
}
return starredItems, paging, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetStarredContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"StarsParameters",
")",
"(",
"[",
"]",
"StarredItem",
",",
"*",
"Paging",
",",
"error",
")",
"{",
"items",
",",
"paging",
",",
"err",
":=",
"api",
".",
"ListStarsContext",
"(",
"ctx",
",",
"params",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"starredItems",
":=",
"make",
"(",
"[",
"]",
"StarredItem",
",",
"len",
"(",
"items",
")",
")",
"\n",
"for",
"i",
",",
"item",
":=",
"range",
"items",
"{",
"starredItems",
"[",
"i",
"]",
"=",
"StarredItem",
"(",
"item",
")",
"\n",
"}",
"\n",
"return",
"starredItems",
",",
"paging",
",",
"nil",
"\n",
"}"
] | // GetStarredContext returns a list of StarredItem items with a custom context
//
// For more details see GetStarred | [
"GetStarredContext",
"returns",
"a",
"list",
"of",
"StarredItem",
"items",
"with",
"a",
"custom",
"context",
"For",
"more",
"details",
"see",
"GetStarred"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/stars.go#L150-L160 | train |
nlopes/slack | block_action.go | NewActionBlock | func NewActionBlock(blockID string, elements ...BlockElement) *ActionBlock {
return &ActionBlock{
Type: mbtAction,
BlockID: blockID,
Elements: elements,
}
} | go | func NewActionBlock(blockID string, elements ...BlockElement) *ActionBlock {
return &ActionBlock{
Type: mbtAction,
BlockID: blockID,
Elements: elements,
}
} | [
"func",
"NewActionBlock",
"(",
"blockID",
"string",
",",
"elements",
"...",
"BlockElement",
")",
"*",
"ActionBlock",
"{",
"return",
"&",
"ActionBlock",
"{",
"Type",
":",
"mbtAction",
",",
"BlockID",
":",
"blockID",
",",
"Elements",
":",
"elements",
",",
"}",
"\n",
"}"
] | // NewActionBlock returns a new instance of an Action Block | [
"NewActionBlock",
"returns",
"a",
"new",
"instance",
"of",
"an",
"Action",
"Block"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block_action.go#L18-L24 | train |
nlopes/slack | block_image.go | NewImageBlock | func NewImageBlock(imageURL, altText, blockID string, title *TextBlockObject) *ImageBlock {
return &ImageBlock{
Type: mbtImage,
ImageURL: imageURL,
AltText: altText,
BlockID: blockID,
Title: title,
}
} | go | func NewImageBlock(imageURL, altText, blockID string, title *TextBlockObject) *ImageBlock {
return &ImageBlock{
Type: mbtImage,
ImageURL: imageURL,
AltText: altText,
BlockID: blockID,
Title: title,
}
} | [
"func",
"NewImageBlock",
"(",
"imageURL",
",",
"altText",
",",
"blockID",
"string",
",",
"title",
"*",
"TextBlockObject",
")",
"*",
"ImageBlock",
"{",
"return",
"&",
"ImageBlock",
"{",
"Type",
":",
"mbtImage",
",",
"ImageURL",
":",
"imageURL",
",",
"AltText",
":",
"altText",
",",
"BlockID",
":",
"blockID",
",",
"Title",
":",
"title",
",",
"}",
"\n",
"}"
] | // NewImageBlock returns an instance of a new Image Block type | [
"NewImageBlock",
"returns",
"an",
"instance",
"of",
"a",
"new",
"Image",
"Block",
"type"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block_image.go#L20-L28 | train |
nlopes/slack | team.go | GetTeamInfoContext | func (api *Client) GetTeamInfoContext(ctx context.Context) (*TeamInfo, error) {
values := url.Values{
"token": {api.token},
}
response, err := api.teamRequest(ctx, "team.info", values)
if err != nil {
return nil, err
}
return &response.Team, nil
} | go | func (api *Client) GetTeamInfoContext(ctx context.Context) (*TeamInfo, error) {
values := url.Values{
"token": {api.token},
}
response, err := api.teamRequest(ctx, "team.info", values)
if err != nil {
return nil, err
}
return &response.Team, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetTeamInfoContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"TeamInfo",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"teamRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"response",
".",
"Team",
",",
"nil",
"\n",
"}"
] | // GetTeamInfoContext gets the Team Information of the user with a custom context | [
"GetTeamInfoContext",
"gets",
"the",
"Team",
"Information",
"of",
"the",
"user",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/team.go#L104-L114 | train |
nlopes/slack | team.go | GetAccessLogs | func (api *Client) GetAccessLogs(params AccessLogParameters) ([]Login, *Paging, error) {
return api.GetAccessLogsContext(context.Background(), params)
} | go | func (api *Client) GetAccessLogs(params AccessLogParameters) ([]Login, *Paging, error) {
return api.GetAccessLogsContext(context.Background(), params)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetAccessLogs",
"(",
"params",
"AccessLogParameters",
")",
"(",
"[",
"]",
"Login",
",",
"*",
"Paging",
",",
"error",
")",
"{",
"return",
"api",
".",
"GetAccessLogsContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"params",
")",
"\n",
"}"
] | // GetAccessLogs retrieves a page of logins according to the parameters given | [
"GetAccessLogs",
"retrieves",
"a",
"page",
"of",
"logins",
"according",
"to",
"the",
"parameters",
"given"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/team.go#L117-L119 | train |
nlopes/slack | team.go | GetAccessLogsContext | func (api *Client) GetAccessLogsContext(ctx context.Context, params AccessLogParameters) ([]Login, *Paging, error) {
values := url.Values{
"token": {api.token},
}
if params.Count != DEFAULT_LOGINS_COUNT {
values.Add("count", strconv.Itoa(params.Count))
}
if params.Page != DEFAULT_LOGINS_PAGE {
values.Add("page", strconv.Itoa(params.Page))
}
response, err := api.accessLogsRequest(ctx, "team.accessLogs", values)
if err != nil {
return nil, nil, err
}
return response.Logins, &response.Paging, nil
} | go | func (api *Client) GetAccessLogsContext(ctx context.Context, params AccessLogParameters) ([]Login, *Paging, error) {
values := url.Values{
"token": {api.token},
}
if params.Count != DEFAULT_LOGINS_COUNT {
values.Add("count", strconv.Itoa(params.Count))
}
if params.Page != DEFAULT_LOGINS_PAGE {
values.Add("page", strconv.Itoa(params.Page))
}
response, err := api.accessLogsRequest(ctx, "team.accessLogs", values)
if err != nil {
return nil, nil, err
}
return response.Logins, &response.Paging, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetAccessLogsContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"AccessLogParameters",
")",
"(",
"[",
"]",
"Login",
",",
"*",
"Paging",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"}",
"\n",
"if",
"params",
".",
"Count",
"!=",
"DEFAULT_LOGINS_COUNT",
"{",
"values",
".",
"Add",
"(",
"\"",
"\"",
",",
"strconv",
".",
"Itoa",
"(",
"params",
".",
"Count",
")",
")",
"\n",
"}",
"\n",
"if",
"params",
".",
"Page",
"!=",
"DEFAULT_LOGINS_PAGE",
"{",
"values",
".",
"Add",
"(",
"\"",
"\"",
",",
"strconv",
".",
"Itoa",
"(",
"params",
".",
"Page",
")",
")",
"\n",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"accessLogsRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"response",
".",
"Logins",
",",
"&",
"response",
".",
"Paging",
",",
"nil",
"\n",
"}"
] | // GetAccessLogsContext retrieves a page of logins according to the parameters given with a custom context | [
"GetAccessLogsContext",
"retrieves",
"a",
"page",
"of",
"logins",
"according",
"to",
"the",
"parameters",
"given",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/team.go#L122-L138 | train |
nlopes/slack | team.go | GetBillableInfoForTeam | func (api *Client) GetBillableInfoForTeam() (map[string]BillingActive, error) {
return api.GetBillableInfoForTeamContext(context.Background())
} | go | func (api *Client) GetBillableInfoForTeam() (map[string]BillingActive, error) {
return api.GetBillableInfoForTeamContext(context.Background())
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetBillableInfoForTeam",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"BillingActive",
",",
"error",
")",
"{",
"return",
"api",
".",
"GetBillableInfoForTeamContext",
"(",
"context",
".",
"Background",
"(",
")",
")",
"\n",
"}"
] | // GetBillableInfoForTeam returns the billing_active status of all users on the team. | [
"GetBillableInfoForTeam",
"returns",
"the",
"billing_active",
"status",
"of",
"all",
"users",
"on",
"the",
"team",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/team.go#L156-L158 | train |
nlopes/slack | internal/timex/timex.go | Max | func Max(values ...time.Duration) time.Duration {
var (
max time.Duration
)
for _, v := range values {
if v > max {
max = v
}
}
return max
} | go | func Max(values ...time.Duration) time.Duration {
var (
max time.Duration
)
for _, v := range values {
if v > max {
max = v
}
}
return max
} | [
"func",
"Max",
"(",
"values",
"...",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"var",
"(",
"max",
"time",
".",
"Duration",
"\n",
")",
"\n\n",
"for",
"_",
",",
"v",
":=",
"range",
"values",
"{",
"if",
"v",
">",
"max",
"{",
"max",
"=",
"v",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"max",
"\n",
"}"
] | // Max returns the maximum duration | [
"Max",
"returns",
"the",
"maximum",
"duration"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/internal/timex/timex.go#L6-L18 | train |
nlopes/slack | dialog_select.go | NewStaticSelectDialogInput | func NewStaticSelectDialogInput(name, label string, options []DialogSelectOption) *DialogInputSelect {
return &DialogInputSelect{
DialogInput: DialogInput{
Type: InputTypeSelect,
Name: name,
Label: label,
Optional: true,
},
DataSource: DialogDataSourceStatic,
Options: options,
}
} | go | func NewStaticSelectDialogInput(name, label string, options []DialogSelectOption) *DialogInputSelect {
return &DialogInputSelect{
DialogInput: DialogInput{
Type: InputTypeSelect,
Name: name,
Label: label,
Optional: true,
},
DataSource: DialogDataSourceStatic,
Options: options,
}
} | [
"func",
"NewStaticSelectDialogInput",
"(",
"name",
",",
"label",
"string",
",",
"options",
"[",
"]",
"DialogSelectOption",
")",
"*",
"DialogInputSelect",
"{",
"return",
"&",
"DialogInputSelect",
"{",
"DialogInput",
":",
"DialogInput",
"{",
"Type",
":",
"InputTypeSelect",
",",
"Name",
":",
"name",
",",
"Label",
":",
"label",
",",
"Optional",
":",
"true",
",",
"}",
",",
"DataSource",
":",
"DialogDataSourceStatic",
",",
"Options",
":",
"options",
",",
"}",
"\n",
"}"
] | // NewStaticSelectDialogInput constructor for a `static` datasource menu input | [
"NewStaticSelectDialogInput",
"constructor",
"for",
"a",
"static",
"datasource",
"menu",
"input"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/dialog_select.go#L44-L55 | train |
nlopes/slack | dialog_select.go | NewGroupedSelectDialogInput | func NewGroupedSelectDialogInput(name, label string, options []DialogOptionGroup) *DialogInputSelect {
return &DialogInputSelect{
DialogInput: DialogInput{
Type: InputTypeSelect,
Name: name,
Label: label,
},
DataSource: DialogDataSourceStatic,
OptionGroups: options}
} | go | func NewGroupedSelectDialogInput(name, label string, options []DialogOptionGroup) *DialogInputSelect {
return &DialogInputSelect{
DialogInput: DialogInput{
Type: InputTypeSelect,
Name: name,
Label: label,
},
DataSource: DialogDataSourceStatic,
OptionGroups: options}
} | [
"func",
"NewGroupedSelectDialogInput",
"(",
"name",
",",
"label",
"string",
",",
"options",
"[",
"]",
"DialogOptionGroup",
")",
"*",
"DialogInputSelect",
"{",
"return",
"&",
"DialogInputSelect",
"{",
"DialogInput",
":",
"DialogInput",
"{",
"Type",
":",
"InputTypeSelect",
",",
"Name",
":",
"name",
",",
"Label",
":",
"label",
",",
"}",
",",
"DataSource",
":",
"DialogDataSourceStatic",
",",
"OptionGroups",
":",
"options",
"}",
"\n",
"}"
] | // NewGroupedSelectDialogInput creates grouped options select input for Dialogs. | [
"NewGroupedSelectDialogInput",
"creates",
"grouped",
"options",
"select",
"input",
"for",
"Dialogs",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/dialog_select.go#L58-L67 | train |
nlopes/slack | dialog_select.go | NewDialogOptionGroup | func NewDialogOptionGroup(label string, options ...DialogSelectOption) DialogOptionGroup {
return DialogOptionGroup{
Label: label,
Options: options,
}
} | go | func NewDialogOptionGroup(label string, options ...DialogSelectOption) DialogOptionGroup {
return DialogOptionGroup{
Label: label,
Options: options,
}
} | [
"func",
"NewDialogOptionGroup",
"(",
"label",
"string",
",",
"options",
"...",
"DialogSelectOption",
")",
"DialogOptionGroup",
"{",
"return",
"DialogOptionGroup",
"{",
"Label",
":",
"label",
",",
"Options",
":",
"options",
",",
"}",
"\n",
"}"
] | // NewDialogOptionGroup creates a DialogOptionGroup from several select options | [
"NewDialogOptionGroup",
"creates",
"a",
"DialogOptionGroup",
"from",
"several",
"select",
"options"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/dialog_select.go#L70-L75 | train |
nlopes/slack | slackutilsx/slackutilsx.go | DetectChannelType | func DetectChannelType(channelID string) ChannelType {
// intentionally ignore the error and just default to CTypeUnknown
switch r, _ := utf8.DecodeRuneInString(channelID); r {
case 'C':
return CTypeChannel
case 'G':
return CTypeGroup
case 'D':
return CTypeDM
default:
return CTypeUnknown
}
} | go | func DetectChannelType(channelID string) ChannelType {
// intentionally ignore the error and just default to CTypeUnknown
switch r, _ := utf8.DecodeRuneInString(channelID); r {
case 'C':
return CTypeChannel
case 'G':
return CTypeGroup
case 'D':
return CTypeDM
default:
return CTypeUnknown
}
} | [
"func",
"DetectChannelType",
"(",
"channelID",
"string",
")",
"ChannelType",
"{",
"// intentionally ignore the error and just default to CTypeUnknown",
"switch",
"r",
",",
"_",
":=",
"utf8",
".",
"DecodeRuneInString",
"(",
"channelID",
")",
";",
"r",
"{",
"case",
"'C'",
":",
"return",
"CTypeChannel",
"\n",
"case",
"'G'",
":",
"return",
"CTypeGroup",
"\n",
"case",
"'D'",
":",
"return",
"CTypeDM",
"\n",
"default",
":",
"return",
"CTypeUnknown",
"\n",
"}",
"\n",
"}"
] | // DetectChannelType converts a channelID to a ChannelType.
// channelID must not be empty. However, if it is empty, the channel type will default to Unknown. | [
"DetectChannelType",
"converts",
"a",
"channelID",
"to",
"a",
"ChannelType",
".",
"channelID",
"must",
"not",
"be",
"empty",
".",
"However",
"if",
"it",
"is",
"empty",
"the",
"channel",
"type",
"will",
"default",
"to",
"Unknown",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/slackutilsx/slackutilsx.go#L39-L51 | train |
nlopes/slack | history.go | NewHistoryParameters | func NewHistoryParameters() HistoryParameters {
return HistoryParameters{
Latest: DEFAULT_HISTORY_LATEST,
Oldest: DEFAULT_HISTORY_OLDEST,
Count: DEFAULT_HISTORY_COUNT,
Inclusive: DEFAULT_HISTORY_INCLUSIVE,
Unreads: DEFAULT_HISTORY_UNREADS,
}
} | go | func NewHistoryParameters() HistoryParameters {
return HistoryParameters{
Latest: DEFAULT_HISTORY_LATEST,
Oldest: DEFAULT_HISTORY_OLDEST,
Count: DEFAULT_HISTORY_COUNT,
Inclusive: DEFAULT_HISTORY_INCLUSIVE,
Unreads: DEFAULT_HISTORY_UNREADS,
}
} | [
"func",
"NewHistoryParameters",
"(",
")",
"HistoryParameters",
"{",
"return",
"HistoryParameters",
"{",
"Latest",
":",
"DEFAULT_HISTORY_LATEST",
",",
"Oldest",
":",
"DEFAULT_HISTORY_OLDEST",
",",
"Count",
":",
"DEFAULT_HISTORY_COUNT",
",",
"Inclusive",
":",
"DEFAULT_HISTORY_INCLUSIVE",
",",
"Unreads",
":",
"DEFAULT_HISTORY_UNREADS",
",",
"}",
"\n",
"}"
] | // NewHistoryParameters provides an instance of HistoryParameters with all the sane default values set | [
"NewHistoryParameters",
"provides",
"an",
"instance",
"of",
"HistoryParameters",
"with",
"all",
"the",
"sane",
"default",
"values",
"set"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/history.go#L28-L36 | train |
nlopes/slack | examples/blocks/blocks.go | main | func main() {
fmt.Println("--- Begin Example One ---")
exampleOne()
fmt.Println("--- End Example One ---")
fmt.Println("--- Begin Example Two ---")
exampleTwo()
fmt.Println("--- End Example Two ---")
fmt.Println("--- Begin Example Three ---")
exampleThree()
fmt.Println("--- End Example Three ---")
fmt.Println("--- Begin Example Four ---")
exampleFour()
fmt.Println("--- End Example Four ---")
fmt.Println("--- Begin Example Five ---")
exampleFive()
fmt.Println("--- End Example Five ---")
fmt.Println("--- Begin Example Six ---")
exampleSix()
fmt.Println("--- End Example Six ---")
} | go | func main() {
fmt.Println("--- Begin Example One ---")
exampleOne()
fmt.Println("--- End Example One ---")
fmt.Println("--- Begin Example Two ---")
exampleTwo()
fmt.Println("--- End Example Two ---")
fmt.Println("--- Begin Example Three ---")
exampleThree()
fmt.Println("--- End Example Three ---")
fmt.Println("--- Begin Example Four ---")
exampleFour()
fmt.Println("--- End Example Four ---")
fmt.Println("--- Begin Example Five ---")
exampleFive()
fmt.Println("--- End Example Five ---")
fmt.Println("--- Begin Example Six ---")
exampleSix()
fmt.Println("--- End Example Six ---")
} | [
"func",
"main",
"(",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"exampleOne",
"(",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"exampleTwo",
"(",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"exampleThree",
"(",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"exampleFour",
"(",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"exampleFive",
"(",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"exampleSix",
"(",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n\n",
"}"
] | // The functions below mock the different templates slack has as examples on their website.
//
// Refer to README.md for more information on the examples and how to use them. | [
"The",
"functions",
"below",
"mock",
"the",
"different",
"templates",
"slack",
"has",
"as",
"examples",
"on",
"their",
"website",
".",
"Refer",
"to",
"README",
".",
"md",
"for",
"more",
"information",
"on",
"the",
"examples",
"and",
"how",
"to",
"use",
"them",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/examples/blocks/blocks.go#L14-L40 | train |
nlopes/slack | examples/blocks/blocks.go | exampleOne | func exampleOne() {
// Header Section
headerText := slack.NewTextBlockObject("mrkdwn", "You have a new request:\n*<fakeLink.toEmployeeProfile.com|Fred Enriquez - New device request>*", false, false)
headerSection := slack.NewSectionBlock(headerText, nil, nil)
// Fields
typeField := slack.NewTextBlockObject("mrkdwn", "*Type:*\nComputer (laptop)", false, false)
whenField := slack.NewTextBlockObject("mrkdwn", "*When:*\nSubmitted Aut 10", false, false)
lastUpdateField := slack.NewTextBlockObject("mrkdwn", "*Last Update:*\nMar 10, 2015 (3 years, 5 months)", false, false)
reasonField := slack.NewTextBlockObject("mrkdwn", "*Reason:*\nAll vowel keys aren't working.", false, false)
specsField := slack.NewTextBlockObject("mrkdwn", "*Specs:*\n\"Cheetah Pro 15\" - Fast, really fast\"", false, false)
fieldSlice := make([]*slack.TextBlockObject, 0)
fieldSlice = append(fieldSlice, typeField)
fieldSlice = append(fieldSlice, whenField)
fieldSlice = append(fieldSlice, lastUpdateField)
fieldSlice = append(fieldSlice, reasonField)
fieldSlice = append(fieldSlice, specsField)
fieldsSection := slack.NewSectionBlock(nil, fieldSlice, nil)
// Approve and Deny Buttons
approveBtnTxt := slack.NewTextBlockObject("plain_text", "Approve", false, false)
approveBtn := slack.NewButtonBlockElement("", "click_me_123", approveBtnTxt)
denyBtnTxt := slack.NewTextBlockObject("plain_text", "Deny", false, false)
denyBtn := slack.NewButtonBlockElement("", "click_me_123", denyBtnTxt)
actionBlock := slack.NewActionBlock("", approveBtn, denyBtn)
// Build Message with blocks created above
msg := slack.NewBlockMessage(
headerSection,
fieldsSection,
actionBlock,
)
b, err := json.MarshalIndent(msg, "", " ")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(b))
} | go | func exampleOne() {
// Header Section
headerText := slack.NewTextBlockObject("mrkdwn", "You have a new request:\n*<fakeLink.toEmployeeProfile.com|Fred Enriquez - New device request>*", false, false)
headerSection := slack.NewSectionBlock(headerText, nil, nil)
// Fields
typeField := slack.NewTextBlockObject("mrkdwn", "*Type:*\nComputer (laptop)", false, false)
whenField := slack.NewTextBlockObject("mrkdwn", "*When:*\nSubmitted Aut 10", false, false)
lastUpdateField := slack.NewTextBlockObject("mrkdwn", "*Last Update:*\nMar 10, 2015 (3 years, 5 months)", false, false)
reasonField := slack.NewTextBlockObject("mrkdwn", "*Reason:*\nAll vowel keys aren't working.", false, false)
specsField := slack.NewTextBlockObject("mrkdwn", "*Specs:*\n\"Cheetah Pro 15\" - Fast, really fast\"", false, false)
fieldSlice := make([]*slack.TextBlockObject, 0)
fieldSlice = append(fieldSlice, typeField)
fieldSlice = append(fieldSlice, whenField)
fieldSlice = append(fieldSlice, lastUpdateField)
fieldSlice = append(fieldSlice, reasonField)
fieldSlice = append(fieldSlice, specsField)
fieldsSection := slack.NewSectionBlock(nil, fieldSlice, nil)
// Approve and Deny Buttons
approveBtnTxt := slack.NewTextBlockObject("plain_text", "Approve", false, false)
approveBtn := slack.NewButtonBlockElement("", "click_me_123", approveBtnTxt)
denyBtnTxt := slack.NewTextBlockObject("plain_text", "Deny", false, false)
denyBtn := slack.NewButtonBlockElement("", "click_me_123", denyBtnTxt)
actionBlock := slack.NewActionBlock("", approveBtn, denyBtn)
// Build Message with blocks created above
msg := slack.NewBlockMessage(
headerSection,
fieldsSection,
actionBlock,
)
b, err := json.MarshalIndent(msg, "", " ")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(b))
} | [
"func",
"exampleOne",
"(",
")",
"{",
"// Header Section",
"headerText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"headerSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"headerText",
",",
"nil",
",",
"nil",
")",
"\n\n",
"// Fields",
"typeField",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"whenField",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"lastUpdateField",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"reasonField",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"specsField",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\\\"",
"\\\"",
"\\\"",
"\"",
",",
"false",
",",
"false",
")",
"\n\n",
"fieldSlice",
":=",
"make",
"(",
"[",
"]",
"*",
"slack",
".",
"TextBlockObject",
",",
"0",
")",
"\n",
"fieldSlice",
"=",
"append",
"(",
"fieldSlice",
",",
"typeField",
")",
"\n",
"fieldSlice",
"=",
"append",
"(",
"fieldSlice",
",",
"whenField",
")",
"\n",
"fieldSlice",
"=",
"append",
"(",
"fieldSlice",
",",
"lastUpdateField",
")",
"\n",
"fieldSlice",
"=",
"append",
"(",
"fieldSlice",
",",
"reasonField",
")",
"\n",
"fieldSlice",
"=",
"append",
"(",
"fieldSlice",
",",
"specsField",
")",
"\n\n",
"fieldsSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"nil",
",",
"fieldSlice",
",",
"nil",
")",
"\n\n",
"// Approve and Deny Buttons",
"approveBtnTxt",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"approveBtn",
":=",
"slack",
".",
"NewButtonBlockElement",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"approveBtnTxt",
")",
"\n\n",
"denyBtnTxt",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"denyBtn",
":=",
"slack",
".",
"NewButtonBlockElement",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"denyBtnTxt",
")",
"\n\n",
"actionBlock",
":=",
"slack",
".",
"NewActionBlock",
"(",
"\"",
"\"",
",",
"approveBtn",
",",
"denyBtn",
")",
"\n\n",
"// Build Message with blocks created above",
"msg",
":=",
"slack",
".",
"NewBlockMessage",
"(",
"headerSection",
",",
"fieldsSection",
",",
"actionBlock",
",",
")",
"\n\n",
"b",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"msg",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Println",
"(",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"string",
"(",
"b",
")",
")",
"\n\n",
"}"
] | // approvalRequest mocks the simple "Approval" template located on block kit builder website | [
"approvalRequest",
"mocks",
"the",
"simple",
"Approval",
"template",
"located",
"on",
"block",
"kit",
"builder",
"website"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/examples/blocks/blocks.go#L43-L90 | train |
nlopes/slack | examples/blocks/blocks.go | exampleTwo | func exampleTwo() {
// Header Section
headerText := slack.NewTextBlockObject("mrkdwn", "You have a new request:\n*<google.com|Fred Enriquez - Time Off request>*", false, false)
headerSection := slack.NewSectionBlock(headerText, nil, nil)
approvalText := slack.NewTextBlockObject("mrkdwn", "*Type:*\nPaid time off\n*When:*\nAug 10-Aug 13\n*Hours:* 16.0 (2 days)\n*Remaining balance:* 32.0 hours (4 days)\n*Comments:* \"Family in town, going camping!\"", false, false)
approvalImage := slack.NewImageBlockElement("https://api.slack.com/img/blocks/bkb_template_images/approvalsNewDevice.png", "computer thumbnail")
fieldsSection := slack.NewSectionBlock(approvalText, nil, approvalImage)
// Approve and Deny Buttons
approveBtnTxt := slack.NewTextBlockObject("plain_text", "Approve", false, false)
approveBtn := slack.NewButtonBlockElement("", "click_me_123", approveBtnTxt)
denyBtnTxt := slack.NewTextBlockObject("plain_text", "Deny", false, false)
denyBtn := slack.NewButtonBlockElement("", "click_me_123", denyBtnTxt)
actionBlock := slack.NewActionBlock("", approveBtn, denyBtn)
// Build Message with blocks created above
msg := slack.NewBlockMessage(
headerSection,
fieldsSection,
actionBlock,
)
b, err := json.MarshalIndent(msg, "", " ")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(b))
} | go | func exampleTwo() {
// Header Section
headerText := slack.NewTextBlockObject("mrkdwn", "You have a new request:\n*<google.com|Fred Enriquez - Time Off request>*", false, false)
headerSection := slack.NewSectionBlock(headerText, nil, nil)
approvalText := slack.NewTextBlockObject("mrkdwn", "*Type:*\nPaid time off\n*When:*\nAug 10-Aug 13\n*Hours:* 16.0 (2 days)\n*Remaining balance:* 32.0 hours (4 days)\n*Comments:* \"Family in town, going camping!\"", false, false)
approvalImage := slack.NewImageBlockElement("https://api.slack.com/img/blocks/bkb_template_images/approvalsNewDevice.png", "computer thumbnail")
fieldsSection := slack.NewSectionBlock(approvalText, nil, approvalImage)
// Approve and Deny Buttons
approveBtnTxt := slack.NewTextBlockObject("plain_text", "Approve", false, false)
approveBtn := slack.NewButtonBlockElement("", "click_me_123", approveBtnTxt)
denyBtnTxt := slack.NewTextBlockObject("plain_text", "Deny", false, false)
denyBtn := slack.NewButtonBlockElement("", "click_me_123", denyBtnTxt)
actionBlock := slack.NewActionBlock("", approveBtn, denyBtn)
// Build Message with blocks created above
msg := slack.NewBlockMessage(
headerSection,
fieldsSection,
actionBlock,
)
b, err := json.MarshalIndent(msg, "", " ")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(b))
} | [
"func",
"exampleTwo",
"(",
")",
"{",
"// Header Section",
"headerText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"headerSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"headerText",
",",
"nil",
",",
"nil",
")",
"\n\n",
"approvalText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\\n",
"\\n",
"\\n",
"\\n",
"\\n",
"\\\"",
"\\\"",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"approvalImage",
":=",
"slack",
".",
"NewImageBlockElement",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"fieldsSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"approvalText",
",",
"nil",
",",
"approvalImage",
")",
"\n\n",
"// Approve and Deny Buttons",
"approveBtnTxt",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"approveBtn",
":=",
"slack",
".",
"NewButtonBlockElement",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"approveBtnTxt",
")",
"\n\n",
"denyBtnTxt",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"denyBtn",
":=",
"slack",
".",
"NewButtonBlockElement",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"denyBtnTxt",
")",
"\n\n",
"actionBlock",
":=",
"slack",
".",
"NewActionBlock",
"(",
"\"",
"\"",
",",
"approveBtn",
",",
"denyBtn",
")",
"\n\n",
"// Build Message with blocks created above",
"msg",
":=",
"slack",
".",
"NewBlockMessage",
"(",
"headerSection",
",",
"fieldsSection",
",",
"actionBlock",
",",
")",
"\n\n",
"b",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"msg",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Println",
"(",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"string",
"(",
"b",
")",
")",
"\n\n",
"}"
] | // exampleTwo mocks the more complex "Approval" template located on block kit builder website
// which includes an accessory image next to the approval request | [
"exampleTwo",
"mocks",
"the",
"more",
"complex",
"Approval",
"template",
"located",
"on",
"block",
"kit",
"builder",
"website",
"which",
"includes",
"an",
"accessory",
"image",
"next",
"to",
"the",
"approval",
"request"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/examples/blocks/blocks.go#L94-L130 | train |
nlopes/slack | examples/blocks/blocks.go | exampleThree | func exampleThree() {
// Shared Assets for example
chooseBtnText := slack.NewTextBlockObject("plain_text", "Choose", true, false)
chooseBtnEle := slack.NewButtonBlockElement("", "click_me_123", chooseBtnText)
divSection := slack.NewDividerBlock()
// Header Section
headerText := slack.NewTextBlockObject("plain_text", "Looks like you have a scheduling conflict with this event:", false, false)
headerSection := slack.NewSectionBlock(headerText, nil, nil)
// Schedule Info Section
scheduleText := slack.NewTextBlockObject("mrkdwn", "*<fakeLink.toUserProfiles.com|Iris / Zelda 1-1>*\nTuesday, January 21 4:00-4:30pm\nBuilding 2 - Havarti Cheese (3)\n2 guests", false, false)
scheduleAccessory := slack.NewImageBlockElement("https://api.slack.com/img/blocks/bkb_template_images/notifications.png", "calendar thumbnail")
schedeuleSection := slack.NewSectionBlock(scheduleText, nil, scheduleAccessory)
// Conflict Section
conflictImage := slack.NewImageBlockObject("https://api.slack.com/img/blocks/bkb_template_images/notificationsWarningIcon.png", "notifications warning icon")
conflictText := slack.NewTextBlockObject("mrkdwn", "*Conflicts with Team Huddle: 4:15-4:30pm*", false, false)
conflictSection := slack.NewContextBlock("", conflictImage, conflictText)
// Proposese Text
proposeText := slack.NewTextBlockObject("mrkdwn", "*Propose a new time:*", false, false)
proposeSection := slack.NewSectionBlock(proposeText, nil, nil)
// Option 1
optionOneText := slack.NewTextBlockObject("mrkdwn", "*Today - 4:30-5pm*\nEveryone is available: @iris, @zelda", false, false)
optionOneSection := slack.NewSectionBlock(optionOneText, nil, chooseBtnEle)
// Option 2
optionTwoText := slack.NewTextBlockObject("mrkdwn", "*Tomorrow - 4-4:30pm*\nEveryone is available: @iris, @zelda", false, false)
optionTwoSection := slack.NewSectionBlock(optionTwoText, nil, chooseBtnEle)
// Option 3
optionThreeText := slack.NewTextBlockObject("mrkdwn", "*Tomorrow - 6-6:30pm*\nSome people aren't available: @iris, ~@zelda~", false, false)
optionThreeSection := slack.NewSectionBlock(optionThreeText, nil, chooseBtnEle)
// Show More Times Link
showMoreText := slack.NewTextBlockObject("mrkdwn", "*<fakelink.ToMoreTimes.com|Show more times>*", false, false)
showMoreSection := slack.NewSectionBlock(showMoreText, nil, nil)
// Build Message with blocks created above
msg := slack.NewBlockMessage(
headerSection,
divSection,
schedeuleSection,
conflictSection,
divSection,
proposeSection,
optionOneSection,
optionTwoSection,
optionThreeSection,
showMoreSection,
)
b, err := json.MarshalIndent(msg, "", " ")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(b))
} | go | func exampleThree() {
// Shared Assets for example
chooseBtnText := slack.NewTextBlockObject("plain_text", "Choose", true, false)
chooseBtnEle := slack.NewButtonBlockElement("", "click_me_123", chooseBtnText)
divSection := slack.NewDividerBlock()
// Header Section
headerText := slack.NewTextBlockObject("plain_text", "Looks like you have a scheduling conflict with this event:", false, false)
headerSection := slack.NewSectionBlock(headerText, nil, nil)
// Schedule Info Section
scheduleText := slack.NewTextBlockObject("mrkdwn", "*<fakeLink.toUserProfiles.com|Iris / Zelda 1-1>*\nTuesday, January 21 4:00-4:30pm\nBuilding 2 - Havarti Cheese (3)\n2 guests", false, false)
scheduleAccessory := slack.NewImageBlockElement("https://api.slack.com/img/blocks/bkb_template_images/notifications.png", "calendar thumbnail")
schedeuleSection := slack.NewSectionBlock(scheduleText, nil, scheduleAccessory)
// Conflict Section
conflictImage := slack.NewImageBlockObject("https://api.slack.com/img/blocks/bkb_template_images/notificationsWarningIcon.png", "notifications warning icon")
conflictText := slack.NewTextBlockObject("mrkdwn", "*Conflicts with Team Huddle: 4:15-4:30pm*", false, false)
conflictSection := slack.NewContextBlock("", conflictImage, conflictText)
// Proposese Text
proposeText := slack.NewTextBlockObject("mrkdwn", "*Propose a new time:*", false, false)
proposeSection := slack.NewSectionBlock(proposeText, nil, nil)
// Option 1
optionOneText := slack.NewTextBlockObject("mrkdwn", "*Today - 4:30-5pm*\nEveryone is available: @iris, @zelda", false, false)
optionOneSection := slack.NewSectionBlock(optionOneText, nil, chooseBtnEle)
// Option 2
optionTwoText := slack.NewTextBlockObject("mrkdwn", "*Tomorrow - 4-4:30pm*\nEveryone is available: @iris, @zelda", false, false)
optionTwoSection := slack.NewSectionBlock(optionTwoText, nil, chooseBtnEle)
// Option 3
optionThreeText := slack.NewTextBlockObject("mrkdwn", "*Tomorrow - 6-6:30pm*\nSome people aren't available: @iris, ~@zelda~", false, false)
optionThreeSection := slack.NewSectionBlock(optionThreeText, nil, chooseBtnEle)
// Show More Times Link
showMoreText := slack.NewTextBlockObject("mrkdwn", "*<fakelink.ToMoreTimes.com|Show more times>*", false, false)
showMoreSection := slack.NewSectionBlock(showMoreText, nil, nil)
// Build Message with blocks created above
msg := slack.NewBlockMessage(
headerSection,
divSection,
schedeuleSection,
conflictSection,
divSection,
proposeSection,
optionOneSection,
optionTwoSection,
optionThreeSection,
showMoreSection,
)
b, err := json.MarshalIndent(msg, "", " ")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(b))
} | [
"func",
"exampleThree",
"(",
")",
"{",
"// Shared Assets for example",
"chooseBtnText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"true",
",",
"false",
")",
"\n",
"chooseBtnEle",
":=",
"slack",
".",
"NewButtonBlockElement",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"chooseBtnText",
")",
"\n",
"divSection",
":=",
"slack",
".",
"NewDividerBlock",
"(",
")",
"\n\n",
"// Header Section",
"headerText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"headerSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"headerText",
",",
"nil",
",",
"nil",
")",
"\n\n",
"// Schedule Info Section",
"scheduleText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\\n",
"\\n",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"scheduleAccessory",
":=",
"slack",
".",
"NewImageBlockElement",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"schedeuleSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"scheduleText",
",",
"nil",
",",
"scheduleAccessory",
")",
"\n\n",
"// Conflict Section",
"conflictImage",
":=",
"slack",
".",
"NewImageBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"conflictText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"conflictSection",
":=",
"slack",
".",
"NewContextBlock",
"(",
"\"",
"\"",
",",
"conflictImage",
",",
"conflictText",
")",
"\n\n",
"// Proposese Text",
"proposeText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"proposeSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"proposeText",
",",
"nil",
",",
"nil",
")",
"\n\n",
"// Option 1",
"optionOneText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"optionOneSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"optionOneText",
",",
"nil",
",",
"chooseBtnEle",
")",
"\n\n",
"// Option 2",
"optionTwoText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"optionTwoSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"optionTwoText",
",",
"nil",
",",
"chooseBtnEle",
")",
"\n\n",
"// Option 3",
"optionThreeText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"optionThreeSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"optionThreeText",
",",
"nil",
",",
"chooseBtnEle",
")",
"\n\n",
"// Show More Times Link",
"showMoreText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"showMoreSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"showMoreText",
",",
"nil",
",",
"nil",
")",
"\n\n",
"// Build Message with blocks created above",
"msg",
":=",
"slack",
".",
"NewBlockMessage",
"(",
"headerSection",
",",
"divSection",
",",
"schedeuleSection",
",",
"conflictSection",
",",
"divSection",
",",
"proposeSection",
",",
"optionOneSection",
",",
"optionTwoSection",
",",
"optionThreeSection",
",",
"showMoreSection",
",",
")",
"\n\n",
"b",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"msg",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Println",
"(",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"string",
"(",
"b",
")",
")",
"\n\n",
"}"
] | // exampleThree generates the notification example from the block kit builder website | [
"exampleThree",
"generates",
"the",
"notification",
"example",
"from",
"the",
"block",
"kit",
"builder",
"website"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/examples/blocks/blocks.go#L133-L196 | train |
nlopes/slack | examples/blocks/blocks.go | exampleFour | func exampleFour() {
// Shared Assets for example
divSection := slack.NewDividerBlock()
voteBtnText := slack.NewTextBlockObject("plain_text", "Vote", true, false)
voteBtnEle := slack.NewButtonBlockElement("", "click_me_123", voteBtnText)
profileOne := slack.NewImageBlockObject("https://api.slack.com/img/blocks/bkb_template_images/profile_1.png", "Michael Scott")
profileTwo := slack.NewImageBlockObject("https://api.slack.com/img/blocks/bkb_template_images/profile_2.png", "Dwight Schrute")
profileThree := slack.NewImageBlockObject("https://api.slack.com/img/blocks/bkb_template_images/profile_3.png", "Pam Beasely")
profileFour := slack.NewImageBlockObject("https://api.slack.com/img/blocks/bkb_template_images/profile_4.png", "Angela")
// Header Section
headerText := slack.NewTextBlockObject("mrkdwn", "*Where should we order lunch from?* Poll by <fakeLink.toUser.com|Mark>", false, false)
headerSection := slack.NewSectionBlock(headerText, nil, nil)
// Option One Info
optOneText := slack.NewTextBlockObject("mrkdwn", ":sushi: *Ace Wasabi Rock-n-Roll Sushi Bar*\nThe best landlocked sushi restaurant.", false, false)
optOneSection := slack.NewSectionBlock(optOneText, nil, voteBtnEle)
// Option One Votes
optOneVoteText := slack.NewTextBlockObject("plain_text", "3 votes", true, false)
optOneContext := slack.NewContextBlock("", profileOne, profileTwo, profileThree, optOneVoteText)
// Option Two Info
optTwoText := slack.NewTextBlockObject("mrkdwn", ":hamburger: *Super Hungryman Hamburgers*\nOnly for the hungriest of the hungry.", false, false)
optTwoSection := slack.NewSectionBlock(optTwoText, nil, voteBtnEle)
// Option Two Votes
optTwoVoteText := slack.NewTextBlockObject("plain_text", "2 votes", true, false)
optTwoContext := slack.NewContextBlock("", profileFour, profileTwo, optTwoVoteText)
// Option Three Info
optThreeText := slack.NewTextBlockObject("mrkdwn", ":ramen: *Kagawa-Ya Udon Noodle Shop*\nDo you like to shop for noodles? We have noodles.", false, false)
optThreeSection := slack.NewSectionBlock(optThreeText, nil, voteBtnEle)
// Option Three Votes
optThreeVoteText := slack.NewTextBlockObject("plain_text", "No votes", true, false)
optThreeContext := slack.NewContextBlock("", optThreeVoteText)
// Suggestions Action
btnTxt := slack.NewTextBlockObject("plain_text", "Add a suggestion", false, false)
nextBtn := slack.NewButtonBlockElement("", "click_me_123", btnTxt)
actionBlock := slack.NewActionBlock("", nextBtn)
// Build Message with blocks created above
msg := slack.NewBlockMessage(
headerSection,
divSection,
optOneSection,
optOneContext,
optTwoSection,
optTwoContext,
optThreeSection,
optThreeContext,
divSection,
actionBlock,
)
b, err := json.MarshalIndent(msg, "", " ")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(b))
} | go | func exampleFour() {
// Shared Assets for example
divSection := slack.NewDividerBlock()
voteBtnText := slack.NewTextBlockObject("plain_text", "Vote", true, false)
voteBtnEle := slack.NewButtonBlockElement("", "click_me_123", voteBtnText)
profileOne := slack.NewImageBlockObject("https://api.slack.com/img/blocks/bkb_template_images/profile_1.png", "Michael Scott")
profileTwo := slack.NewImageBlockObject("https://api.slack.com/img/blocks/bkb_template_images/profile_2.png", "Dwight Schrute")
profileThree := slack.NewImageBlockObject("https://api.slack.com/img/blocks/bkb_template_images/profile_3.png", "Pam Beasely")
profileFour := slack.NewImageBlockObject("https://api.slack.com/img/blocks/bkb_template_images/profile_4.png", "Angela")
// Header Section
headerText := slack.NewTextBlockObject("mrkdwn", "*Where should we order lunch from?* Poll by <fakeLink.toUser.com|Mark>", false, false)
headerSection := slack.NewSectionBlock(headerText, nil, nil)
// Option One Info
optOneText := slack.NewTextBlockObject("mrkdwn", ":sushi: *Ace Wasabi Rock-n-Roll Sushi Bar*\nThe best landlocked sushi restaurant.", false, false)
optOneSection := slack.NewSectionBlock(optOneText, nil, voteBtnEle)
// Option One Votes
optOneVoteText := slack.NewTextBlockObject("plain_text", "3 votes", true, false)
optOneContext := slack.NewContextBlock("", profileOne, profileTwo, profileThree, optOneVoteText)
// Option Two Info
optTwoText := slack.NewTextBlockObject("mrkdwn", ":hamburger: *Super Hungryman Hamburgers*\nOnly for the hungriest of the hungry.", false, false)
optTwoSection := slack.NewSectionBlock(optTwoText, nil, voteBtnEle)
// Option Two Votes
optTwoVoteText := slack.NewTextBlockObject("plain_text", "2 votes", true, false)
optTwoContext := slack.NewContextBlock("", profileFour, profileTwo, optTwoVoteText)
// Option Three Info
optThreeText := slack.NewTextBlockObject("mrkdwn", ":ramen: *Kagawa-Ya Udon Noodle Shop*\nDo you like to shop for noodles? We have noodles.", false, false)
optThreeSection := slack.NewSectionBlock(optThreeText, nil, voteBtnEle)
// Option Three Votes
optThreeVoteText := slack.NewTextBlockObject("plain_text", "No votes", true, false)
optThreeContext := slack.NewContextBlock("", optThreeVoteText)
// Suggestions Action
btnTxt := slack.NewTextBlockObject("plain_text", "Add a suggestion", false, false)
nextBtn := slack.NewButtonBlockElement("", "click_me_123", btnTxt)
actionBlock := slack.NewActionBlock("", nextBtn)
// Build Message with blocks created above
msg := slack.NewBlockMessage(
headerSection,
divSection,
optOneSection,
optOneContext,
optTwoSection,
optTwoContext,
optThreeSection,
optThreeContext,
divSection,
actionBlock,
)
b, err := json.MarshalIndent(msg, "", " ")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(b))
} | [
"func",
"exampleFour",
"(",
")",
"{",
"// Shared Assets for example",
"divSection",
":=",
"slack",
".",
"NewDividerBlock",
"(",
")",
"\n",
"voteBtnText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"true",
",",
"false",
")",
"\n",
"voteBtnEle",
":=",
"slack",
".",
"NewButtonBlockElement",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"voteBtnText",
")",
"\n",
"profileOne",
":=",
"slack",
".",
"NewImageBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"profileTwo",
":=",
"slack",
".",
"NewImageBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"profileThree",
":=",
"slack",
".",
"NewImageBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"profileFour",
":=",
"slack",
".",
"NewImageBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"// Header Section",
"headerText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"headerSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"headerText",
",",
"nil",
",",
"nil",
")",
"\n\n",
"// Option One Info",
"optOneText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"optOneSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"optOneText",
",",
"nil",
",",
"voteBtnEle",
")",
"\n\n",
"// Option One Votes",
"optOneVoteText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"true",
",",
"false",
")",
"\n",
"optOneContext",
":=",
"slack",
".",
"NewContextBlock",
"(",
"\"",
"\"",
",",
"profileOne",
",",
"profileTwo",
",",
"profileThree",
",",
"optOneVoteText",
")",
"\n\n",
"// Option Two Info",
"optTwoText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"optTwoSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"optTwoText",
",",
"nil",
",",
"voteBtnEle",
")",
"\n\n",
"// Option Two Votes",
"optTwoVoteText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"true",
",",
"false",
")",
"\n",
"optTwoContext",
":=",
"slack",
".",
"NewContextBlock",
"(",
"\"",
"\"",
",",
"profileFour",
",",
"profileTwo",
",",
"optTwoVoteText",
")",
"\n\n",
"// Option Three Info",
"optThreeText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\\n",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"optThreeSection",
":=",
"slack",
".",
"NewSectionBlock",
"(",
"optThreeText",
",",
"nil",
",",
"voteBtnEle",
")",
"\n\n",
"// Option Three Votes",
"optThreeVoteText",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"true",
",",
"false",
")",
"\n",
"optThreeContext",
":=",
"slack",
".",
"NewContextBlock",
"(",
"\"",
"\"",
",",
"optThreeVoteText",
")",
"\n\n",
"// Suggestions Action",
"btnTxt",
":=",
"slack",
".",
"NewTextBlockObject",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"false",
",",
"false",
")",
"\n",
"nextBtn",
":=",
"slack",
".",
"NewButtonBlockElement",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"btnTxt",
")",
"\n",
"actionBlock",
":=",
"slack",
".",
"NewActionBlock",
"(",
"\"",
"\"",
",",
"nextBtn",
")",
"\n\n",
"// Build Message with blocks created above",
"msg",
":=",
"slack",
".",
"NewBlockMessage",
"(",
"headerSection",
",",
"divSection",
",",
"optOneSection",
",",
"optOneContext",
",",
"optTwoSection",
",",
"optTwoContext",
",",
"optThreeSection",
",",
"optThreeContext",
",",
"divSection",
",",
"actionBlock",
",",
")",
"\n\n",
"b",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"msg",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Println",
"(",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"fmt",
".",
"Println",
"(",
"string",
"(",
"b",
")",
")",
"\n\n",
"}"
] | // exampleFour profiles a poll example block | [
"exampleFour",
"profiles",
"a",
"poll",
"example",
"block"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/examples/blocks/blocks.go#L199-L265 | train |
nlopes/slack | item.go | NewMessageItem | func NewMessageItem(ch string, m *Message) Item {
return Item{Type: TYPE_MESSAGE, Channel: ch, Message: m}
} | go | func NewMessageItem(ch string, m *Message) Item {
return Item{Type: TYPE_MESSAGE, Channel: ch, Message: m}
} | [
"func",
"NewMessageItem",
"(",
"ch",
"string",
",",
"m",
"*",
"Message",
")",
"Item",
"{",
"return",
"Item",
"{",
"Type",
":",
"TYPE_MESSAGE",
",",
"Channel",
":",
"ch",
",",
"Message",
":",
"m",
"}",
"\n",
"}"
] | // NewMessageItem turns a message on a channel into a typed message struct. | [
"NewMessageItem",
"turns",
"a",
"message",
"on",
"a",
"channel",
"into",
"a",
"typed",
"message",
"struct",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/item.go#L23-L25 | train |
nlopes/slack | item.go | NewFileCommentItem | func NewFileCommentItem(f *File, c *Comment) Item {
return Item{Type: TYPE_FILE_COMMENT, File: f, Comment: c}
} | go | func NewFileCommentItem(f *File, c *Comment) Item {
return Item{Type: TYPE_FILE_COMMENT, File: f, Comment: c}
} | [
"func",
"NewFileCommentItem",
"(",
"f",
"*",
"File",
",",
"c",
"*",
"Comment",
")",
"Item",
"{",
"return",
"Item",
"{",
"Type",
":",
"TYPE_FILE_COMMENT",
",",
"File",
":",
"f",
",",
"Comment",
":",
"c",
"}",
"\n",
"}"
] | // NewFileCommentItem turns a file and comment into a typed file_comment struct. | [
"NewFileCommentItem",
"turns",
"a",
"file",
"and",
"comment",
"into",
"a",
"typed",
"file_comment",
"struct",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/item.go#L33-L35 | train |
nlopes/slack | item.go | NewRefToMessage | func NewRefToMessage(channel, timestamp string) ItemRef {
return ItemRef{Channel: channel, Timestamp: timestamp}
} | go | func NewRefToMessage(channel, timestamp string) ItemRef {
return ItemRef{Channel: channel, Timestamp: timestamp}
} | [
"func",
"NewRefToMessage",
"(",
"channel",
",",
"timestamp",
"string",
")",
"ItemRef",
"{",
"return",
"ItemRef",
"{",
"Channel",
":",
"channel",
",",
"Timestamp",
":",
"timestamp",
"}",
"\n",
"}"
] | // NewRefToMessage initializes a reference to to a message. | [
"NewRefToMessage",
"initializes",
"a",
"reference",
"to",
"to",
"a",
"message",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/item.go#L63-L65 | train |
nlopes/slack | misc.go | postJSON | func postJSON(ctx context.Context, client httpClient, endpoint, token string, json []byte, intf interface{}, d debug) error {
reqBody := bytes.NewBuffer(json)
req, err := http.NewRequest("POST", endpoint, reqBody)
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
return doPost(ctx, client, req, intf, d)
} | go | func postJSON(ctx context.Context, client httpClient, endpoint, token string, json []byte, intf interface{}, d debug) error {
reqBody := bytes.NewBuffer(json)
req, err := http.NewRequest("POST", endpoint, reqBody)
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
return doPost(ctx, client, req, intf, d)
} | [
"func",
"postJSON",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"httpClient",
",",
"endpoint",
",",
"token",
"string",
",",
"json",
"[",
"]",
"byte",
",",
"intf",
"interface",
"{",
"}",
",",
"d",
"debug",
")",
"error",
"{",
"reqBody",
":=",
"bytes",
".",
"NewBuffer",
"(",
"json",
")",
"\n",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"endpoint",
",",
"reqBody",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"req",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"req",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"token",
")",
")",
"\n",
"return",
"doPost",
"(",
"ctx",
",",
"client",
",",
"req",
",",
"intf",
",",
"d",
")",
"\n",
"}"
] | // post JSON. | [
"post",
"JSON",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/misc.go#L210-L219 | train |
nlopes/slack | misc.go | postForm | func postForm(ctx context.Context, client httpClient, endpoint string, values url.Values, intf interface{}, d debug) error {
reqBody := strings.NewReader(values.Encode())
req, err := http.NewRequest("POST", endpoint, reqBody)
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
return doPost(ctx, client, req, intf, d)
} | go | func postForm(ctx context.Context, client httpClient, endpoint string, values url.Values, intf interface{}, d debug) error {
reqBody := strings.NewReader(values.Encode())
req, err := http.NewRequest("POST", endpoint, reqBody)
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
return doPost(ctx, client, req, intf, d)
} | [
"func",
"postForm",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"httpClient",
",",
"endpoint",
"string",
",",
"values",
"url",
".",
"Values",
",",
"intf",
"interface",
"{",
"}",
",",
"d",
"debug",
")",
"error",
"{",
"reqBody",
":=",
"strings",
".",
"NewReader",
"(",
"values",
".",
"Encode",
"(",
")",
")",
"\n",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"endpoint",
",",
"reqBody",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"req",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"doPost",
"(",
"ctx",
",",
"client",
",",
"req",
",",
"intf",
",",
"d",
")",
"\n",
"}"
] | // post a url encoded form. | [
"post",
"a",
"url",
"encoded",
"form",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/misc.go#L222-L230 | train |
nlopes/slack | misc.go | timerReset | func timerReset(t *time.Timer, d time.Duration) {
if !t.Stop() {
<-t.C
}
t.Reset(d)
} | go | func timerReset(t *time.Timer, d time.Duration) {
if !t.Stop() {
<-t.C
}
t.Reset(d)
} | [
"func",
"timerReset",
"(",
"t",
"*",
"time",
".",
"Timer",
",",
"d",
"time",
".",
"Duration",
")",
"{",
"if",
"!",
"t",
".",
"Stop",
"(",
")",
"{",
"<-",
"t",
".",
"C",
"\n",
"}",
"\n",
"t",
".",
"Reset",
"(",
"d",
")",
"\n",
"}"
] | // timerReset safely reset a timer, see time.Timer.Reset for details. | [
"timerReset",
"safely",
"reset",
"a",
"timer",
"see",
"time",
".",
"Timer",
".",
"Reset",
"for",
"details",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/misc.go#L269-L274 | train |
nlopes/slack | dnd.go | EndSnoozeContext | func (api *Client) EndSnoozeContext(ctx context.Context) (*DNDStatus, error) {
values := url.Values{
"token": {api.token},
}
response, err := api.dndRequest(ctx, "dnd.endSnooze", values)
if err != nil {
return nil, err
}
return &response.DNDStatus, nil
} | go | func (api *Client) EndSnoozeContext(ctx context.Context) (*DNDStatus, error) {
values := url.Values{
"token": {api.token},
}
response, err := api.dndRequest(ctx, "dnd.endSnooze", values)
if err != nil {
return nil, err
}
return &response.DNDStatus, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"EndSnoozeContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"DNDStatus",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"dndRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"response",
".",
"DNDStatus",
",",
"nil",
"\n",
"}"
] | // EndSnoozeContext ends the current user's snooze mode with a custom context | [
"EndSnoozeContext",
"ends",
"the",
"current",
"user",
"s",
"snooze",
"mode",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/dnd.go#L74-L84 | train |
nlopes/slack | dnd.go | GetDNDInfo | func (api *Client) GetDNDInfo(user *string) (*DNDStatus, error) {
return api.GetDNDInfoContext(context.Background(), user)
} | go | func (api *Client) GetDNDInfo(user *string) (*DNDStatus, error) {
return api.GetDNDInfoContext(context.Background(), user)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetDNDInfo",
"(",
"user",
"*",
"string",
")",
"(",
"*",
"DNDStatus",
",",
"error",
")",
"{",
"return",
"api",
".",
"GetDNDInfoContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"user",
")",
"\n",
"}"
] | // GetDNDInfo provides information about a user's current Do Not Disturb settings. | [
"GetDNDInfo",
"provides",
"information",
"about",
"a",
"user",
"s",
"current",
"Do",
"Not",
"Disturb",
"settings",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/dnd.go#L87-L89 | train |
nlopes/slack | dnd.go | GetDNDInfoContext | func (api *Client) GetDNDInfoContext(ctx context.Context, user *string) (*DNDStatus, error) {
values := url.Values{
"token": {api.token},
}
if user != nil {
values.Set("user", *user)
}
response, err := api.dndRequest(ctx, "dnd.info", values)
if err != nil {
return nil, err
}
return &response.DNDStatus, nil
} | go | func (api *Client) GetDNDInfoContext(ctx context.Context, user *string) (*DNDStatus, error) {
values := url.Values{
"token": {api.token},
}
if user != nil {
values.Set("user", *user)
}
response, err := api.dndRequest(ctx, "dnd.info", values)
if err != nil {
return nil, err
}
return &response.DNDStatus, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetDNDInfoContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"user",
"*",
"string",
")",
"(",
"*",
"DNDStatus",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"}",
"\n",
"if",
"user",
"!=",
"nil",
"{",
"values",
".",
"Set",
"(",
"\"",
"\"",
",",
"*",
"user",
")",
"\n",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"dndRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"response",
".",
"DNDStatus",
",",
"nil",
"\n",
"}"
] | // GetDNDInfoContext provides information about a user's current Do Not Disturb settings with a custom context. | [
"GetDNDInfoContext",
"provides",
"information",
"about",
"a",
"user",
"s",
"current",
"Do",
"Not",
"Disturb",
"settings",
"with",
"a",
"custom",
"context",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/dnd.go#L92-L105 | train |
nlopes/slack | dnd.go | GetDNDTeamInfo | func (api *Client) GetDNDTeamInfo(users []string) (map[string]DNDStatus, error) {
return api.GetDNDTeamInfoContext(context.Background(), users)
} | go | func (api *Client) GetDNDTeamInfo(users []string) (map[string]DNDStatus, error) {
return api.GetDNDTeamInfoContext(context.Background(), users)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetDNDTeamInfo",
"(",
"users",
"[",
"]",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"DNDStatus",
",",
"error",
")",
"{",
"return",
"api",
".",
"GetDNDTeamInfoContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"users",
")",
"\n",
"}"
] | // GetDNDTeamInfo provides information about a user's current Do Not Disturb settings. | [
"GetDNDTeamInfo",
"provides",
"information",
"about",
"a",
"user",
"s",
"current",
"Do",
"Not",
"Disturb",
"settings",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/dnd.go#L108-L110 | train |
nlopes/slack | dnd.go | GetDNDTeamInfoContext | func (api *Client) GetDNDTeamInfoContext(ctx context.Context, users []string) (map[string]DNDStatus, error) {
values := url.Values{
"token": {api.token},
"users": {strings.Join(users, ",")},
}
response := &dndTeamInfoResponse{}
if err := api.postMethod(ctx, "dnd.teamInfo", values, response); err != nil {
return nil, err
}
if response.Err() != nil {
return nil, response.Err()
}
return response.Users, nil
} | go | func (api *Client) GetDNDTeamInfoContext(ctx context.Context, users []string) (map[string]DNDStatus, error) {
values := url.Values{
"token": {api.token},
"users": {strings.Join(users, ",")},
}
response := &dndTeamInfoResponse{}
if err := api.postMethod(ctx, "dnd.teamInfo", values, response); err != nil {
return nil, err
}
if response.Err() != nil {
return nil, response.Err()
}
return response.Users, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetDNDTeamInfoContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"users",
"[",
"]",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"DNDStatus",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"strings",
".",
"Join",
"(",
"users",
",",
"\"",
"\"",
")",
"}",
",",
"}",
"\n",
"response",
":=",
"&",
"dndTeamInfoResponse",
"{",
"}",
"\n\n",
"if",
"err",
":=",
"api",
".",
"postMethod",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
",",
"response",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"response",
".",
"Err",
"(",
")",
"!=",
"nil",
"{",
"return",
"nil",
",",
"response",
".",
"Err",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"response",
".",
"Users",
",",
"nil",
"\n",
"}"
] | // GetDNDTeamInfoContext provides information about a user's current Do Not Disturb settings with a custom context. | [
"GetDNDTeamInfoContext",
"provides",
"information",
"about",
"a",
"user",
"s",
"current",
"Do",
"Not",
"Disturb",
"settings",
"with",
"a",
"custom",
"context",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/dnd.go#L113-L129 | train |
nlopes/slack | dnd.go | SetSnooze | func (api *Client) SetSnooze(minutes int) (*DNDStatus, error) {
return api.SetSnoozeContext(context.Background(), minutes)
} | go | func (api *Client) SetSnooze(minutes int) (*DNDStatus, error) {
return api.SetSnoozeContext(context.Background(), minutes)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"SetSnooze",
"(",
"minutes",
"int",
")",
"(",
"*",
"DNDStatus",
",",
"error",
")",
"{",
"return",
"api",
".",
"SetSnoozeContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"minutes",
")",
"\n",
"}"
] | // SetSnooze adjusts the snooze duration for a user's Do Not Disturb
// settings. If a snooze session is not already active for the user, invoking
// this method will begin one for the specified duration. | [
"SetSnooze",
"adjusts",
"the",
"snooze",
"duration",
"for",
"a",
"user",
"s",
"Do",
"Not",
"Disturb",
"settings",
".",
"If",
"a",
"snooze",
"session",
"is",
"not",
"already",
"active",
"for",
"the",
"user",
"invoking",
"this",
"method",
"will",
"begin",
"one",
"for",
"the",
"specified",
"duration",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/dnd.go#L134-L136 | train |
nlopes/slack | dnd.go | SetSnoozeContext | func (api *Client) SetSnoozeContext(ctx context.Context, minutes int) (*DNDStatus, error) {
values := url.Values{
"token": {api.token},
"num_minutes": {strconv.Itoa(minutes)},
}
response, err := api.dndRequest(ctx, "dnd.setSnooze", values)
if err != nil {
return nil, err
}
return &response.DNDStatus, nil
} | go | func (api *Client) SetSnoozeContext(ctx context.Context, minutes int) (*DNDStatus, error) {
values := url.Values{
"token": {api.token},
"num_minutes": {strconv.Itoa(minutes)},
}
response, err := api.dndRequest(ctx, "dnd.setSnooze", values)
if err != nil {
return nil, err
}
return &response.DNDStatus, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"SetSnoozeContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"minutes",
"int",
")",
"(",
"*",
"DNDStatus",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"strconv",
".",
"Itoa",
"(",
"minutes",
")",
"}",
",",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"dndRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"response",
".",
"DNDStatus",
",",
"nil",
"\n",
"}"
] | // SetSnoozeContext adjusts the snooze duration for a user's Do Not Disturb settings with a custom context.
// For more information see the SetSnooze docs | [
"SetSnoozeContext",
"adjusts",
"the",
"snooze",
"duration",
"for",
"a",
"user",
"s",
"Do",
"Not",
"Disturb",
"settings",
"with",
"a",
"custom",
"context",
".",
"For",
"more",
"information",
"see",
"the",
"SetSnooze",
"docs"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/dnd.go#L140-L151 | train |
nlopes/slack | backoff.go | Duration | func (b *backoff) Duration() (dur time.Duration) {
// Zero-values are nonsensical, so we use
// them to apply defaults
if b.Max == 0 {
b.Max = 10 * time.Second
}
if b.Initial == 0 {
b.Initial = 100 * time.Millisecond
}
// calculate this duration
if dur = time.Duration(1 << uint(b.attempts)); dur > 0 {
dur = dur * b.Initial
} else {
dur = b.Max
}
if b.Jitter > 0 {
dur = dur + time.Duration(rand.Intn(int(b.Jitter)))
}
// bump attempts count
b.attempts++
return dur
} | go | func (b *backoff) Duration() (dur time.Duration) {
// Zero-values are nonsensical, so we use
// them to apply defaults
if b.Max == 0 {
b.Max = 10 * time.Second
}
if b.Initial == 0 {
b.Initial = 100 * time.Millisecond
}
// calculate this duration
if dur = time.Duration(1 << uint(b.attempts)); dur > 0 {
dur = dur * b.Initial
} else {
dur = b.Max
}
if b.Jitter > 0 {
dur = dur + time.Duration(rand.Intn(int(b.Jitter)))
}
// bump attempts count
b.attempts++
return dur
} | [
"func",
"(",
"b",
"*",
"backoff",
")",
"Duration",
"(",
")",
"(",
"dur",
"time",
".",
"Duration",
")",
"{",
"// Zero-values are nonsensical, so we use",
"// them to apply defaults",
"if",
"b",
".",
"Max",
"==",
"0",
"{",
"b",
".",
"Max",
"=",
"10",
"*",
"time",
".",
"Second",
"\n",
"}",
"\n\n",
"if",
"b",
".",
"Initial",
"==",
"0",
"{",
"b",
".",
"Initial",
"=",
"100",
"*",
"time",
".",
"Millisecond",
"\n",
"}",
"\n\n",
"// calculate this duration",
"if",
"dur",
"=",
"time",
".",
"Duration",
"(",
"1",
"<<",
"uint",
"(",
"b",
".",
"attempts",
")",
")",
";",
"dur",
">",
"0",
"{",
"dur",
"=",
"dur",
"*",
"b",
".",
"Initial",
"\n",
"}",
"else",
"{",
"dur",
"=",
"b",
".",
"Max",
"\n",
"}",
"\n\n",
"if",
"b",
".",
"Jitter",
">",
"0",
"{",
"dur",
"=",
"dur",
"+",
"time",
".",
"Duration",
"(",
"rand",
".",
"Intn",
"(",
"int",
"(",
"b",
".",
"Jitter",
")",
")",
")",
"\n",
"}",
"\n\n",
"// bump attempts count",
"b",
".",
"attempts",
"++",
"\n\n",
"return",
"dur",
"\n",
"}"
] | // Returns the current value of the counter and then multiplies it
// Factor | [
"Returns",
"the",
"current",
"value",
"of",
"the",
"counter",
"and",
"then",
"multiplies",
"it",
"Factor"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/backoff.go#L26-L52 | train |
nlopes/slack | users.go | UnmarshalJSON | func (fields *UserProfileCustomFields) UnmarshalJSON(b []byte) error {
// https://github.com/nlopes/slack/pull/298#discussion_r185159233
if string(b) == "[]" {
return nil
}
return json.Unmarshal(b, &fields.fields)
} | go | func (fields *UserProfileCustomFields) UnmarshalJSON(b []byte) error {
// https://github.com/nlopes/slack/pull/298#discussion_r185159233
if string(b) == "[]" {
return nil
}
return json.Unmarshal(b, &fields.fields)
} | [
"func",
"(",
"fields",
"*",
"UserProfileCustomFields",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"// https://github.com/nlopes/slack/pull/298#discussion_r185159233",
"if",
"string",
"(",
"b",
")",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"json",
".",
"Unmarshal",
"(",
"b",
",",
"&",
"fields",
".",
"fields",
")",
"\n",
"}"
] | // UnmarshalJSON is the implementation of the json.Unmarshaler interface. | [
"UnmarshalJSON",
"is",
"the",
"implementation",
"of",
"the",
"json",
".",
"Unmarshaler",
"interface",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L52-L58 | train |
nlopes/slack | users.go | MarshalJSON | func (fields UserProfileCustomFields) MarshalJSON() ([]byte, error) {
if len(fields.fields) == 0 {
return []byte("[]"), nil
}
return json.Marshal(fields.fields)
} | go | func (fields UserProfileCustomFields) MarshalJSON() ([]byte, error) {
if len(fields.fields) == 0 {
return []byte("[]"), nil
}
return json.Marshal(fields.fields)
} | [
"func",
"(",
"fields",
"UserProfileCustomFields",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"len",
"(",
"fields",
".",
"fields",
")",
"==",
"0",
"{",
"return",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
",",
"nil",
"\n",
"}",
"\n",
"return",
"json",
".",
"Marshal",
"(",
"fields",
".",
"fields",
")",
"\n",
"}"
] | // MarshalJSON is the implementation of the json.Marshaler interface. | [
"MarshalJSON",
"is",
"the",
"implementation",
"of",
"the",
"json",
".",
"Marshaler",
"interface",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L61-L66 | train |
nlopes/slack | users.go | SetFieldsMap | func (profile *UserProfile) SetFieldsMap(m map[string]UserProfileCustomField) {
profile.Fields.SetMap(m)
} | go | func (profile *UserProfile) SetFieldsMap(m map[string]UserProfileCustomField) {
profile.Fields.SetMap(m)
} | [
"func",
"(",
"profile",
"*",
"UserProfile",
")",
"SetFieldsMap",
"(",
"m",
"map",
"[",
"string",
"]",
"UserProfileCustomField",
")",
"{",
"profile",
".",
"Fields",
".",
"SetMap",
"(",
"m",
")",
"\n",
"}"
] | // SetFieldsMap sets a map of custom fields. | [
"SetFieldsMap",
"sets",
"a",
"map",
"of",
"custom",
"fields",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L89-L91 | train |
nlopes/slack | users.go | GetUserPresence | func (api *Client) GetUserPresence(user string) (*UserPresence, error) {
return api.GetUserPresenceContext(context.Background(), user)
} | go | func (api *Client) GetUserPresence(user string) (*UserPresence, error) {
return api.GetUserPresenceContext(context.Background(), user)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetUserPresence",
"(",
"user",
"string",
")",
"(",
"*",
"UserPresence",
",",
"error",
")",
"{",
"return",
"api",
".",
"GetUserPresenceContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"user",
")",
"\n",
"}"
] | // GetUserPresence will retrieve the current presence status of given user. | [
"GetUserPresence",
"will",
"retrieve",
"the",
"current",
"presence",
"status",
"of",
"given",
"user",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L215-L217 | train |
nlopes/slack | users.go | GetUserPresenceContext | func (api *Client) GetUserPresenceContext(ctx context.Context, user string) (*UserPresence, error) {
values := url.Values{
"token": {api.token},
"user": {user},
}
response, err := api.userRequest(ctx, "users.getPresence", values)
if err != nil {
return nil, err
}
return &response.UserPresence, nil
} | go | func (api *Client) GetUserPresenceContext(ctx context.Context, user string) (*UserPresence, error) {
values := url.Values{
"token": {api.token},
"user": {user},
}
response, err := api.userRequest(ctx, "users.getPresence", values)
if err != nil {
return nil, err
}
return &response.UserPresence, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetUserPresenceContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"user",
"string",
")",
"(",
"*",
"UserPresence",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"user",
"}",
",",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"userRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"response",
".",
"UserPresence",
",",
"nil",
"\n",
"}"
] | // GetUserPresenceContext will retrieve the current presence status of given user with a custom context. | [
"GetUserPresenceContext",
"will",
"retrieve",
"the",
"current",
"presence",
"status",
"of",
"given",
"user",
"with",
"a",
"custom",
"context",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L220-L231 | train |
nlopes/slack | users.go | GetUserInfo | func (api *Client) GetUserInfo(user string) (*User, error) {
return api.GetUserInfoContext(context.Background(), user)
} | go | func (api *Client) GetUserInfo(user string) (*User, error) {
return api.GetUserInfoContext(context.Background(), user)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetUserInfo",
"(",
"user",
"string",
")",
"(",
"*",
"User",
",",
"error",
")",
"{",
"return",
"api",
".",
"GetUserInfoContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"user",
")",
"\n",
"}"
] | // GetUserInfo will retrieve the complete user information | [
"GetUserInfo",
"will",
"retrieve",
"the",
"complete",
"user",
"information"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L234-L236 | train |
nlopes/slack | users.go | GetUserInfoContext | func (api *Client) GetUserInfoContext(ctx context.Context, user string) (*User, error) {
values := url.Values{
"token": {api.token},
"user": {user},
"include_locale": {strconv.FormatBool(true)},
}
response, err := api.userRequest(ctx, "users.info", values)
if err != nil {
return nil, err
}
return &response.User, nil
} | go | func (api *Client) GetUserInfoContext(ctx context.Context, user string) (*User, error) {
values := url.Values{
"token": {api.token},
"user": {user},
"include_locale": {strconv.FormatBool(true)},
}
response, err := api.userRequest(ctx, "users.info", values)
if err != nil {
return nil, err
}
return &response.User, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetUserInfoContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"user",
"string",
")",
"(",
"*",
"User",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"user",
"}",
",",
"\"",
"\"",
":",
"{",
"strconv",
".",
"FormatBool",
"(",
"true",
")",
"}",
",",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"userRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"response",
".",
"User",
",",
"nil",
"\n",
"}"
] | // GetUserInfoContext will retrieve the complete user information with a custom context | [
"GetUserInfoContext",
"will",
"retrieve",
"the",
"complete",
"user",
"information",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L239-L251 | train |
nlopes/slack | users.go | Failure | func (t UserPagination) Failure(err error) error {
if t.Done(err) {
return nil
}
return err
} | go | func (t UserPagination) Failure(err error) error {
if t.Done(err) {
return nil
}
return err
} | [
"func",
"(",
"t",
"UserPagination",
")",
"Failure",
"(",
"err",
"error",
")",
"error",
"{",
"if",
"t",
".",
"Done",
"(",
"err",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}"
] | // Failure checks if pagination failed. | [
"Failure",
"checks",
"if",
"pagination",
"failed",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L298-L304 | train |
nlopes/slack | users.go | GetUserByEmail | func (api *Client) GetUserByEmail(email string) (*User, error) {
return api.GetUserByEmailContext(context.Background(), email)
} | go | func (api *Client) GetUserByEmail(email string) (*User, error) {
return api.GetUserByEmailContext(context.Background(), email)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetUserByEmail",
"(",
"email",
"string",
")",
"(",
"*",
"User",
",",
"error",
")",
"{",
"return",
"api",
".",
"GetUserByEmailContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"email",
")",
"\n",
"}"
] | // GetUserByEmail will retrieve the complete user information by email | [
"GetUserByEmail",
"will",
"retrieve",
"the",
"complete",
"user",
"information",
"by",
"email"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L360-L362 | train |
nlopes/slack | users.go | GetUserByEmailContext | func (api *Client) GetUserByEmailContext(ctx context.Context, email string) (*User, error) {
values := url.Values{
"token": {api.token},
"email": {email},
}
response, err := api.userRequest(ctx, "users.lookupByEmail", values)
if err != nil {
return nil, err
}
return &response.User, nil
} | go | func (api *Client) GetUserByEmailContext(ctx context.Context, email string) (*User, error) {
values := url.Values{
"token": {api.token},
"email": {email},
}
response, err := api.userRequest(ctx, "users.lookupByEmail", values)
if err != nil {
return nil, err
}
return &response.User, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetUserByEmailContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"email",
"string",
")",
"(",
"*",
"User",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"email",
"}",
",",
"}",
"\n",
"response",
",",
"err",
":=",
"api",
".",
"userRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"response",
".",
"User",
",",
"nil",
"\n",
"}"
] | // GetUserByEmailContext will retrieve the complete user information by email with a custom context | [
"GetUserByEmailContext",
"will",
"retrieve",
"the",
"complete",
"user",
"information",
"by",
"email",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L365-L375 | train |
nlopes/slack | users.go | SetUserAsActiveContext | func (api *Client) SetUserAsActiveContext(ctx context.Context) (err error) {
values := url.Values{
"token": {api.token},
}
_, err = api.userRequest(ctx, "users.setActive", values)
return err
} | go | func (api *Client) SetUserAsActiveContext(ctx context.Context) (err error) {
values := url.Values{
"token": {api.token},
}
_, err = api.userRequest(ctx, "users.setActive", values)
return err
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"SetUserAsActiveContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"}",
"\n\n",
"_",
",",
"err",
"=",
"api",
".",
"userRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // SetUserAsActiveContext marks the currently authenticated user as active with a custom context | [
"SetUserAsActiveContext",
"marks",
"the",
"currently",
"authenticated",
"user",
"as",
"active",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L383-L390 | train |
nlopes/slack | users.go | SetUserPresence | func (api *Client) SetUserPresence(presence string) error {
return api.SetUserPresenceContext(context.Background(), presence)
} | go | func (api *Client) SetUserPresence(presence string) error {
return api.SetUserPresenceContext(context.Background(), presence)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"SetUserPresence",
"(",
"presence",
"string",
")",
"error",
"{",
"return",
"api",
".",
"SetUserPresenceContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"presence",
")",
"\n",
"}"
] | // SetUserPresence changes the currently authenticated user presence | [
"SetUserPresence",
"changes",
"the",
"currently",
"authenticated",
"user",
"presence"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L393-L395 | train |
nlopes/slack | users.go | SetUserPresenceContext | func (api *Client) SetUserPresenceContext(ctx context.Context, presence string) error {
values := url.Values{
"token": {api.token},
"presence": {presence},
}
_, err := api.userRequest(ctx, "users.setPresence", values)
return err
} | go | func (api *Client) SetUserPresenceContext(ctx context.Context, presence string) error {
values := url.Values{
"token": {api.token},
"presence": {presence},
}
_, err := api.userRequest(ctx, "users.setPresence", values)
return err
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"SetUserPresenceContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"presence",
"string",
")",
"error",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"presence",
"}",
",",
"}",
"\n\n",
"_",
",",
"err",
":=",
"api",
".",
"userRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // SetUserPresenceContext changes the currently authenticated user presence with a custom context | [
"SetUserPresenceContext",
"changes",
"the",
"currently",
"authenticated",
"user",
"presence",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L398-L406 | train |
nlopes/slack | users.go | GetUserIdentityContext | func (api *Client) GetUserIdentityContext(ctx context.Context) (*UserIdentityResponse, error) {
values := url.Values{
"token": {api.token},
}
response := &UserIdentityResponse{}
err := api.postMethod(ctx, "users.identity", values, response)
if err != nil {
return nil, err
}
if err := response.Err(); err != nil {
return nil, err
}
return response, nil
} | go | func (api *Client) GetUserIdentityContext(ctx context.Context) (*UserIdentityResponse, error) {
values := url.Values{
"token": {api.token},
}
response := &UserIdentityResponse{}
err := api.postMethod(ctx, "users.identity", values, response)
if err != nil {
return nil, err
}
if err := response.Err(); err != nil {
return nil, err
}
return response, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetUserIdentityContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"UserIdentityResponse",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"}",
"\n",
"response",
":=",
"&",
"UserIdentityResponse",
"{",
"}",
"\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",
",",
"nil",
"\n",
"}"
] | // GetUserIdentityContext will retrieve user info available per identity scopes with a custom context | [
"GetUserIdentityContext",
"will",
"retrieve",
"user",
"info",
"available",
"per",
"identity",
"scopes",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L414-L430 | train |
nlopes/slack | users.go | SetUserPhoto | func (api *Client) SetUserPhoto(image string, params UserSetPhotoParams) error {
return api.SetUserPhotoContext(context.Background(), image, params)
} | go | func (api *Client) SetUserPhoto(image string, params UserSetPhotoParams) error {
return api.SetUserPhotoContext(context.Background(), image, params)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"SetUserPhoto",
"(",
"image",
"string",
",",
"params",
"UserSetPhotoParams",
")",
"error",
"{",
"return",
"api",
".",
"SetUserPhotoContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"image",
",",
"params",
")",
"\n",
"}"
] | // SetUserPhoto changes the currently authenticated user's profile image | [
"SetUserPhoto",
"changes",
"the",
"currently",
"authenticated",
"user",
"s",
"profile",
"image"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L433-L435 | train |
nlopes/slack | users.go | SetUserPhotoContext | func (api *Client) SetUserPhotoContext(ctx context.Context, image string, params UserSetPhotoParams) error {
response := &SlackResponse{}
values := url.Values{
"token": {api.token},
}
if params.CropX != DEFAULT_USER_PHOTO_CROP_X {
values.Add("crop_x", strconv.Itoa(params.CropX))
}
if params.CropY != DEFAULT_USER_PHOTO_CROP_Y {
values.Add("crop_y", strconv.Itoa(params.CropX))
}
if params.CropW != DEFAULT_USER_PHOTO_CROP_W {
values.Add("crop_w", strconv.Itoa(params.CropW))
}
err := postLocalWithMultipartResponse(ctx, api.httpclient, api.endpoint+"users.setPhoto", image, "image", values, response, api)
if err != nil {
return err
}
return response.Err()
} | go | func (api *Client) SetUserPhotoContext(ctx context.Context, image string, params UserSetPhotoParams) error {
response := &SlackResponse{}
values := url.Values{
"token": {api.token},
}
if params.CropX != DEFAULT_USER_PHOTO_CROP_X {
values.Add("crop_x", strconv.Itoa(params.CropX))
}
if params.CropY != DEFAULT_USER_PHOTO_CROP_Y {
values.Add("crop_y", strconv.Itoa(params.CropX))
}
if params.CropW != DEFAULT_USER_PHOTO_CROP_W {
values.Add("crop_w", strconv.Itoa(params.CropW))
}
err := postLocalWithMultipartResponse(ctx, api.httpclient, api.endpoint+"users.setPhoto", image, "image", values, response, api)
if err != nil {
return err
}
return response.Err()
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"SetUserPhotoContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"image",
"string",
",",
"params",
"UserSetPhotoParams",
")",
"error",
"{",
"response",
":=",
"&",
"SlackResponse",
"{",
"}",
"\n",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"}",
"\n",
"if",
"params",
".",
"CropX",
"!=",
"DEFAULT_USER_PHOTO_CROP_X",
"{",
"values",
".",
"Add",
"(",
"\"",
"\"",
",",
"strconv",
".",
"Itoa",
"(",
"params",
".",
"CropX",
")",
")",
"\n",
"}",
"\n",
"if",
"params",
".",
"CropY",
"!=",
"DEFAULT_USER_PHOTO_CROP_Y",
"{",
"values",
".",
"Add",
"(",
"\"",
"\"",
",",
"strconv",
".",
"Itoa",
"(",
"params",
".",
"CropX",
")",
")",
"\n",
"}",
"\n",
"if",
"params",
".",
"CropW",
"!=",
"DEFAULT_USER_PHOTO_CROP_W",
"{",
"values",
".",
"Add",
"(",
"\"",
"\"",
",",
"strconv",
".",
"Itoa",
"(",
"params",
".",
"CropW",
")",
")",
"\n",
"}",
"\n\n",
"err",
":=",
"postLocalWithMultipartResponse",
"(",
"ctx",
",",
"api",
".",
"httpclient",
",",
"api",
".",
"endpoint",
"+",
"\"",
"\"",
",",
"image",
",",
"\"",
"\"",
",",
"values",
",",
"response",
",",
"api",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"response",
".",
"Err",
"(",
")",
"\n",
"}"
] | // SetUserPhotoContext changes the currently authenticated user's profile image using a custom context | [
"SetUserPhotoContext",
"changes",
"the",
"currently",
"authenticated",
"user",
"s",
"profile",
"image",
"using",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L438-L459 | train |
nlopes/slack | users.go | SetUserCustomStatusContext | func (api *Client) SetUserCustomStatusContext(ctx context.Context, statusText, statusEmoji string, statusExpiration int64) error {
// XXX(theckman): this anonymous struct is for making requests to the Slack
// API for setting and unsetting a User's Custom Status/Emoji. To change
// these values we must provide a JSON document as the profile POST field.
//
// We use an anonymous struct over UserProfile because to unset the values
// on the User's profile we cannot use the `json:"omitempty"` tag. This is
// because an empty string ("") is what's used to unset the values. Check
// out the API docs for more details:
//
// - https://api.slack.com/docs/presence-and-status#custom_status
profile, err := json.Marshal(
&struct {
StatusText string `json:"status_text"`
StatusEmoji string `json:"status_emoji"`
StatusExpiration int64 `json:"status_expiration"`
}{
StatusText: statusText,
StatusEmoji: statusEmoji,
StatusExpiration: statusExpiration,
},
)
if err != nil {
return err
}
values := url.Values{
"token": {api.token},
"profile": {string(profile)},
}
response := &userResponseFull{}
if err = api.postMethod(ctx, "users.profile.set", values, response); err != nil {
return err
}
return response.Err()
} | go | func (api *Client) SetUserCustomStatusContext(ctx context.Context, statusText, statusEmoji string, statusExpiration int64) error {
// XXX(theckman): this anonymous struct is for making requests to the Slack
// API for setting and unsetting a User's Custom Status/Emoji. To change
// these values we must provide a JSON document as the profile POST field.
//
// We use an anonymous struct over UserProfile because to unset the values
// on the User's profile we cannot use the `json:"omitempty"` tag. This is
// because an empty string ("") is what's used to unset the values. Check
// out the API docs for more details:
//
// - https://api.slack.com/docs/presence-and-status#custom_status
profile, err := json.Marshal(
&struct {
StatusText string `json:"status_text"`
StatusEmoji string `json:"status_emoji"`
StatusExpiration int64 `json:"status_expiration"`
}{
StatusText: statusText,
StatusEmoji: statusEmoji,
StatusExpiration: statusExpiration,
},
)
if err != nil {
return err
}
values := url.Values{
"token": {api.token},
"profile": {string(profile)},
}
response := &userResponseFull{}
if err = api.postMethod(ctx, "users.profile.set", values, response); err != nil {
return err
}
return response.Err()
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"SetUserCustomStatusContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"statusText",
",",
"statusEmoji",
"string",
",",
"statusExpiration",
"int64",
")",
"error",
"{",
"// XXX(theckman): this anonymous struct is for making requests to the Slack",
"// API for setting and unsetting a User's Custom Status/Emoji. To change",
"// these values we must provide a JSON document as the profile POST field.",
"//",
"// We use an anonymous struct over UserProfile because to unset the values",
"// on the User's profile we cannot use the `json:\"omitempty\"` tag. This is",
"// because an empty string (\"\") is what's used to unset the values. Check",
"// out the API docs for more details:",
"//",
"// - https://api.slack.com/docs/presence-and-status#custom_status",
"profile",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"&",
"struct",
"{",
"StatusText",
"string",
"`json:\"status_text\"`",
"\n",
"StatusEmoji",
"string",
"`json:\"status_emoji\"`",
"\n",
"StatusExpiration",
"int64",
"`json:\"status_expiration\"`",
"\n",
"}",
"{",
"StatusText",
":",
"statusText",
",",
"StatusEmoji",
":",
"statusEmoji",
",",
"StatusExpiration",
":",
"statusExpiration",
",",
"}",
",",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"string",
"(",
"profile",
")",
"}",
",",
"}",
"\n\n",
"response",
":=",
"&",
"userResponseFull",
"{",
"}",
"\n",
"if",
"err",
"=",
"api",
".",
"postMethod",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
",",
"response",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"response",
".",
"Err",
"(",
")",
"\n",
"}"
] | // SetUserCustomStatusContext will set a custom status and emoji for the currently authenticated user with a custom context
//
// For more information see SetUserCustomStatus | [
"SetUserCustomStatusContext",
"will",
"set",
"a",
"custom",
"status",
"and",
"emoji",
"for",
"the",
"currently",
"authenticated",
"user",
"with",
"a",
"custom",
"context",
"For",
"more",
"information",
"see",
"SetUserCustomStatus"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L493-L531 | train |
nlopes/slack | users.go | GetUserProfile | func (api *Client) GetUserProfile(userID string, includeLabels bool) (*UserProfile, error) {
return api.GetUserProfileContext(context.Background(), userID, includeLabels)
} | go | func (api *Client) GetUserProfile(userID string, includeLabels bool) (*UserProfile, error) {
return api.GetUserProfileContext(context.Background(), userID, includeLabels)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetUserProfile",
"(",
"userID",
"string",
",",
"includeLabels",
"bool",
")",
"(",
"*",
"UserProfile",
",",
"error",
")",
"{",
"return",
"api",
".",
"GetUserProfileContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"userID",
",",
"includeLabels",
")",
"\n",
"}"
] | // GetUserProfile retrieves a user's profile information. | [
"GetUserProfile",
"retrieves",
"a",
"user",
"s",
"profile",
"information",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L546-L548 | train |
nlopes/slack | users.go | GetUserProfileContext | func (api *Client) GetUserProfileContext(ctx context.Context, userID string, includeLabels bool) (*UserProfile, error) {
values := url.Values{"token": {api.token}, "user": {userID}}
if includeLabels {
values.Add("include_labels", "true")
}
resp := &getUserProfileResponse{}
err := api.postMethod(ctx, "users.profile.get", values, &resp)
if err != nil {
return nil, err
}
if err := resp.Err(); err != nil {
return nil, err
}
return resp.Profile, nil
} | go | func (api *Client) GetUserProfileContext(ctx context.Context, userID string, includeLabels bool) (*UserProfile, error) {
values := url.Values{"token": {api.token}, "user": {userID}}
if includeLabels {
values.Add("include_labels", "true")
}
resp := &getUserProfileResponse{}
err := api.postMethod(ctx, "users.profile.get", values, &resp)
if err != nil {
return nil, err
}
if err := resp.Err(); err != nil {
return nil, err
}
return resp.Profile, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetUserProfileContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"userID",
"string",
",",
"includeLabels",
"bool",
")",
"(",
"*",
"UserProfile",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"userID",
"}",
"}",
"\n",
"if",
"includeLabels",
"{",
"values",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"resp",
":=",
"&",
"getUserProfileResponse",
"{",
"}",
"\n\n",
"err",
":=",
"api",
".",
"postMethod",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
",",
"&",
"resp",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"resp",
".",
"Err",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"resp",
".",
"Profile",
",",
"nil",
"\n",
"}"
] | // GetUserProfileContext retrieves a user's profile information with a context. | [
"GetUserProfileContext",
"retrieves",
"a",
"user",
"s",
"profile",
"information",
"with",
"a",
"context",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/users.go#L556-L573 | train |
nlopes/slack | bots.go | GetBotInfo | func (api *Client) GetBotInfo(bot string) (*Bot, error) {
return api.GetBotInfoContext(context.Background(), bot)
} | go | func (api *Client) GetBotInfo(bot string) (*Bot, error) {
return api.GetBotInfoContext(context.Background(), bot)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetBotInfo",
"(",
"bot",
"string",
")",
"(",
"*",
"Bot",
",",
"error",
")",
"{",
"return",
"api",
".",
"GetBotInfoContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"bot",
")",
"\n",
"}"
] | // GetBotInfo will retrieve the complete bot information | [
"GetBotInfo",
"will",
"retrieve",
"the",
"complete",
"bot",
"information"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/bots.go#L36-L38 | train |
nlopes/slack | bots.go | GetBotInfoContext | func (api *Client) GetBotInfoContext(ctx context.Context, bot string) (*Bot, error) {
values := url.Values{
"token": {api.token},
"bot": {bot},
}
response, err := api.botRequest(ctx, "bots.info", values)
if err != nil {
return nil, err
}
return &response.Bot, nil
} | go | func (api *Client) GetBotInfoContext(ctx context.Context, bot string) (*Bot, error) {
values := url.Values{
"token": {api.token},
"bot": {bot},
}
response, err := api.botRequest(ctx, "bots.info", values)
if err != nil {
return nil, err
}
return &response.Bot, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetBotInfoContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"bot",
"string",
")",
"(",
"*",
"Bot",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"bot",
"}",
",",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"botRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"response",
".",
"Bot",
",",
"nil",
"\n",
"}"
] | // GetBotInfoContext will retrieve the complete bot information using a custom context | [
"GetBotInfoContext",
"will",
"retrieve",
"the",
"complete",
"bot",
"information",
"using",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/bots.go#L41-L52 | train |
nlopes/slack | oauth.go | GetOAuthToken | func GetOAuthToken(client httpClient, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, err error) {
return GetOAuthTokenContext(context.Background(), client, clientID, clientSecret, code, redirectURI)
} | go | func GetOAuthToken(client httpClient, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, err error) {
return GetOAuthTokenContext(context.Background(), client, clientID, clientSecret, code, redirectURI)
} | [
"func",
"GetOAuthToken",
"(",
"client",
"httpClient",
",",
"clientID",
",",
"clientSecret",
",",
"code",
",",
"redirectURI",
"string",
")",
"(",
"accessToken",
"string",
",",
"scope",
"string",
",",
"err",
"error",
")",
"{",
"return",
"GetOAuthTokenContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"client",
",",
"clientID",
",",
"clientSecret",
",",
"code",
",",
"redirectURI",
")",
"\n",
"}"
] | // GetOAuthToken retrieves an AccessToken | [
"GetOAuthToken",
"retrieves",
"an",
"AccessToken"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/oauth.go#L35-L37 | train |
nlopes/slack | oauth.go | GetOAuthTokenContext | func GetOAuthTokenContext(ctx context.Context, client httpClient, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, err error) {
response, err := GetOAuthResponseContext(ctx, client, clientID, clientSecret, code, redirectURI)
if err != nil {
return "", "", err
}
return response.AccessToken, response.Scope, nil
} | go | func GetOAuthTokenContext(ctx context.Context, client httpClient, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, err error) {
response, err := GetOAuthResponseContext(ctx, client, clientID, clientSecret, code, redirectURI)
if err != nil {
return "", "", err
}
return response.AccessToken, response.Scope, nil
} | [
"func",
"GetOAuthTokenContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"httpClient",
",",
"clientID",
",",
"clientSecret",
",",
"code",
",",
"redirectURI",
"string",
")",
"(",
"accessToken",
"string",
",",
"scope",
"string",
",",
"err",
"error",
")",
"{",
"response",
",",
"err",
":=",
"GetOAuthResponseContext",
"(",
"ctx",
",",
"client",
",",
"clientID",
",",
"clientSecret",
",",
"code",
",",
"redirectURI",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"response",
".",
"AccessToken",
",",
"response",
".",
"Scope",
",",
"nil",
"\n",
"}"
] | // GetOAuthTokenContext retrieves an AccessToken with a custom context | [
"GetOAuthTokenContext",
"retrieves",
"an",
"AccessToken",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/oauth.go#L40-L46 | train |
nlopes/slack | block_context.go | NewContextBlock | func NewContextBlock(blockID string, elements ...BlockObject) *ContextBlock {
return &ContextBlock{
Type: mbtContext,
BlockID: blockID,
Elements: elements,
}
} | go | func NewContextBlock(blockID string, elements ...BlockObject) *ContextBlock {
return &ContextBlock{
Type: mbtContext,
BlockID: blockID,
Elements: elements,
}
} | [
"func",
"NewContextBlock",
"(",
"blockID",
"string",
",",
"elements",
"...",
"BlockObject",
")",
"*",
"ContextBlock",
"{",
"return",
"&",
"ContextBlock",
"{",
"Type",
":",
"mbtContext",
",",
"BlockID",
":",
"blockID",
",",
"Elements",
":",
"elements",
",",
"}",
"\n",
"}"
] | // NewContextBlock returns a newinstance of a context block | [
"NewContextBlock",
"returns",
"a",
"newinstance",
"of",
"a",
"context",
"block"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/block_context.go#L19-L25 | train |
nlopes/slack | groups.go | ArchiveGroup | func (api *Client) ArchiveGroup(group string) error {
return api.ArchiveGroupContext(context.Background(), group)
} | go | func (api *Client) ArchiveGroup(group string) error {
return api.ArchiveGroupContext(context.Background(), group)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"ArchiveGroup",
"(",
"group",
"string",
")",
"error",
"{",
"return",
"api",
".",
"ArchiveGroupContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"group",
")",
"\n",
"}"
] | // ArchiveGroup archives a private group | [
"ArchiveGroup",
"archives",
"a",
"private",
"group"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L41-L43 | train |
nlopes/slack | groups.go | ArchiveGroupContext | func (api *Client) ArchiveGroupContext(ctx context.Context, group string) error {
values := url.Values{
"token": {api.token},
"channel": {group},
}
_, err := api.groupRequest(ctx, "groups.archive", values)
return err
} | go | func (api *Client) ArchiveGroupContext(ctx context.Context, group string) error {
values := url.Values{
"token": {api.token},
"channel": {group},
}
_, err := api.groupRequest(ctx, "groups.archive", values)
return err
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"ArchiveGroupContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"group",
"string",
")",
"error",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"group",
"}",
",",
"}",
"\n\n",
"_",
",",
"err",
":=",
"api",
".",
"groupRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // ArchiveGroupContext archives a private group | [
"ArchiveGroupContext",
"archives",
"a",
"private",
"group"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L46-L54 | train |
nlopes/slack | groups.go | UnarchiveGroup | func (api *Client) UnarchiveGroup(group string) error {
return api.UnarchiveGroupContext(context.Background(), group)
} | go | func (api *Client) UnarchiveGroup(group string) error {
return api.UnarchiveGroupContext(context.Background(), group)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"UnarchiveGroup",
"(",
"group",
"string",
")",
"error",
"{",
"return",
"api",
".",
"UnarchiveGroupContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"group",
")",
"\n",
"}"
] | // UnarchiveGroup unarchives a private group | [
"UnarchiveGroup",
"unarchives",
"a",
"private",
"group"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L57-L59 | train |
nlopes/slack | groups.go | CreateGroup | func (api *Client) CreateGroup(group string) (*Group, error) {
return api.CreateGroupContext(context.Background(), group)
} | go | func (api *Client) CreateGroup(group string) (*Group, error) {
return api.CreateGroupContext(context.Background(), group)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"CreateGroup",
"(",
"group",
"string",
")",
"(",
"*",
"Group",
",",
"error",
")",
"{",
"return",
"api",
".",
"CreateGroupContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"group",
")",
"\n",
"}"
] | // CreateGroup creates a private group | [
"CreateGroup",
"creates",
"a",
"private",
"group"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L73-L75 | train |
nlopes/slack | groups.go | CreateGroupContext | func (api *Client) CreateGroupContext(ctx context.Context, group string) (*Group, error) {
values := url.Values{
"token": {api.token},
"name": {group},
}
response, err := api.groupRequest(ctx, "groups.create", values)
if err != nil {
return nil, err
}
return &response.Group, nil
} | go | func (api *Client) CreateGroupContext(ctx context.Context, group string) (*Group, error) {
values := url.Values{
"token": {api.token},
"name": {group},
}
response, err := api.groupRequest(ctx, "groups.create", values)
if err != nil {
return nil, err
}
return &response.Group, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"CreateGroupContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"group",
"string",
")",
"(",
"*",
"Group",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"group",
"}",
",",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"groupRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"response",
".",
"Group",
",",
"nil",
"\n",
"}"
] | // CreateGroupContext creates a private group | [
"CreateGroupContext",
"creates",
"a",
"private",
"group"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L78-L89 | train |
nlopes/slack | groups.go | GetGroupHistory | func (api *Client) GetGroupHistory(group string, params HistoryParameters) (*History, error) {
return api.GetGroupHistoryContext(context.Background(), group, params)
} | go | func (api *Client) GetGroupHistory(group string, params HistoryParameters) (*History, error) {
return api.GetGroupHistoryContext(context.Background(), group, params)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetGroupHistory",
"(",
"group",
"string",
",",
"params",
"HistoryParameters",
")",
"(",
"*",
"History",
",",
"error",
")",
"{",
"return",
"api",
".",
"GetGroupHistoryContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"group",
",",
"params",
")",
"\n",
"}"
] | // GetGroupHistory fetches all the history for a private group | [
"GetGroupHistory",
"fetches",
"all",
"the",
"history",
"for",
"a",
"private",
"group"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L117-L119 | train |
nlopes/slack | groups.go | InviteUserToGroup | func (api *Client) InviteUserToGroup(group, user string) (*Group, bool, error) {
return api.InviteUserToGroupContext(context.Background(), group, user)
} | go | func (api *Client) InviteUserToGroup(group, user string) (*Group, bool, error) {
return api.InviteUserToGroupContext(context.Background(), group, user)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"InviteUserToGroup",
"(",
"group",
",",
"user",
"string",
")",
"(",
"*",
"Group",
",",
"bool",
",",
"error",
")",
"{",
"return",
"api",
".",
"InviteUserToGroupContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"group",
",",
"user",
")",
"\n",
"}"
] | // InviteUserToGroup invites a specific user to a private group | [
"InviteUserToGroup",
"invites",
"a",
"specific",
"user",
"to",
"a",
"private",
"group"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L159-L161 | train |
nlopes/slack | groups.go | InviteUserToGroupContext | func (api *Client) InviteUserToGroupContext(ctx context.Context, group, user string) (*Group, bool, error) {
values := url.Values{
"token": {api.token},
"channel": {group},
"user": {user},
}
response, err := api.groupRequest(ctx, "groups.invite", values)
if err != nil {
return nil, false, err
}
return &response.Group, response.AlreadyInGroup, nil
} | go | func (api *Client) InviteUserToGroupContext(ctx context.Context, group, user string) (*Group, bool, error) {
values := url.Values{
"token": {api.token},
"channel": {group},
"user": {user},
}
response, err := api.groupRequest(ctx, "groups.invite", values)
if err != nil {
return nil, false, err
}
return &response.Group, response.AlreadyInGroup, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"InviteUserToGroupContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"group",
",",
"user",
"string",
")",
"(",
"*",
"Group",
",",
"bool",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"group",
"}",
",",
"\"",
"\"",
":",
"{",
"user",
"}",
",",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"groupRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"false",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"response",
".",
"Group",
",",
"response",
".",
"AlreadyInGroup",
",",
"nil",
"\n",
"}"
] | // InviteUserToGroupContext invites a specific user to a private group with a custom context | [
"InviteUserToGroupContext",
"invites",
"a",
"specific",
"user",
"to",
"a",
"private",
"group",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L164-L176 | train |
nlopes/slack | groups.go | LeaveGroup | func (api *Client) LeaveGroup(group string) error {
return api.LeaveGroupContext(context.Background(), group)
} | go | func (api *Client) LeaveGroup(group string) error {
return api.LeaveGroupContext(context.Background(), group)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"LeaveGroup",
"(",
"group",
"string",
")",
"error",
"{",
"return",
"api",
".",
"LeaveGroupContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"group",
")",
"\n",
"}"
] | // LeaveGroup makes authenticated user leave the group | [
"LeaveGroup",
"makes",
"authenticated",
"user",
"leave",
"the",
"group"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L179-L181 | train |
nlopes/slack | groups.go | KickUserFromGroup | func (api *Client) KickUserFromGroup(group, user string) error {
return api.KickUserFromGroupContext(context.Background(), group, user)
} | go | func (api *Client) KickUserFromGroup(group, user string) error {
return api.KickUserFromGroupContext(context.Background(), group, user)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"KickUserFromGroup",
"(",
"group",
",",
"user",
"string",
")",
"error",
"{",
"return",
"api",
".",
"KickUserFromGroupContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"group",
",",
"user",
")",
"\n",
"}"
] | // KickUserFromGroup kicks a user from a group | [
"KickUserFromGroup",
"kicks",
"a",
"user",
"from",
"a",
"group"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L195-L197 | train |
nlopes/slack | groups.go | GetGroupsContext | func (api *Client) GetGroupsContext(ctx context.Context, excludeArchived bool) ([]Group, error) {
values := url.Values{
"token": {api.token},
}
if excludeArchived {
values.Add("exclude_archived", "1")
}
response, err := api.groupRequest(ctx, "groups.list", values)
if err != nil {
return nil, err
}
return response.Groups, nil
} | go | func (api *Client) GetGroupsContext(ctx context.Context, excludeArchived bool) ([]Group, error) {
values := url.Values{
"token": {api.token},
}
if excludeArchived {
values.Add("exclude_archived", "1")
}
response, err := api.groupRequest(ctx, "groups.list", values)
if err != nil {
return nil, err
}
return response.Groups, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetGroupsContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"excludeArchived",
"bool",
")",
"(",
"[",
"]",
"Group",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"}",
"\n",
"if",
"excludeArchived",
"{",
"values",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"groupRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"response",
".",
"Groups",
",",
"nil",
"\n",
"}"
] | // GetGroupsContext retrieves all groups with a custom context | [
"GetGroupsContext",
"retrieves",
"all",
"groups",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L217-L230 | train |
nlopes/slack | groups.go | GetGroupInfo | func (api *Client) GetGroupInfo(group string) (*Group, error) {
return api.GetGroupInfoContext(context.Background(), group)
} | go | func (api *Client) GetGroupInfo(group string) (*Group, error) {
return api.GetGroupInfoContext(context.Background(), group)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetGroupInfo",
"(",
"group",
"string",
")",
"(",
"*",
"Group",
",",
"error",
")",
"{",
"return",
"api",
".",
"GetGroupInfoContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"group",
")",
"\n",
"}"
] | // GetGroupInfo retrieves the given group | [
"GetGroupInfo",
"retrieves",
"the",
"given",
"group"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L233-L235 | train |
nlopes/slack | groups.go | GetGroupInfoContext | func (api *Client) GetGroupInfoContext(ctx context.Context, group string) (*Group, error) {
values := url.Values{
"token": {api.token},
"channel": {group},
"include_locale": {strconv.FormatBool(true)},
}
response, err := api.groupRequest(ctx, "groups.info", values)
if err != nil {
return nil, err
}
return &response.Group, nil
} | go | func (api *Client) GetGroupInfoContext(ctx context.Context, group string) (*Group, error) {
values := url.Values{
"token": {api.token},
"channel": {group},
"include_locale": {strconv.FormatBool(true)},
}
response, err := api.groupRequest(ctx, "groups.info", values)
if err != nil {
return nil, err
}
return &response.Group, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetGroupInfoContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"group",
"string",
")",
"(",
"*",
"Group",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"group",
"}",
",",
"\"",
"\"",
":",
"{",
"strconv",
".",
"FormatBool",
"(",
"true",
")",
"}",
",",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"groupRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"response",
".",
"Group",
",",
"nil",
"\n",
"}"
] | // GetGroupInfoContext retrieves the given group with a custom context | [
"GetGroupInfoContext",
"retrieves",
"the",
"given",
"group",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L238-L250 | train |
nlopes/slack | groups.go | OpenGroup | func (api *Client) OpenGroup(group string) (bool, bool, error) {
return api.OpenGroupContext(context.Background(), group)
} | go | func (api *Client) OpenGroup(group string) (bool, bool, error) {
return api.OpenGroupContext(context.Background(), group)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"OpenGroup",
"(",
"group",
"string",
")",
"(",
"bool",
",",
"bool",
",",
"error",
")",
"{",
"return",
"api",
".",
"OpenGroupContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"group",
")",
"\n",
"}"
] | // OpenGroup opens a private group | [
"OpenGroup",
"opens",
"a",
"private",
"group"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L275-L277 | train |
nlopes/slack | groups.go | OpenGroupContext | func (api *Client) OpenGroupContext(ctx context.Context, group string) (bool, bool, error) {
values := url.Values{
"token": {api.token},
"channel": {group},
}
response, err := api.groupRequest(ctx, "groups.open", values)
if err != nil {
return false, false, err
}
return response.NoOp, response.AlreadyOpen, nil
} | go | func (api *Client) OpenGroupContext(ctx context.Context, group string) (bool, bool, error) {
values := url.Values{
"token": {api.token},
"channel": {group},
}
response, err := api.groupRequest(ctx, "groups.open", values)
if err != nil {
return false, false, err
}
return response.NoOp, response.AlreadyOpen, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"OpenGroupContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"group",
"string",
")",
"(",
"bool",
",",
"bool",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"group",
"}",
",",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"groupRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"false",
",",
"err",
"\n",
"}",
"\n",
"return",
"response",
".",
"NoOp",
",",
"response",
".",
"AlreadyOpen",
",",
"nil",
"\n",
"}"
] | // OpenGroupContext opens a private group with a custom context | [
"OpenGroupContext",
"opens",
"a",
"private",
"group",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L280-L291 | train |
nlopes/slack | groups.go | RenameGroupContext | func (api *Client) RenameGroupContext(ctx context.Context, group, name string) (*Channel, error) {
values := url.Values{
"token": {api.token},
"channel": {group},
"name": {name},
}
// XXX: the created entry in this call returns a string instead of a number
// so I may have to do some workaround to solve it.
response, err := api.groupRequest(ctx, "groups.rename", values)
if err != nil {
return nil, err
}
return &response.Channel, nil
} | go | func (api *Client) RenameGroupContext(ctx context.Context, group, name string) (*Channel, error) {
values := url.Values{
"token": {api.token},
"channel": {group},
"name": {name},
}
// XXX: the created entry in this call returns a string instead of a number
// so I may have to do some workaround to solve it.
response, err := api.groupRequest(ctx, "groups.rename", values)
if err != nil {
return nil, err
}
return &response.Channel, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"RenameGroupContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"group",
",",
"name",
"string",
")",
"(",
"*",
"Channel",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"group",
"}",
",",
"\"",
"\"",
":",
"{",
"name",
"}",
",",
"}",
"\n\n",
"// XXX: the created entry in this call returns a string instead of a number",
"// so I may have to do some workaround to solve it.",
"response",
",",
"err",
":=",
"api",
".",
"groupRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"response",
".",
"Channel",
",",
"nil",
"\n",
"}"
] | // RenameGroupContext renames a group with a custom context | [
"RenameGroupContext",
"renames",
"a",
"group",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L301-L315 | train |
nlopes/slack | groups.go | SetGroupPurpose | func (api *Client) SetGroupPurpose(group, purpose string) (string, error) {
return api.SetGroupPurposeContext(context.Background(), group, purpose)
} | go | func (api *Client) SetGroupPurpose(group, purpose string) (string, error) {
return api.SetGroupPurposeContext(context.Background(), group, purpose)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"SetGroupPurpose",
"(",
"group",
",",
"purpose",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"api",
".",
"SetGroupPurposeContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"group",
",",
"purpose",
")",
"\n",
"}"
] | // SetGroupPurpose sets the group purpose | [
"SetGroupPurpose",
"sets",
"the",
"group",
"purpose"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L318-L320 | train |
nlopes/slack | groups.go | SetGroupPurposeContext | func (api *Client) SetGroupPurposeContext(ctx context.Context, group, purpose string) (string, error) {
values := url.Values{
"token": {api.token},
"channel": {group},
"purpose": {purpose},
}
response, err := api.groupRequest(ctx, "groups.setPurpose", values)
if err != nil {
return "", err
}
return response.Purpose, nil
} | go | func (api *Client) SetGroupPurposeContext(ctx context.Context, group, purpose string) (string, error) {
values := url.Values{
"token": {api.token},
"channel": {group},
"purpose": {purpose},
}
response, err := api.groupRequest(ctx, "groups.setPurpose", values)
if err != nil {
return "", err
}
return response.Purpose, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"SetGroupPurposeContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"group",
",",
"purpose",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"group",
"}",
",",
"\"",
"\"",
":",
"{",
"purpose",
"}",
",",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"groupRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"response",
".",
"Purpose",
",",
"nil",
"\n",
"}"
] | // SetGroupPurposeContext sets the group purpose with a custom context | [
"SetGroupPurposeContext",
"sets",
"the",
"group",
"purpose",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L323-L335 | train |
nlopes/slack | groups.go | SetGroupTopic | func (api *Client) SetGroupTopic(group, topic string) (string, error) {
return api.SetGroupTopicContext(context.Background(), group, topic)
} | go | func (api *Client) SetGroupTopic(group, topic string) (string, error) {
return api.SetGroupTopicContext(context.Background(), group, topic)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"SetGroupTopic",
"(",
"group",
",",
"topic",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"api",
".",
"SetGroupTopicContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"group",
",",
"topic",
")",
"\n",
"}"
] | // SetGroupTopic sets the group topic | [
"SetGroupTopic",
"sets",
"the",
"group",
"topic"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L338-L340 | train |
nlopes/slack | groups.go | SetGroupTopicContext | func (api *Client) SetGroupTopicContext(ctx context.Context, group, topic string) (string, error) {
values := url.Values{
"token": {api.token},
"channel": {group},
"topic": {topic},
}
response, err := api.groupRequest(ctx, "groups.setTopic", values)
if err != nil {
return "", err
}
return response.Topic, nil
} | go | func (api *Client) SetGroupTopicContext(ctx context.Context, group, topic string) (string, error) {
values := url.Values{
"token": {api.token},
"channel": {group},
"topic": {topic},
}
response, err := api.groupRequest(ctx, "groups.setTopic", values)
if err != nil {
return "", err
}
return response.Topic, nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"SetGroupTopicContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"group",
",",
"topic",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"api",
".",
"token",
"}",
",",
"\"",
"\"",
":",
"{",
"group",
"}",
",",
"\"",
"\"",
":",
"{",
"topic",
"}",
",",
"}",
"\n\n",
"response",
",",
"err",
":=",
"api",
".",
"groupRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"response",
".",
"Topic",
",",
"nil",
"\n",
"}"
] | // SetGroupTopicContext sets the group topic with a custom context | [
"SetGroupTopicContext",
"sets",
"the",
"group",
"topic",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/groups.go#L343-L355 | train |
nlopes/slack | messageID.go | NewSafeID | func NewSafeID(startID int) IDGenerator {
return &safeID{
nextID: startID,
mutex: &sync.Mutex{},
}
} | go | func NewSafeID(startID int) IDGenerator {
return &safeID{
nextID: startID,
mutex: &sync.Mutex{},
}
} | [
"func",
"NewSafeID",
"(",
"startID",
"int",
")",
"IDGenerator",
"{",
"return",
"&",
"safeID",
"{",
"nextID",
":",
"startID",
",",
"mutex",
":",
"&",
"sync",
".",
"Mutex",
"{",
"}",
",",
"}",
"\n",
"}"
] | // NewSafeID returns a new instance of an IDGenerator which is safe for
// concurrent use by multiple goroutines. | [
"NewSafeID",
"returns",
"a",
"new",
"instance",
"of",
"an",
"IDGenerator",
"which",
"is",
"safe",
"for",
"concurrent",
"use",
"by",
"multiple",
"goroutines",
"."
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/messageID.go#L12-L17 | train |
nlopes/slack | auth.go | SendAuthRevoke | func (api *Client) SendAuthRevoke(token string) (*AuthRevokeResponse, error) {
return api.SendAuthRevokeContext(context.Background(), token)
} | go | func (api *Client) SendAuthRevoke(token string) (*AuthRevokeResponse, error) {
return api.SendAuthRevokeContext(context.Background(), token)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"SendAuthRevoke",
"(",
"token",
"string",
")",
"(",
"*",
"AuthRevokeResponse",
",",
"error",
")",
"{",
"return",
"api",
".",
"SendAuthRevokeContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"token",
")",
"\n",
"}"
] | // SendAuthRevoke will send a revocation for our token | [
"SendAuthRevoke",
"will",
"send",
"a",
"revocation",
"for",
"our",
"token"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/auth.go#L26-L28 | train |
nlopes/slack | auth.go | SendAuthRevokeContext | func (api *Client) SendAuthRevokeContext(ctx context.Context, token string) (*AuthRevokeResponse, error) {
if token == "" {
token = api.token
}
values := url.Values{
"token": {token},
}
return api.authRequest(ctx, "auth.revoke", values)
} | go | func (api *Client) SendAuthRevokeContext(ctx context.Context, token string) (*AuthRevokeResponse, error) {
if token == "" {
token = api.token
}
values := url.Values{
"token": {token},
}
return api.authRequest(ctx, "auth.revoke", values)
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"SendAuthRevokeContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"token",
"string",
")",
"(",
"*",
"AuthRevokeResponse",
",",
"error",
")",
"{",
"if",
"token",
"==",
"\"",
"\"",
"{",
"token",
"=",
"api",
".",
"token",
"\n",
"}",
"\n",
"values",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"token",
"}",
",",
"}",
"\n\n",
"return",
"api",
".",
"authRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"}"
] | // SendAuthRevokeContext will retrieve the satus from api.test | [
"SendAuthRevokeContext",
"will",
"retrieve",
"the",
"satus",
"from",
"api",
".",
"test"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/auth.go#L31-L40 | train |
nlopes/slack | chat.go | getMessageTimestamp | func (c chatResponseFull) getMessageTimestamp() string {
if len(c.Timestamp) > 0 {
return c.Timestamp
}
return c.MessageTimeStamp
} | go | func (c chatResponseFull) getMessageTimestamp() string {
if len(c.Timestamp) > 0 {
return c.Timestamp
}
return c.MessageTimeStamp
} | [
"func",
"(",
"c",
"chatResponseFull",
")",
"getMessageTimestamp",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"c",
".",
"Timestamp",
")",
">",
"0",
"{",
"return",
"c",
".",
"Timestamp",
"\n",
"}",
"\n",
"return",
"c",
".",
"MessageTimeStamp",
"\n",
"}"
] | // getMessageTimestamp will inspect the `chatResponseFull` to ruturn a timestamp value
// in `chat.postMessage` its under `ts`
// in `chat.postEphemeral` its under `message_ts` | [
"getMessageTimestamp",
"will",
"inspect",
"the",
"chatResponseFull",
"to",
"ruturn",
"a",
"timestamp",
"value",
"in",
"chat",
".",
"postMessage",
"its",
"under",
"ts",
"in",
"chat",
".",
"postEphemeral",
"its",
"under",
"message_ts"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/chat.go#L37-L42 | train |
nlopes/slack | chat.go | NewPostMessageParameters | func NewPostMessageParameters() PostMessageParameters {
return PostMessageParameters{
Username: DEFAULT_MESSAGE_USERNAME,
User: DEFAULT_MESSAGE_USERNAME,
AsUser: DEFAULT_MESSAGE_ASUSER,
Parse: DEFAULT_MESSAGE_PARSE,
ThreadTimestamp: DEFAULT_MESSAGE_THREAD_TIMESTAMP,
LinkNames: DEFAULT_MESSAGE_LINK_NAMES,
UnfurlLinks: DEFAULT_MESSAGE_UNFURL_LINKS,
UnfurlMedia: DEFAULT_MESSAGE_UNFURL_MEDIA,
IconURL: DEFAULT_MESSAGE_ICON_URL,
IconEmoji: DEFAULT_MESSAGE_ICON_EMOJI,
Markdown: DEFAULT_MESSAGE_MARKDOWN,
EscapeText: DEFAULT_MESSAGE_ESCAPE_TEXT,
}
} | go | func NewPostMessageParameters() PostMessageParameters {
return PostMessageParameters{
Username: DEFAULT_MESSAGE_USERNAME,
User: DEFAULT_MESSAGE_USERNAME,
AsUser: DEFAULT_MESSAGE_ASUSER,
Parse: DEFAULT_MESSAGE_PARSE,
ThreadTimestamp: DEFAULT_MESSAGE_THREAD_TIMESTAMP,
LinkNames: DEFAULT_MESSAGE_LINK_NAMES,
UnfurlLinks: DEFAULT_MESSAGE_UNFURL_LINKS,
UnfurlMedia: DEFAULT_MESSAGE_UNFURL_MEDIA,
IconURL: DEFAULT_MESSAGE_ICON_URL,
IconEmoji: DEFAULT_MESSAGE_ICON_EMOJI,
Markdown: DEFAULT_MESSAGE_MARKDOWN,
EscapeText: DEFAULT_MESSAGE_ESCAPE_TEXT,
}
} | [
"func",
"NewPostMessageParameters",
"(",
")",
"PostMessageParameters",
"{",
"return",
"PostMessageParameters",
"{",
"Username",
":",
"DEFAULT_MESSAGE_USERNAME",
",",
"User",
":",
"DEFAULT_MESSAGE_USERNAME",
",",
"AsUser",
":",
"DEFAULT_MESSAGE_ASUSER",
",",
"Parse",
":",
"DEFAULT_MESSAGE_PARSE",
",",
"ThreadTimestamp",
":",
"DEFAULT_MESSAGE_THREAD_TIMESTAMP",
",",
"LinkNames",
":",
"DEFAULT_MESSAGE_LINK_NAMES",
",",
"UnfurlLinks",
":",
"DEFAULT_MESSAGE_UNFURL_LINKS",
",",
"UnfurlMedia",
":",
"DEFAULT_MESSAGE_UNFURL_MEDIA",
",",
"IconURL",
":",
"DEFAULT_MESSAGE_ICON_URL",
",",
"IconEmoji",
":",
"DEFAULT_MESSAGE_ICON_EMOJI",
",",
"Markdown",
":",
"DEFAULT_MESSAGE_MARKDOWN",
",",
"EscapeText",
":",
"DEFAULT_MESSAGE_ESCAPE_TEXT",
",",
"}",
"\n",
"}"
] | // NewPostMessageParameters provides an instance of PostMessageParameters with all the sane default values set | [
"NewPostMessageParameters",
"provides",
"an",
"instance",
"of",
"PostMessageParameters",
"with",
"all",
"the",
"sane",
"default",
"values",
"set"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/chat.go#L65-L80 | train |
nlopes/slack | chat.go | DeleteMessage | func (api *Client) DeleteMessage(channel, messageTimestamp string) (string, string, error) {
respChannel, respTimestamp, _, err := api.SendMessageContext(context.Background(), channel, MsgOptionDelete(messageTimestamp))
return respChannel, respTimestamp, err
} | go | func (api *Client) DeleteMessage(channel, messageTimestamp string) (string, string, error) {
respChannel, respTimestamp, _, err := api.SendMessageContext(context.Background(), channel, MsgOptionDelete(messageTimestamp))
return respChannel, respTimestamp, err
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"DeleteMessage",
"(",
"channel",
",",
"messageTimestamp",
"string",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"respChannel",
",",
"respTimestamp",
",",
"_",
",",
"err",
":=",
"api",
".",
"SendMessageContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"channel",
",",
"MsgOptionDelete",
"(",
"messageTimestamp",
")",
")",
"\n",
"return",
"respChannel",
",",
"respTimestamp",
",",
"err",
"\n",
"}"
] | // DeleteMessage deletes a message in a channel | [
"DeleteMessage",
"deletes",
"a",
"message",
"in",
"a",
"channel"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/chat.go#L83-L86 | train |
nlopes/slack | chat.go | DeleteMessageContext | func (api *Client) DeleteMessageContext(ctx context.Context, channel, messageTimestamp string) (string, string, error) {
respChannel, respTimestamp, _, err := api.SendMessageContext(ctx, channel, MsgOptionDelete(messageTimestamp))
return respChannel, respTimestamp, err
} | go | func (api *Client) DeleteMessageContext(ctx context.Context, channel, messageTimestamp string) (string, string, error) {
respChannel, respTimestamp, _, err := api.SendMessageContext(ctx, channel, MsgOptionDelete(messageTimestamp))
return respChannel, respTimestamp, err
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"DeleteMessageContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"channel",
",",
"messageTimestamp",
"string",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"respChannel",
",",
"respTimestamp",
",",
"_",
",",
"err",
":=",
"api",
".",
"SendMessageContext",
"(",
"ctx",
",",
"channel",
",",
"MsgOptionDelete",
"(",
"messageTimestamp",
")",
")",
"\n",
"return",
"respChannel",
",",
"respTimestamp",
",",
"err",
"\n",
"}"
] | // DeleteMessageContext deletes a message in a channel with a custom context | [
"DeleteMessageContext",
"deletes",
"a",
"message",
"in",
"a",
"channel",
"with",
"a",
"custom",
"context"
] | 65ea2b979a7ffe628676bdb6b924e2498d66c1bf | https://github.com/nlopes/slack/blob/65ea2b979a7ffe628676bdb6b924e2498d66c1bf/chat.go#L89-L92 | train |
Subsets and Splits