Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors in red #8

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@
# Go workspace file
go.work
go.work.sum

grol-discord-bot
12 changes: 11 additions & 1 deletion bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,17 @@ func evalAndReply(session *discordgo.Session, info, channelID, input string) {
// TODO: stdout vs stderr vs result. https://github.com/grol-io/grol/issues/33
// TODO: Maybe better quoting.
input = removeTripleBackticks(input)
res = "```go\n" + repl.EvalString(input) + "\n```"
var errs []string
res, errs = repl.EvalString(input)
if len(errs) > 0 {
res = "```diff"
for _, e := range errs {
res += "\n- " + e
}
res += "\n```"
} else {
res = "```go\n" + res + "\n```"
}
}
log.S(log.Info, info, log.String("response", res))
reply(session, channelID, res)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
fortio.org/scli v1.15.1
fortio.org/version v1.0.4
github.com/bwmarrin/discordgo v0.28.1
grol.io/grol v0.20.0
grol.io/grol v0.21.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
grol.io/grol v0.20.0 h1:YZzAn5PANwT1y+Ubhc0w+rHKzNg1e+DK6UU0rEjdi+w=
grol.io/grol v0.20.0/go.mod h1:ZR4Q830l/q+zWVx7yAVS1crPChNXghSRd0fQOvfObmI=
grol.io/grol v0.21.0 h1:VMWFMZPDnIne0Esz2yr3D2tkQ9FlFqxjsVdyMWvx0Tc=
grol.io/grol v0.21.0/go.mod h1:ZR4Q830l/q+zWVx7yAVS1crPChNXghSRd0fQOvfObmI=