add DEBUG_SLACK env var

This commit is contained in:
c9s 2022-03-14 21:20:53 +08:00
parent 19f01bbca6
commit 0d0e0039e5

View File

@ -13,6 +13,8 @@ import (
"github.com/slack-go/slack"
"github.com/slack-go/slack/slackevents"
"github.com/slack-go/slack/socketmode"
"github.com/c9s/bbgo/pkg/util"
)
type SlackReply struct {
@ -165,14 +167,17 @@ type Slack struct {
}
func NewSlack(client *slack.Client) *Slack {
socket := socketmode.New(
client,
socketmode.OptionDebug(true),
var opts = []socketmode.Option{
socketmode.OptionLog(
stdlog.New(os.Stdout, "socketmode: ",
stdlog.Lshortfile|stdlog.LstdFlags)),
)
}
if b, ok := util.GetEnvVarBool("DEBUG_SLACK"); ok {
opts = append(opts, socketmode.OptionDebug(b))
}
socket := socketmode.New(client, opts...)
return &Slack{
client: client,
socket: socket,