Add rpn command

This commit is contained in:
Dustin Pianalto
2020-08-25 16:53:51 -08:00
parent dd0f9cba57
commit 6c05518146
3 changed files with 176 additions and 1 deletions
+11 -1
View File
@@ -2,8 +2,10 @@ package exts
import (
"fmt"
"github.com/dustinpianalto/disgoman"
"strconv"
"djpianalto.com/goff/djpianalto.com/goff/utils"
"github.com/dustinpianalto/disgoman"
)
func interleave(ctx disgoman.Context, args []string) {
@@ -47,3 +49,11 @@ func deinterleave(ctx disgoman.Context, args []string) {
ctx.Send(fmt.Sprintf("(%v, %v)", x, y))
}
}
func rpn(ctx disgoman.Context, args []string) {
rpn, err := utils.GenerateRPN(args)
if err != nil {
ctx.Send(err.Error())
}
ctx.Send(rpn)
}
+9
View File
@@ -186,4 +186,13 @@ func AddCommandHandlers(h *disgoman.CommandManager) {
RequiredPermissions: 0,
Invoke: deinterleave,
})
_ = h.AddCommand(&disgoman.Command{
Name: "rpn",
Aliases: []string{"d"},
Description: "Convert infix to rpn",
OwnerOnly: false,
Hidden: false,
RequiredPermissions: 0,
Invoke: rpn,
})
}