commit b915a3809966c95503977c58be7f5385bf3640f1
parent 33cf646126a863c48c6334030d477abe7c6f2b0b
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Wed, 24 May 2023 08:16:47 -0700
add "/chess username r" for random color
Diffstat:
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/pkg/web/handlers/api/v1/handlers.go b/pkg/web/handlers/api/v1/handlers.go
@@ -45,7 +45,7 @@ var groupRgx = regexp.MustCompile(`^/g (` + groupName + `)\s(?s:(.*))`)
var pmRgx = regexp.MustCompile(`^/pm ` + optAtGUserOr0 + `(?:\s(?s:(.*)))?`)
var editRgx = regexp.MustCompile(`^/e (` + chatTs + `)\s(?s:(.*))`)
var hbmtRgx = regexp.MustCompile(`^/hbmt (` + chatTs + `)$`)
-var chessRgx = regexp.MustCompile(`^/chess ` + optAtGUser + `(?:\s(w|b))?`)
+var chessRgx = regexp.MustCompile(`^/chess ` + optAtGUser + `(?:\s(w|b|r))?`)
var inboxRgx = regexp.MustCompile(`^/inbox ` + optAtGUser + `(\s-e)?\s(?s:(.*))`)
var purgeRgx = regexp.MustCompile(`^/purge ` + optAtGUserOr0)
var renameRgx = regexp.MustCompile(`^/rename ` + optAtGUser + ` ` + optAtGUser)
diff --git a/pkg/web/handlers/api/v1/slashInterceptor.go b/pkg/web/handlers/api/v1/slashInterceptor.go
@@ -1208,6 +1208,9 @@ func handleChessCmd(c *Command) (handled bool) {
c.err = errors.New("invalid username")
return true
}
+ if color == "r" {
+ color = utils.RandChoice([]string{"w", "b"})
+ }
if color == "b" {
player1, player2 = player2, player1
}