Skip to content

Commit

Permalink
build: 1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
cssxsh committed Oct 15, 2022
1 parent ea2514f commit 527513f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "xyz.cssxsh.mirai.novelai"
version = "1.0.7"
version = "1.0.8"

repositories {
mavenLocal()
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/xyz/cssxsh/mirai/novelai/NovelAiHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public object NovelAiHelper : KotlinPlugin(
JvmPluginDescription(
id = "xyz.cssxsh.mirai.plugin.novelai-helper",
name = "novelai-helper",
version = "1.0.7",
version = "1.0.8",
) {
author("cssxsh")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public object NovelAiCommand : SimpleCommand(
}
}

val seed = random.nextLong(0, 2 shl 32 - 1)
val seed = random.nextLong(0, 2L shl 32 - 1)
NovelAiHelper.logger.info(input.joinToString(", ", "generate image seed: $seed, tags: "))
val generate = try {
NovelAiHelper.client.ai.generateImage(input = input.joinToString(",")) {
Expand All @@ -74,6 +74,6 @@ public object NovelAiCommand : SimpleCommand(
return
}
val image = generate.data.toExternalResource().use { subject.uploadImage(it) }
sendMessage(fromEvent.message.quote() + image + "\n$seed")
sendMessage(fromEvent.message.quote() + image + "\nseed=$seed")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public object NovelAiFuCommand : SimpleCommand(
}
}

val seed = random.nextLong(0, 2 shl 32 - 1)
val seed = random.nextLong(0, 2L shl 32 - 1)
NovelAiHelper.logger.info(input.joinToString(", ", "generate image seed: $seed, tags: "))
val generate = try {
client.ai.generateImage(input = input.joinToString(",")) {
Expand All @@ -76,6 +76,6 @@ public object NovelAiFuCommand : SimpleCommand(
return
}
val image = subject.uploadImage(generate.data.toExternalResource().toAutoCloseable())
sendMessage(fromEvent.message.quote() + image + "\n$seed")
sendMessage(fromEvent.message.quote() + image + "\nseed=$seed")
}
}
4 changes: 3 additions & 1 deletion src/main/kotlin/xyz/cssxsh/novelai/NovelAiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public open class NovelAiClient(internal val config: NovelAiClientConfig, intern
HttpStatusCode.Conflict -> throw NovelAiApiException(error = response.body())
HttpStatusCode.InternalServerError -> throw NovelAiApiException(error = response.body())
}
if (response.status.value in 500..599) throw ServerResponseException(response, response.body())
if ((response.contentLength() ?: 0) == 0L) throw ServerResponseException(response, response.body())
}
}
Auth {
Expand All @@ -63,7 +65,7 @@ public open class NovelAiClient(internal val config: NovelAiClientConfig, intern
BrowserUserAgent()
ContentEncoding()
defaultRequest {
if (!default) url(config.baseUrl)
if (default) url("https://api.novelai.net") else url(config.baseUrl)
}
engine {
config {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/xyz/cssxsh/novelai/ai/AIController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public class AIController(private val client: NovelAiClient) {
"data" -> data = packet.decodeBase64Bytes().readBytes()
}
}
if (event.isEmpty()) {
if (data.isEmpty()) {
throw NovelAiApiException(error = Json.decodeFromString(key))
}

Expand Down

0 comments on commit 527513f

Please sign in to comment.