From 2045fc45914a44477a1ca2447c83d6f4c6248c57 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Tue, 4 May 2021 14:05:21 -0400 Subject: [PATCH] goals: fix ordering of commands --- plugins/goals/goals.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/goals/goals.go b/plugins/goals/goals.go index dfdec80..cee58ab 100644 --- a/plugins/goals/goals.go +++ b/plugins/goals/goals.go @@ -53,14 +53,6 @@ func (p *GoalsPlugin) mkDB() { func (p *GoalsPlugin) registerCmds() { p.handlers = bot.HandlerTable{ - {Kind: bot.Message, IsCmd: true, - Regex: regexp.MustCompile(`(?i)^register (?Pcompetition|goal) (?P[[:punct:][:alnum:]]+) (?P[[:digit:]]+)?`), - HelpText: "Register with `%s` for yourself", - Handler: func(r bot.Request) bool { - amount, _ := strconv.Atoi(r.Values["amount"]) - p.register(r.Conn, r.Msg.Channel, r.Values["type"], r.Values["what"], r.Msg.User.Name, amount) - return true - }}, {Kind: bot.Message, IsCmd: true, Regex: regexp.MustCompile(`(?i)^register (?Pcompetition|goal) for (?P[[:punct:][:alnum:]]+) (?P[[:punct:][:alnum:]]+) (?P[[:digit:]]+)?`), HelpText: "Register with `%s` for other people", @@ -70,10 +62,11 @@ func (p *GoalsPlugin) registerCmds() { return true }}, {Kind: bot.Message, IsCmd: true, - Regex: regexp.MustCompile(`(?i)^deregister (?Pcompetition|goal) (?P[[:punct:][:alnum:]]+)`), - HelpText: "Deregister with `%s` for yourself", + Regex: regexp.MustCompile(`(?i)^register (?Pcompetition|goal) (?P[[:punct:][:alnum:]]+) (?P[[:digit:]]+)?`), + HelpText: "Register with `%s` for yourself", Handler: func(r bot.Request) bool { - p.deregister(r.Conn, r.Msg.Channel, r.Values["type"], r.Values["what"], r.Msg.User.Name) + amount, _ := strconv.Atoi(r.Values["amount"]) + p.register(r.Conn, r.Msg.Channel, r.Values["type"], r.Values["what"], r.Msg.User.Name, amount) return true }}, {Kind: bot.Message, IsCmd: true, @@ -84,10 +77,10 @@ func (p *GoalsPlugin) registerCmds() { return true }}, {Kind: bot.Message, IsCmd: true, - Regex: regexp.MustCompile(`(?i)^check (?Pcompetition|goal) (?P[[:punct:][:alnum:]]+)`), - HelpText: "Check with `%s` for yourself", + Regex: regexp.MustCompile(`(?i)^deregister (?Pcompetition|goal) (?P[[:punct:][:alnum:]]+)`), + HelpText: "Deregister with `%s` for yourself", Handler: func(r bot.Request) bool { - p.check(r.Conn, r.Msg.Channel, r.Values["type"], r.Values["what"], r.Msg.User.Name) + p.deregister(r.Conn, r.Msg.Channel, r.Values["type"], r.Values["what"], r.Msg.User.Name) return true }}, {Kind: bot.Message, IsCmd: true, @@ -97,6 +90,13 @@ func (p *GoalsPlugin) registerCmds() { p.check(r.Conn, r.Msg.Channel, r.Values["type"], r.Values["what"], r.Values["who"]) return true }}, + {Kind: bot.Message, IsCmd: true, + Regex: regexp.MustCompile(`(?i)^check (?Pcompetition|goal) (?P[[:punct:][:alnum:]]+)`), + HelpText: "Check with `%s` for yourself", + Handler: func(r bot.Request) bool { + p.check(r.Conn, r.Msg.Channel, r.Values["type"], r.Values["what"], r.Msg.User.Name) + return true + }}, } p.b.RegisterTable(p, p.handlers) }