diff --git a/chat.go b/chat.go index 35ffbbcf..2668b382 100644 --- a/chat.go +++ b/chat.go @@ -696,6 +696,14 @@ func MsgOptionMetadata(metadata SlackMetadata) MsgOption { } } +// MsgOptionLinkNames finds and links user groups. Does not support linking individual users +func MsgOptionLinkNames(linkName bool) MsgOption { + return func(config *sendConfig) error { + config.values.Set("link_names", strconv.FormatBool(linkName)) + return nil + } +} + // UnsafeMsgOptionEndpoint deliver the message to the specified endpoint. // NOTE: USE AT YOUR OWN RISK: No issues relating to the use of this Option // will be supported by the library, it is subject to change without notice that diff --git a/chat_test.go b/chat_test.go index fb372259..ee93bddf 100644 --- a/chat_test.go +++ b/chat_test.go @@ -185,6 +185,28 @@ func TestPostMessage(t *testing.T) { "user_auth_message": []string{"Please!"}, }, }, + "LinkNames true": { + endpoint: "/chat.postMessage", + opt: []MsgOption{ + MsgOptionLinkNames(true), + }, + expected: url.Values{ + "channel": []string{"CXXX"}, + "token": []string{"testing-token"}, + "link_names": []string{"true"}, + }, + }, + "LinkNames false": { + endpoint: "/chat.postMessage", + opt: []MsgOption{ + MsgOptionLinkNames(false), + }, + expected: url.Values{ + "channel": []string{"CXXX"}, + "token": []string{"testing-token"}, + "link_names": []string{"false"}, + }, + }, } once.Do(startServer)