Merge pull request #5451 from ornicar/sitcounter-warn-close
Automatic warning and closure based on sit counter
This commit is contained in:
commit
dac810864d
|
@ -4,6 +4,8 @@ import akka.actor._
|
|||
import com.typesafe.config.Config
|
||||
import scala.concurrent.duration._
|
||||
|
||||
import lila.user.User
|
||||
|
||||
final class Env(
|
||||
config: Config,
|
||||
val scheduler: lila.common.Scheduler,
|
||||
|
@ -101,13 +103,16 @@ final class Env(
|
|||
system.lilaBus.publish(lila.hub.actorApi.security.CloseAccount(user.id), 'accountClose)
|
||||
}
|
||||
|
||||
system.lilaBus.subscribeFun('garbageCollect) {
|
||||
case lila.hub.actorApi.security.GarbageCollect(userId, _) =>
|
||||
system.scheduler.scheduleOnce(1 second) {
|
||||
closeAccount(userId, self = false)
|
||||
}
|
||||
system.lilaBus.subscribeFun('garbageCollect, 'playban) {
|
||||
case lila.hub.actorApi.security.GarbageCollect(userId, _) => kill(userId)
|
||||
case lila.hub.actorApi.playban.SitcounterClose(userId) => kill(userId)
|
||||
}
|
||||
|
||||
private def kill(userId: User.ID): Unit =
|
||||
system.scheduler.scheduleOnce(1 second) {
|
||||
closeAccount(userId, self = false)
|
||||
}
|
||||
|
||||
system.actorOf(Props(new actor.Renderer), name = RendererName)
|
||||
|
||||
lila.common.Chronometer.syncEffect(List(
|
||||
|
|
|
@ -95,9 +95,10 @@ object Mod extends LilaController {
|
|||
}
|
||||
|
||||
def closeAccount(username: String) = OAuthMod(_.CloseAccount) { _ => me =>
|
||||
modApi.closeAccount(me.id, username).flatMap {
|
||||
_.?? { user =>
|
||||
Env.current.closeAccount(user.id, self = false) map some
|
||||
UserRepo named username flatMap {
|
||||
_ ?? { user =>
|
||||
modLogApi.closeAccount(me.id, user.id) >>
|
||||
Env.current.closeAccount(user.id, self = false) map some
|
||||
}
|
||||
}
|
||||
}(actionResult(username))
|
||||
|
|
|
@ -82,6 +82,7 @@ package mod {
|
|||
|
||||
package playban {
|
||||
case class Playban(userId: String, mins: Int)
|
||||
case class SitcounterClose(userId: String)
|
||||
}
|
||||
|
||||
package captcha {
|
||||
|
|
|
@ -96,6 +96,12 @@ Losing rated games on purpose is called "sandbagging", and is not allowed on Lic
|
|||
Thank you for your understanding."""
|
||||
)
|
||||
|
||||
lazy val sittingAuto = ModPreset(
|
||||
subject = "Warning: leaving games / stalling on time",
|
||||
text = """In your game history, you have several games where you have left the game or just let the time run out instead of playing or resigning.
|
||||
This can be very annoying for your opponents. If this behavior continues to happen, we may be forced to terminate your account."""
|
||||
)
|
||||
|
||||
def maxFollow(username: String, max: Int) = ModPreset(
|
||||
subject = "Follow limit reached!",
|
||||
text = s"""Sorry, you can't follow more than $max players on Lichess.
|
||||
|
|
|
@ -127,7 +127,7 @@ final class Env(
|
|||
api.garbageCollect(sus, ipBan) >> publicChat.delete(sus)
|
||||
}
|
||||
}
|
||||
}), name = ActorName), 'finishGame, 'analysisReady, 'garbageCollect)
|
||||
}), name = ActorName), 'finishGame, 'analysisReady, 'garbageCollect, 'playban)
|
||||
}
|
||||
|
||||
object Env {
|
||||
|
|
|
@ -100,12 +100,6 @@ final class ModApi(
|
|||
(UserRepo disableTwoFactor user.id) >> logApi.disableTwoFactor(mod, user.id)
|
||||
}
|
||||
|
||||
def closeAccount(mod: String, username: String): Fu[Option[User]] = withUser(username) { user =>
|
||||
user.enabled ?? {
|
||||
logApi.closeAccount(mod, user.id) inject user.some
|
||||
}
|
||||
}
|
||||
|
||||
def reopenAccount(mod: String, username: String): Funit = withUser(username) { user =>
|
||||
!user.enabled ?? {
|
||||
(UserRepo reopen user.id) >> logApi.reopenAccount(mod, user.id)
|
||||
|
|
|
@ -27,7 +27,8 @@ final class Env(
|
|||
sandbag = new SandbagWatch(messenger),
|
||||
feedback = feedback,
|
||||
bus = bus,
|
||||
asyncCache = asyncCache
|
||||
asyncCache = asyncCache,
|
||||
messenger = messenger
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import lila.common.PlayApp.{ startedSinceMinutes, isDev }
|
|||
import lila.db.BSON._
|
||||
import lila.db.dsl._
|
||||
import lila.game.{ Pov, Game, Player, Source }
|
||||
import lila.message.{ MessageApi, ModPreset }
|
||||
import lila.user.{ User, UserRepo }
|
||||
|
||||
import org.joda.time.DateTime
|
||||
|
@ -18,7 +19,8 @@ final class PlaybanApi(
|
|||
sandbag: SandbagWatch,
|
||||
feedback: PlaybanFeedback,
|
||||
bus: lila.common.Bus,
|
||||
asyncCache: lila.memo.AsyncCache.Builder
|
||||
asyncCache: lila.memo.AsyncCache.Builder,
|
||||
messenger: MessageApi
|
||||
) {
|
||||
|
||||
import lila.db.BSON.BSONJodaDateTimeHandler
|
||||
|
@ -191,7 +193,26 @@ final class PlaybanApi(
|
|||
o => o map { d => legiferate(record, d) } getOrElse funit
|
||||
}
|
||||
} addEffect { _ =>
|
||||
sitAndDcCounterCache refresh userId
|
||||
if (sitAndDcCounterChange != 0) {
|
||||
sitAndDcCounterCache refresh userId
|
||||
if (sitAndDcCounterChange < 0) {
|
||||
sitAndDcCounter(userId) map { counter =>
|
||||
if (counter == -10) {
|
||||
for {
|
||||
mod <- UserRepo.lichess
|
||||
user <- UserRepo byId userId
|
||||
} yield (mod zip user).headOption.?? {
|
||||
case (m, u) =>
|
||||
lila.log("stall").info(s"https://lichess.org/@/${u.username}")
|
||||
messenger.sendPreset(m, u, ModPreset.sittingAuto).void
|
||||
}
|
||||
} else if (counter <= -20) {
|
||||
lila.log("stall").warn(s"Close https://lichess.org/@/${userId} ragesit=$counter")
|
||||
// bus.publish(lila.hub.actorApi.playban.SitcounterClose(userId), 'playban)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}.void logFailure lila.log("playban")
|
||||
|
|
Loading…
Reference in a new issue