only bots can use bot challenge decline reason

pull/8134/head
Thibault Duplessis 2021-02-09 08:45:06 +01:00
parent eaea6bdcae
commit 4b961aa2e6
2 changed files with 3 additions and 1 deletions

View File

@ -141,6 +141,8 @@ object Challenge {
val default: DeclineReason = Generic
val all: List[DeclineReason] =
List(Generic, Later, TooFast, TooSlow, TimeControl, Rated, Casual, Standard, Variant, NoBot, OnlyBot)
val allExceptBot: List[DeclineReason] =
all.filterNot(r => r == NoBot || r == OnlyBot)
def apply(key: String) = all.find { d => d.key == key.toLowerCase || d.trans.key == key } | Generic
}

View File

@ -36,7 +36,7 @@ final class JsonView(
"in" -> a.in.map(apply(Direction.In.some)),
"out" -> a.out.map(apply(Direction.Out.some)),
"i18n" -> lila.i18n.JsDump.keysToObject(i18nKeys, lang),
"reasons" -> JsObject(Challenge.DeclineReason.all.map { r =>
"reasons" -> JsObject(Challenge.DeclineReason.allExceptBot.map { r =>
r.key -> JsString(r.trans.txt())
})
)