Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pull mod incompatibility list json from quiltmc.org #77

Merged
merged 1 commit into from
Aug 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,22 @@ package org.quiltmc.community.cozy.modules.logs.processors.quilt
import dev.kord.core.event.Event
import io.ktor.client.call.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.decodeFromJsonElement
import org.quiltmc.community.cozy.modules.logs.data.LoaderType
import org.quiltmc.community.cozy.modules.logs.data.Log
import org.quiltmc.community.cozy.modules.logs.data.Order
import org.quiltmc.community.cozy.modules.logs.types.LogProcessor
import kotlin.time.Duration.Companion.minutes

private const val THREAD_LINK = "https://forum.quiltmc.org/t/mod-incompatibility-megathread/261"
private const val THREAD_JSON = "$THREAD_LINK.json"
private const val JSON_LINK = "https://quiltmc.org/incompatible-mods.json"

private val CHECK_DELAY = 15.minutes

Expand Down Expand Up @@ -117,18 +116,10 @@ public class IncompatibleModProcessor : LogProcessor() {
}
}

val postText = client.get(THREAD_JSON)
.body<DiscoursePosts>()
.postStream
.posts
.first()
.cooked
val cozyJson = client.get(JSON_LINK)
.body<JsonElement>()

val cozyJson = postText
.substringAfter("// START COZY JSON")
.substringBefore("// END COZY JSON")

incompatibleMods = json.decodeFromString(cozyJson)
incompatibleMods = json.decodeFromJsonElement(cozyJson)
lastCheck = now
}
}
Expand All @@ -148,20 +139,4 @@ public class IncompatibleModProcessor : LogProcessor() {
public val type: Incompatibility,
public val note: String? = null,
)

@Serializable
public data class DiscoursePosts(
@SerialName("post_stream")
public val postStream: PostStream
)

@Serializable
public data class PostStream(
public val posts: List<CookedPost>
)

@Serializable
public data class CookedPost(
public val cooked: String
)
}
Loading