Skip to content

Commit

Permalink
Merge fe3f10e into c3767d1
Browse files Browse the repository at this point in the history
  • Loading branch information
wass3r committed Nov 21, 2019
2 parents c3767d1 + fe3f10e commit 8409d86
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 59 deletions.
10 changes: 5 additions & 5 deletions core/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strconv"
"strings"

"github.com/leekchan/gtf"
"github.com/Masterminds/sprig"
"github.com/mohae/deepcopy"

"github.com/target/flottbot/handlers"
Expand Down Expand Up @@ -339,7 +339,7 @@ func craftResponse(rule models.Rule, msg models.Message, bot *models.Bot) (strin
if strings.Contains(output, "{{") {
var i interface{}

t, err := template.New("output").Funcs(gtf.GtfFuncMap).Parse(output)
t, err := template.New("output").Funcs(sprig.FuncMap()).Parse(output)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -410,9 +410,9 @@ func handleHTTP(action models.Action, msg *models.Message, bot *models.Bot) erro

// Check if the value contains html/template code
if strings.Contains(v, "{{") {
t, err = template.New(k).Funcs(gtf.GtfFuncMap).Parse(v)
t, err = template.New(k).Funcs(sprig.FuncMap()).Parse(v)
} else {
t, err = template.New(k).Funcs(gtf.GtfFuncMap).Parse(fmt.Sprintf(`{{%s}}`, v))
t, err = template.New(k).Funcs(sprig.FuncMap()).Parse(fmt.Sprintf(`{{%s}}`, v))
}
if err != nil {
return err
Expand Down Expand Up @@ -492,7 +492,7 @@ func updateReaction(action models.Action, rule *models.Rule, vars map[string]str
var t *template.Template
var i interface{}

t, err = template.New("update_reaction").Funcs(gtf.GtfFuncMap).Parse(action.Reaction)
t, err = template.New("update_reaction").Funcs(sprig.FuncMap()).Parse(action.Reaction)
if err != nil {
bot.Log.Errorf("Failed to update Reaction %s", rule.Reaction)
return
Expand Down
20 changes: 10 additions & 10 deletions core/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,9 @@ func Test_handleChatServiceRule(t *testing.T) {
}

ruleVarg := models.Rule{
Name: "Test Rules with varargs",
Respond: "foo",
Args: []string{"arg1", "argv+"},
Name: "Test Rules with varargs",
Respond: "foo",
Args: []string{"arg1", "argv+"},
HelpText: "foo <arg1> <argv...>",
}

Expand Down Expand Up @@ -728,8 +728,8 @@ func Test_handleChatServiceRule(t *testing.T) {
}

testMessageVargs := models.Message{
Input: "foo arg1 arg2 arg3 arg4",
Vars: map[string]string{},
Input: "foo arg1 arg2 arg3 arg4",
Vars: map[string]string{},
BotMentioned: true,
}

Expand All @@ -741,11 +741,11 @@ func Test_handleChatServiceRule(t *testing.T) {
}

tests := []struct {
name string
args args
want bool
want1 bool
expectMsg string
name string
args args
want bool
want1 bool
expectMsg string
expectedVars map[string]string
}{
{"basic", args{}, false, false, "", map[string]string{}},
Expand Down
38 changes: 22 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
module github.com/target/flottbot

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/Masterminds/semver v1.4.2
github.com/bwmarrin/discordgo v0.19.0
github.com/golang/protobuf v1.3.1 // indirect
github.com/gorilla/mux v1.7.0
github.com/Masterminds/goutils v1.1.0 // indirect
github.com/Masterminds/semver v1.5.0
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/bwmarrin/discordgo v0.20.1
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/gorilla/mux v1.7.3
github.com/gorilla/websocket v1.4.1 // indirect
github.com/huandu/xstrings v1.2.0 // indirect
github.com/imdario/mergo v0.3.8 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/leekchan/gtf v0.0.0-20190214083521-5fba33c5b00b
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/nlopes/slack v0.6.0
github.com/pkg/errors v0.8.1 // indirect
github.com/prometheus/client_golang v0.9.1
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 // indirect
github.com/prometheus/common v0.2.0 // indirect
github.com/prometheus/procfs v0.0.0-20190322151404-55ae3d9d5573 // indirect
github.com/robfig/cron v1.1.0
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/prometheus/client_golang v1.2.1
github.com/prometheus/procfs v0.0.7 // indirect
github.com/robfig/cron v1.2.0
github.com/rs/xid v1.2.1
github.com/sirupsen/logrus v1.4.0
github.com/sirupsen/logrus v1.4.2
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.3.2
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c // indirect
golang.org/x/sys v0.0.0-20190322080309-f49334f85ddc // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.5.0
golang.org/x/crypto v0.0.0-20191119213627-4f8c1d86b1ba // indirect
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e // indirect
golang.org/x/text v0.3.2 // indirect
gopkg.in/yaml.v2 v2.2.7 // indirect
)

go 1.13
Loading

0 comments on commit 8409d86

Please sign in to comment.