Skip to content

Commit

Permalink
build: 2.0.0-RC
Browse files Browse the repository at this point in the history
  • Loading branch information
cssxsh committed Sep 25, 2022
1 parent 82879b8 commit 023b8f4
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 32 deletions.
21 changes: 11 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "xyz.cssxsh.mirai.plugin"
version = "2.0.0-M8"
version = "2.0.0-RC"

repositories {
mavenLocal()
Expand All @@ -16,8 +16,8 @@ repositories {
}

dependencies {
implementation("org.jsoup:jsoup:1.15.2")
implementation("xyz.cssxsh.pixiv:pixiv-client:1.2.4") {
implementation("org.jsoup:jsoup:1.15.3")
implementation("xyz.cssxsh.pixiv:pixiv-client:1.2.6") {
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.jetbrains.kotlinx")
exclude(group = "org.slf4j")
Expand All @@ -31,15 +31,16 @@ dependencies {
compileOnly("net.mamoe:mirai-core:2.13.0-M1")
compileOnly("net.mamoe:mirai-core-utils:2.13.0-M1")
// dependsOn
compileOnly("xyz.cssxsh.mirai:mirai-hibernate-plugin:2.4.3")
compileOnly("xyz.cssxsh.mirai:mirai-selenium-plugin:2.2.2")
compileOnly("xyz.cssxsh.mirai:mirai-skia-plugin:1.1.7")
compileOnly("xyz.cssxsh.mirai:mirai-hibernate-plugin:2.4.4")
compileOnly("xyz.cssxsh.mirai:mirai-selenium-plugin:2.2.3")
compileOnly("xyz.cssxsh.mirai:mirai-skia-plugin:1.1.9")

testImplementation(kotlin("test"))
testImplementation("net.mamoe:mirai-slf4j-bridge:1.2.0")
testImplementation("xyz.cssxsh.mirai:mirai-hibernate-plugin:2.4.3")
testImplementation("xyz.cssxsh.mirai:mirai-selenium-plugin:2.2.2")
testImplementation("xyz.cssxsh.mirai:mirai-skia-plugin:1.1.7")
testImplementation("org.slf4j:slf4j-simple:2.0.0")
testImplementation("net.mamoe:mirai-logging-slf4j:2.13.0-M1")
testImplementation("xyz.cssxsh.mirai:mirai-hibernate-plugin:2.4.4")
testImplementation("xyz.cssxsh.mirai:mirai-selenium-plugin:2.2.3")
testImplementation("xyz.cssxsh.mirai:mirai-skia-plugin:1.1.9")
}

mirai {
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/xyz/cssxsh/mirai/pixiv/PixivClientPool.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public object PixivClientPool : ReadOnlyProperty<PixivHelper, PixivAuthClient>,
logger.warning { "Api 超时, 已忽略: ${throwable.message}" }
true
}
is java.net.UnknownHostException,
is java.net.NoRouteToHostException -> false
is IOException -> {
logger.warning { "Api 错误, 已忽略: $throwable" }
true
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/xyz/cssxsh/mirai/pixiv/PixivConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal fun initConfiguration() {
ProfileFolder.mkdirs()
ArticleFolder.mkdirs()
UgoiraImagesFolder.mkdirs()
ExistsImagesFolder.mkdirs()
OtherImagesFolder.mkdirs()
ExistsImagesFolder.mkdirs()
logger.info { "CacheFolder: ${CacheFolder.absolutePath}" }
logger.info { "BackupFolder: ${BackupFolder.absolutePath}" }
Expand Down
7 changes: 3 additions & 4 deletions src/main/kotlin/xyz/cssxsh/mirai/pixiv/PixivHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ import kotlin.coroutines.*
* Pixiv 助手
* @see PixivHelperPool.helper
*/
public class PixivHelper internal constructor(public val id: Long, parentCoroutineContext: CoroutineContext) :
public class PixivHelper internal constructor(public val id: Long, parentContext: CoroutineContext) :
CoroutineScope {

private val logger by lazy { MiraiLogger.Factory.create(this::class, identity = "pixiv-helper-${id}") }
private val logger = MiraiLogger.Factory.create(this::class, identity = "pixiv-helper-${id}")

override val coroutineContext: CoroutineContext =
parentCoroutineContext + CoroutineName(name = "pixiv-helper-${id}")
override val coroutineContext: CoroutineContext = parentContext + CoroutineName(name = "pixiv-helper-${id}")

public val client: PixivAuthClient by PixivClientPool

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import xyz.cssxsh.mirai.pixiv.command.*
import xyz.cssxsh.mirai.pixiv.data.*

public object PixivHelperPlugin : KotlinPlugin(
JvmPluginDescription(id = "xyz.cssxsh.mirai.plugin.pixiv-helper", version = "2.0.0-M8") {
JvmPluginDescription(id = "xyz.cssxsh.mirai.plugin.pixiv-helper", version = "2.0.0-M9") {
name("pixiv-helper")
author("cssxsh")

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/xyz/cssxsh/mirai/pixiv/PixivHelperPool.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public object PixivHelperPool : ReadOnlyProperty<Contact, PixivHelper>, Coroutin
@Synchronized
public fun helper(contact: Contact): PixivHelper {
return helpers.getOrPut(contact.id) {
PixivHelper(id = contact.id, parentCoroutineContext = coroutineContext)
PixivHelper(id = contact.id, parentContext = coroutineContext)
}
}
}
8 changes: 6 additions & 2 deletions src/main/kotlin/xyz/cssxsh/mirai/pixiv/PixivProperty.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ internal const val ERO_SFW_PROPERTY = "xyz.cssxsh.mirai.plugin.pixiv.ero.sfw"

internal const val ERO_STANDARD_PROPERTY = "xyz.cssxsh.mirai.plugin.pixiv.ero.standard"

internal const val TAG_COOLING_PROPERTY = "xyz.cssxsh.mirai.plugin.pixiv.tag.cooling"

internal const val TAG_SFW_PROPERTY = "xyz.cssxsh.mirai.plugin.pixiv.tag.sfw"

internal const val CACHE_CAPACITY_PROPERTY = "xyz.cssxsh.mirai.plugin.pixiv.cache.capacity"
Expand Down Expand Up @@ -281,8 +279,14 @@ internal fun illust(pid: Long) = images(pid).resolve("${pid}.json")
*/
internal fun ugoira(pid: Long) = images(pid).resolve("${pid}.ugoira.json")

/**
* 从 [Contact] 上下文得到 [PixivHelper]
*/
public val Contact.helper: PixivHelper by PixivHelperPool

/**
* 从 [CommandSender] 上下文得到 [PixivClientPool.AuthClient]
*/
public fun CommandSender.client(): PixivClientPool.AuthClient {
return when {
isUser() -> PixivClientPool.get(id = subject.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public object PixivMethodCommand : CompositeCommand(
val json = File("cookie.json")
sendMessage("加载 cookie 从 ${json.absolutePath}")
val auth = pixiv.cookie {
@OptIn(ExperimentalSerializationApi::class)
PixivJson.decodeFromString<List<EditThisCookie>>(json.readText()).map { it.toCookie() }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public object PixivTaskCommand : CompositeCommand(
}

@SubCommand
@Description("定时任务,删除")
@Description("任务定时")
public suspend fun CommandSender.cron(id: String, cron: Cron) {
val message = try {
when (val task = PixivScheduler[id]) {
Expand All @@ -113,14 +113,14 @@ public object PixivTaskCommand : CompositeCommand(
}
}
} catch (cause: Exception) {
"定时任务${id}删除失败${cause.message}"
"任务${id}定时失败${cause.message}"
}

sendMessage(message)
}

@SubCommand
@Description("定时任务,删除")
@Description("删除任务")
public suspend fun CommandSender.delete(id: String) {
val message = try {
when (val task = PixivScheduler.remove(id)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
package xyz.cssxsh.mirai.pixiv.tools

import io.ktor.client.features.*
import kotlinx.coroutines.*
import org.junit.jupiter.api.*
import java.io.*

internal class ImageSearcherTest {

private val picUrl = ""

init {
ImageSearcher.ignore = {
println(it)
it is IOException || it is HttpRequestTimeoutException
}
}

@Test
fun json(): Unit = runBlocking {
ImageSearcher.json(url = picUrl).also {
Expand Down

0 comments on commit 023b8f4

Please sign in to comment.