diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b9624e779..227eac6ab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,7 +89,7 @@ For faster development, you can also build and run Botkube outside K8s cluster. # Fetch the dependencies go mod download # Build the binary - go build ./cmd/botkube-agent/ + go build -o botkube ./cmd/botkube-agent/ ``` 2. Create a local configuration file to override default values. For example, set communication credentials, specify cluster name, and disable analytics: diff --git a/pkg/bot/slack_cloud.go b/pkg/bot/slack_cloud.go index 862085bb1..0ee1f8732 100644 --- a/pkg/bot/slack_cloud.go +++ b/pkg/bot/slack_cloud.go @@ -519,14 +519,36 @@ func (b *CloudSlack) send(ctx context.Context, event slackMessage, resp interact var file *slack.File var err error if len(markdown) >= slackMaxMessageSize { - file, err = uploadFileToSlack(ctx, event.Channel, resp, b.client, event.ThreadTimeStamp) - if err != nil { - return err - } - resp = interactive.CoreMessage{ - Message: api.Message{ - PlaintextInputs: resp.PlaintextInputs, - }, + if strings.Contains(resp.Description, "logs") { + + file, err = uploadFileToSlack(ctx, event.Channel, resp, b.client, event.ThreadTimeStamp) + if err != nil { + return err + } + resp = interactive.CoreMessage{ + Message: api.Message{ + PlaintextInputs: resp.PlaintextInputs, + }, + } + } else { + newBlocks := strings.Split(resp.BaseBody.CodeBlock, "\n") + + newBlocks = newBlocks[:45] + + result := strings.Join(newBlocks, "\n") + + fmt.Println("result is",result) + + resp = interactive.CoreMessage{ + Description: resp.Description, + Message: api.Message{ + PlaintextInputs: resp.PlaintextInputs, + + BaseBody: api.Body{ + CodeBlock: result, + }, + }, + } } } diff --git a/pkg/bot/slack_socket.go b/pkg/bot/slack_socket.go index f865f1169..85da36704 100644 --- a/pkg/bot/slack_socket.go +++ b/pkg/bot/slack_socket.go @@ -407,14 +407,36 @@ func (b *SocketSlack) send(ctx context.Context, event slackMessage, resp interac var file *slack.File var err error if len(markdown) >= slackMaxMessageSize { - file, err = uploadFileToSlack(ctx, event.Channel, resp, b.client, event.ThreadTimeStamp) - if err != nil { - return err - } - resp = interactive.CoreMessage{ - Message: api.Message{ - PlaintextInputs: resp.PlaintextInputs, - }, + if strings.Contains(resp.Description, "logs") { + + file, err = uploadFileToSlack(ctx, event.Channel, resp, b.client, event.ThreadTimeStamp) + if err != nil { + return err + } + resp = interactive.CoreMessage{ + Message: api.Message{ + PlaintextInputs: resp.PlaintextInputs, + }, + } + } else { + newBlocks := strings.Split(resp.BaseBody.CodeBlock, "\n") + + newBlocks = newBlocks[:45] + + result := strings.Join(newBlocks, "\n") + + fmt.Println("result is",result) + + resp = interactive.CoreMessage{ + Description: resp.Description, + Message: api.Message{ + PlaintextInputs: resp.PlaintextInputs, + + BaseBody: api.Body{ + CodeBlock: result, + }, + }, + } } }