mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
interact: handle InteractionTypeViewSubmission and print debug state
This commit is contained in:
parent
1e92d8e08a
commit
a9610a3e74
|
@ -2,6 +2,7 @@ package interact
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
stdlog "log"
|
||||
"os"
|
||||
|
@ -247,6 +248,8 @@ func (s *Slack) listen() {
|
|||
case slack.InteractionTypeShortcut:
|
||||
case slack.InteractionTypeViewSubmission:
|
||||
// See https://api.slack.com/apis/connections/socket-implement#modal
|
||||
log.Debugf("InteractionTypeViewSubmission: state: %s", toJson(callback.View.State))
|
||||
|
||||
case slack.InteractionTypeDialogSubmission:
|
||||
default:
|
||||
|
||||
|
@ -349,8 +352,9 @@ func generateTextInputModalRequest(title string, prompt string, textFields ...Te
|
|||
labelObject := slack.NewTextBlockObject("plain_text", textField.Label, false, false)
|
||||
placeHolderObject := slack.NewTextBlockObject("plain_text", textField.PlaceHolder, false, false)
|
||||
textInputObject := slack.NewPlainTextInputBlockElement(placeHolderObject, textField.Name)
|
||||
|
||||
// Notice that blockID is a unique identifier for a block
|
||||
inputBlock := slack.NewInputBlock(textField.Name, labelObject, textInputObject)
|
||||
inputBlock := slack.NewInputBlock("block-"+textField.Name+"-"+uuid.NewString(), labelObject, textInputObject)
|
||||
blocks.BlockSet = append(blocks.BlockSet, inputBlock)
|
||||
}
|
||||
|
||||
|
@ -362,3 +366,12 @@ func generateTextInputModalRequest(title string, prompt string, textFields ...Te
|
|||
modalRequest.Blocks = blocks
|
||||
return &modalRequest
|
||||
}
|
||||
|
||||
func toJson(v interface{}) string {
|
||||
o, err := json.MarshalIndent(v, "", " ")
|
||||
if err != nil {
|
||||
log.WithError(err).Errorf("json marshal error")
|
||||
return ""
|
||||
}
|
||||
return string(o)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user