make moretime messages volatile

pull/5869/head
Thibault Duplessis 2020-01-02 23:19:38 -06:00
parent 8e9ebe39f6
commit 2b6db8eb00
2 changed files with 14 additions and 5 deletions

View File

@ -9,10 +9,19 @@ import lila.user.User
final class Messenger(api: ChatApi) {
def system(game: Game, message: SelectI18nKey, args: Any*): Unit = {
def system(game: Game, message: SelectI18nKey, args: Any*): Unit =
system(true)(game, message, args: _*)
def volatile(game: Game, message: SelectI18nKey, args: Any*): Unit =
system(false)(game, message, args: _*)
def system(persistent: Boolean)(game: Game, message: SelectI18nKey, args: Any*): Unit = {
val translated = message(I18nKeys).literalTxtTo(enLang, args)
api.userChat.system(watcherId(Chat.Id(game.id)), translated)
if (game.nonAi) api.userChat.system(Chat.Id(game.id), translated)
val apiCall =
if (persistent) api.userChat.system _
else api.userChat.volatile _
apiCall(watcherId(Chat.Id(game.id)), translated)
if (game.nonAi) apiCall(Chat.Id(game.id), translated)
}
def systemForOwners(chatId: Chat.Id, message: SelectI18nKey, args: Any*): Unit = {

View File

@ -17,7 +17,7 @@ final private class Moretimer(
if (pov.game.hasClock) give(pov.game, List(!pov.color), duration).some
else
pov.game.hasCorrespondenceClock option {
messenger.system(pov.game, (_.untranslated(s"${!pov.color} gets more time")))
messenger.volatile(pov.game, (_.untranslated(s"${!pov.color} gets more time")))
val p = pov.game.correspondenceGiveTime
p.game.correspondenceClock.map(Event.CorrespondenceClock.apply).fold(p)(p + _)
}
@ -35,7 +35,7 @@ final private class Moretimer(
case (c, color) => c.giveTime(color, centis)
}
colors.foreach { c =>
messenger.system(game, (_.untranslated(s"$c + ${duration.value.toSeconds} seconds")))
messenger.volatile(game, (_.untranslated(s"$c + ${duration.value.toSeconds} seconds")))
}
(game withClock newClock) ++ colors.map { Event.ClockInc(_, centis) }
}