feat(slack): add thread support (#423)

##### ISSUE TYPE
 - Feature Pull Request

##### SUMMARY
adding support for botkube to interact in slack threads
I did update the test bash script that would not run on my zsh shell on my mac.

I Also wanted to add some unit tests but the Slack test server does not support thread messages.

Fixes #422
This commit is contained in:
sgandon 2020-11-03 09:42:01 +01:00 committed by GitHub
parent f5dce1ff6b
commit 0ad0536512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -20,7 +20,7 @@
set -o errexit
set -o nounset
set -o pipefail
export CONFIG_PATH="$(pwd)/test"

View File

@ -180,7 +180,14 @@ func (sm *slackMessage) Send() {
return
}
if _, _, err := sm.RTM.PostMessage(sm.Event.Channel, slack.MsgOptionText("```"+sm.Response+"```", false), slack.MsgOptionAsUser(true)); err != nil {
var options = []slack.MsgOption{slack.MsgOptionText("```"+sm.Response+"```", false), slack.MsgOptionAsUser(true)}
//if the message is from thread then add an option to return the response to the thread
if sm.Event.ThreadTimestamp != "" {
options = append(options, slack.MsgOptionTS(sm.Event.ThreadTimestamp))
}
if _, _, err := sm.RTM.PostMessage(sm.Event.Channel, options...); err != nil {
log.Error("Error in sending message:", err)
}
}