publish worst ragesitters to slack
parent
9dfb273a08
commit
1e84f6b712
|
@ -197,6 +197,15 @@ final class SlackApi(
|
|||
)
|
||||
)
|
||||
|
||||
def publishRageSit(userId: User.ID, rageSit: Int) = client(
|
||||
SlackMessage(
|
||||
username = "Ragesit offender",
|
||||
icon = "babyrage",
|
||||
text = linkifyUsers(s"$userId rageSit = $rageSit"),
|
||||
channel = rooms.tavernBots
|
||||
)
|
||||
)
|
||||
|
||||
private def link(url: String, name: String) = s"<$url|$name>"
|
||||
private def lichessLink(path: String, name: String) = s"<https://lichess.org$path|$name>"
|
||||
private def userLink(name: String): String = lichessLink(s"/@/$name?mod", name)
|
||||
|
|
|
@ -11,6 +11,7 @@ final class Env(
|
|||
messenger: lila.msg.MsgApi,
|
||||
reporter: lila.hub.actors.Report,
|
||||
chatApi: lila.chat.ChatApi,
|
||||
slackApi: lila.irc.SlackApi,
|
||||
userRepo: lila.user.UserRepo,
|
||||
lightUser: lila.common.LightUser.Getter,
|
||||
db: lila.db.Db,
|
||||
|
|
|
@ -18,6 +18,7 @@ final class PlaybanApi(
|
|||
feedback: PlaybanFeedback,
|
||||
userRepo: UserRepo,
|
||||
cacheApi: lila.memo.CacheApi,
|
||||
slackApi: lila.irc.SlackApi,
|
||||
messenger: MsgApi
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
||||
|
@ -231,15 +232,15 @@ final class PlaybanApi(
|
|||
update match {
|
||||
case RageSit.Inc(delta) =>
|
||||
rageSitCache.put(record.userId, fuccess(record.rageSit))
|
||||
(delta < 0) ?? {
|
||||
if (record.rageSit.isTerrible) funit
|
||||
else if (record.rageSit.isVeryBad) {
|
||||
(delta < 0 && record.rageSit.isVeryBad) ?? {
|
||||
messenger.postPreset(record.userId, MsgPreset.sittingAuto).void >>- {
|
||||
Bus.publish(
|
||||
lila.hub.actorApi.mod.AutoWarning(record.userId, MsgPreset.sittingAuto.name),
|
||||
"autoWarning"
|
||||
)
|
||||
messenger.postPreset(record.userId, MsgPreset.sittingAuto).void
|
||||
} else funit
|
||||
if (record.rageSit.isLethal && record.rageSitRecidive)
|
||||
slackApi.publishRageSit(record.userId, record.rageSit.counterView).unit
|
||||
}
|
||||
}
|
||||
case _ => funit
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ case class RageSit(counter: Int) extends AnyVal {
|
|||
def isBad = counter <= -40
|
||||
def isVeryBad = counter <= -80
|
||||
def isTerrible = counter <= -160
|
||||
def isLethal = counter <= -200
|
||||
|
||||
def goneWeight: Float =
|
||||
if (!isBad) 1f
|
||||
|
|
Loading…
Reference in New Issue