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