From 4fd0683a8d37f3abdb499720a32b289fd4611c66 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Tue, 1 Oct 2019 14:01:02 -0400 Subject: [PATCH] zork: make path to exec and dat configurable zork: squash pkgPath err zork: add flag support --- plugins/zork/zork.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/zork/zork.go b/plugins/zork/zork.go index 11458a7..63ecba6 100644 --- a/plugins/zork/zork.go +++ b/plugins/zork/zork.go @@ -39,12 +39,17 @@ func New(b bot.Bot) bot.Plugin { func (p *ZorkPlugin) runZork(c bot.Connector, ch string) error { const importString = "github.com/velour/catbase/plugins/zork" + pkgPath := "" pkg, err := build.Import(importString, "", build.FindOnly) - if err != nil { - return err + if err == nil { + pkgPath = pkg.Dir } - zorkdat := filepath.Join(pkg.Dir, "ZORK1.DAT") - cmd := exec.Command("dfrotz", zorkdat) + zorkPath := p.bot.Config().GetString("zork.path", pkgPath) + zorkdat := filepath.Join(zorkPath, "ZORK1.DAT") + zorkFlags := p.bot.Config().GetArray("zork.args", []string{"-p"}) + zorkExec := p.bot.Config().GetString("zork.binary", "frotz") + zorkFlags = append(zorkFlags, zorkdat) + cmd := exec.Command(zorkExec, zorkFlags...) var r io.ReadCloser r, cmd.Stdout = io.Pipe()