feat: 添加白名单状态验证

This commit is contained in:
叁玖领域 2026-06-05 11:54:33 +08:00
parent 7ec5cb559e
commit 7c9e1b5b9a
3 changed files with 26 additions and 11 deletions

View File

@ -3,7 +3,9 @@
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="userId" value="43b882ab:19e8e7ab67a:-7ff2" />
<option name="migrated" value="true" />
<option name="pristineConfig" value="false" />
<option name="userId" value="-ef169b8:19dcecdb453:-7ffe" />
</MTProjectMetadataState>
</option>
</component>

View File

@ -3,5 +3,5 @@ org.gradle.downloadSources=false
org.gradle.parallel=true
org.gradle.degree_of_parallelism=16
project_group=top.r3944realms.ltdmanager
project_version=1.19-SNAPSHOT
project_version=1.20-SNAPSHOT
dg_lab_version=4.4.14.19

View File

@ -208,7 +208,7 @@ class InvitationCodesModule(
val placeholders = java.lang.String.join(",", Collections.nCopies(qqIds.size, "?"))
// 修正SQL语句的表名引用
val sql = """
SELECT q.player_id, q.effective, q.is_used, q.qq
SELECT q.player_id, q.effective, q.is_used, q.qq, q.status
FROM ltd_manager_bot.qualified_user_info q
WHERE q.qq IN ($placeholders)
""".trimIndent()
@ -223,20 +223,33 @@ class InvitationCodesModule(
pstmt.executeQuery().use { rs ->
// 创建结果映射表
val resultMap = mutableMapOf<Long, Triple<Long?, Boolean?, Boolean?>>()
var invalidMap = mutableMapOf<Long, String?>()
while (rs.next()) {
val state = rs.getInt("status")
val qq = rs.getLong("qq")
val playerId = rs.getLong("player_id")
// 处理可能的null值
val playerIdValue = if (rs.wasNull()) null else playerId
val effective = rs.getBoolean("effective")
val isUsed = rs.getBoolean("is_used")
resultMap[qq] = Triple(playerIdValue, effective, isUsed)
invalidMap[qq] = when (state) {
1 -> {
val playerId = rs.getLong("player_id")
// 处理可能的null值
val playerIdValue = if (rs.wasNull()) null else playerId
val effective = rs.getBoolean("effective")
val isUsed = rs.getBoolean("is_used")
resultMap[qq] = Triple(playerIdValue, effective, isUsed)
null
}
2 -> "白名单在审核中,请耐心等待"
3 -> "白名单不通过,无权获得邀请码"
else -> "无效状态,请联系管理员,错误状态码: $state"
}
}
// 分类处理每个消息
for (msg in msgs) {
var invalidMsg = invalidMap[msg.userId]
if (invalidMsg != null) { //无效时这里有值
sendFailedMessage(napCatClient, msg.userId, msg.realId, msg.time, invalidMsg)
return
}
val result = resultMap[msg.userId]
when {