remove /fen and watcher

pull/95/head
Thibault Duplessis 2014-07-20 23:55:32 +02:00
parent 6c0d8d7aa5
commit b9f9ed73cf
4 changed files with 0 additions and 49 deletions

View File

@ -95,11 +95,4 @@ object Analyse extends LilaController {
private def gameOpening(game: GameModel) =
if (game.fromPosition || game.variant.exotic) none
else chess.OpeningExplorer openingOf game.pgnMoves
def fen(id: String) = Open { implicit ctx =>
OptionOk(GameRepo game id) { game =>
Env.round fenUrlWatch game
chess.format.Forsyth >> game.toChess
}
}
}

View File

@ -143,7 +143,6 @@ POST /$gameId<\w{8}>/request-analysis controllers.Analyse.requestAnalysis(ga
POST /$gameId<\w{8}>/better-analysis/$color<white|black> controllers.Analyse.betterAnalysis(gameId: String, color: String)
POST /$gameId<\w{8}>/post-analysis controllers.Analyse.postAnalysis(gameId: String)
GET /$gameId<\w{8}>/pgn controllers.Analyse.pgn(gameId: String)
GET /$gameId<\w{8}>/fen controllers.Analyse.fen(gameId: String)
# Pref
POST /pref/:name controllers.Pref.set(name: String)

View File

@ -128,11 +128,6 @@ final class Env(
chat = hub.actor.chat,
i18nKeys = i18nKeys)
lazy val fenUrlWatch = new FenUrlWatch(
roundMap = roundMap,
reporter = hub.actor.report,
scheduler = system.scheduler)
def version(gameId: String): Fu[Int] =
socketHub ? Ask(gameId, GetVersion) mapTo manifest[Int]

View File

@ -1,36 +0,0 @@
package lila.round
import scala.concurrent.duration._
import actorApi.round.Cheat
import lila.game.Game
import lila.hub.actorApi.map.Tell
private[round] final class FenUrlWatch(
roundMap: akka.actor.ActorRef,
reporter: akka.actor.ActorSelection,
scheduler: akka.actor.Scheduler) {
private val stack = lila.memo.Builder.expiry[String, Int](30.seconds)
def apply(game: Game) {
if (game.playable) {
val id = game.id + game.turnColor.name.head
~Option(stack getIfPresent id) match {
case nb if nb < 5 => stack.put(id, nb + 1)
case nb =>
play.api.Logger("FenUrlWatch").warn(s"Detected http://lichess.org/${game.id} ${game.turnColor}")
stack.invalidate(id)
scheduler.scheduleOnce(
(1 + scala.util.Random.nextInt(15)).seconds,
roundMap,
Tell(game.id, Cheat(game.turnColor))
)
game.player.userId foreach { userId =>
reporter ! lila.hub.actorApi.report.Cheater(userId,
s"Cheat detected on http://lichess.org/${game.id}, using a FEN bot.")
}
}
}
}
}