From b03cf7c8571d347fe4f37706eef0a99564178e20 Mon Sep 17 00:00:00 2001 From: Kseniya Shaydurova Date: Fri, 24 Sep 2021 21:03:16 +0700 Subject: [PATCH] feat: add possibility to send msg to thread (#10) --- README.md | 1 + main.go | 2 ++ slack_notifier.go | 1 + 3 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 771cc9b..f69bf77 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ __NOTE__: The module supports up to 8 Fields in an [attachment](https://api.slac | fallback | SLACK_FALLBACK | A plain-text summary of the attachment. This text will be used in clients that don't show formatted text | | color | SLACK_COLOR | An optional value that can either be one of `good`, `warning`, `danger`, or a color code (_e.g._ `#439FE0`) | | channel | SLACK_CHANNEL | Slack channel to send to | +| thread | SLACK_THREAD | Slack channel thread to send to | | pretext | SLACK_PRETEXT | Optional text that appears above the message attachment block | | author_name | SLACK_AUTHOR_NAME | Small text to display the attachment author's name | | author_link | SLACK_AUTHOR_LINK | URL that will hyperlink the author's name. Will only work if `author_name` is present | diff --git a/main.go b/main.go index 100202e..bfe25ae 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ var ( fallback = flag.String("fallback", os.Getenv("SLACK_FALLBACK"), "A plain-text summary of the attachment. This text will be used in clients that don't show formatted text") color = flag.String("color", os.Getenv("SLACK_COLOR"), "An optional value that can either be one of good, warning, danger, or any hex color code (e.g. #439FE0)") channel = flag.String("channel", os.Getenv("SLACK_CHANNEL"), "Slack channel to send to") + thread = flag.String("thread", os.Getenv("SLACK_THREAD"), "Slack channel thread to send to") pretext = flag.String("pretext", os.Getenv("SLACK_PRETEXT"), "Optional text that appears above the message attachment block") authorName = flag.String("author_name", os.Getenv("SLACK_AUTHOR_NAME"), "Small text to display the attachment author's name") authorLink = flag.String("author_link", os.Getenv("SLACK_AUTHOR_LINK"), "URL that will hyperlink the author's name. Will only work if author_name is present") @@ -135,6 +136,7 @@ func main() { Username: *userName, IconEmoji: *iconEmoji, Channel: *channel, + Thread: *thread, } notifier := NewSlackNotifier(*webhookURL) diff --git a/slack_notifier.go b/slack_notifier.go index f4e8e05..0825c92 100644 --- a/slack_notifier.go +++ b/slack_notifier.go @@ -22,6 +22,7 @@ type Payload struct { IconEmoji string `json:"icon_emoji"` Username string `json:"username"` Channel string `json:"channel"` + Thread string `json:"thread_ts,omitempty"` } // Attachment for a Slack message