mirror of
https://github.com/MewoLab/AquaDX.git
synced 2025-10-26 04:22:38 +00:00
[+] Automatically ban people with unacceptable names
This commit is contained in:
parent
60661757c6
commit
08c27b6c58
@ -13,6 +13,7 @@ import icu.samnyan.aqua.sega.general.model.Card
|
|||||||
import icu.samnyan.aqua.sega.general.service.CardService
|
import icu.samnyan.aqua.sega.general.service.CardService
|
||||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserDataRepo
|
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserDataRepo
|
||||||
import icu.samnyan.aqua.sega.wacca.model.db.WcUserRepo
|
import icu.samnyan.aqua.sega.wacca.model.db.WcUserRepo
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import org.springframework.web.bind.annotation.RestController
|
import org.springframework.web.bind.annotation.RestController
|
||||||
import kotlin.jvm.optionals.getOrNull
|
import kotlin.jvm.optionals.getOrNull
|
||||||
@ -150,7 +151,12 @@ class CardGameService(
|
|||||||
val wacca: WcUserRepo,
|
val wacca: WcUserRepo,
|
||||||
val ongeki: icu.samnyan.aqua.sega.ongeki.dao.userdata.UserDataRepository,
|
val ongeki: icu.samnyan.aqua.sega.ongeki.dao.userdata.UserDataRepository,
|
||||||
val diva: icu.samnyan.aqua.sega.diva.dao.userdata.PlayerProfileRepository,
|
val diva: icu.samnyan.aqua.sega.diva.dao.userdata.PlayerProfileRepository,
|
||||||
|
val safety: AquaNetSafetyService
|
||||||
) {
|
) {
|
||||||
|
companion object {
|
||||||
|
val log = logger()
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun migrate(crd: Card, games: List<String>) = async {
|
suspend fun migrate(crd: Card, games: List<String>) = async {
|
||||||
// Migrate data from the card to the user's ghost card
|
// Migrate data from the card to the user's ghost card
|
||||||
// An easy migration is to change the UserData card field to the user's ghost card
|
// An easy migration is to change the UserData card field to the user's ghost card
|
||||||
@ -180,4 +186,21 @@ class CardGameService(
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
) }
|
) }
|
||||||
|
|
||||||
|
// Every hour
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
@Scheduled(fixedDelay = 3600000)
|
||||||
|
suspend fun autoBan() {
|
||||||
|
log.info("Running auto-ban")
|
||||||
|
|
||||||
|
// Ban any players with unacceptable names
|
||||||
|
for (repo in listOf(maimai2, chusan, wacca, ongeki)) {
|
||||||
|
repo.findAll().filter { it.card != null }.forEach { data ->
|
||||||
|
if (!safety.isSafe(data.userName)) {
|
||||||
|
data.card!!.rankingBanned = true
|
||||||
|
async { (repo as GenericUserDataRepo<IUserData>).save(data) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user