Skip to content

Commit 72e7470

Browse files
committed
feat(arona): 支持最新api
1 parent 7a4eb27 commit 72e7470

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

arona/arona-plugin/arona/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
}
88

99
val projectMainClass = "com.diyigemt.arona.arona.Arona"
10-
version = "1.3.19"
10+
version = "1.3.20"
1111
kotlin {
1212
compilerOptions {
1313
freeCompilerArgs.add("-Xcontext-receivers")

arona/arona-plugin/arona/src/main/kotlin/com/diyigemt/arona/arona/command/TrainerCommand.kt

+11-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package com.diyigemt.arona.arona.command
44

55
import com.diyigemt.arona.arona.Arona
6-
import com.diyigemt.arona.arona.database.DatabaseProvider.dbQuery
76
import com.diyigemt.arona.arona.database.DatabaseProvider.dbQuerySuspended
87
import com.diyigemt.arona.arona.database.image.ImageCacheSchema.Companion.findImage
98
import com.diyigemt.arona.arona.database.image.contactType
@@ -92,6 +91,7 @@ class TrainerCommand : AbstractCommand(
9291
private suspend fun getImage(name: String): ServerResponse<List<ImageQueryData>> {
9392
return NetworkTool.request<List<ImageQueryData>>(BackendEndpoint.QueryImage) {
9493
parameter("name", name)
94+
parameter("method", 3)
9595
}.getOrThrow()
9696
}
9797

@@ -133,33 +133,36 @@ class TrainerCommand : AbstractCommand(
133133
getImage(match).run {
134134
data?.run r1@{
135135
if (code != 200) {
136+
val d = filterIndexed { index, _ -> index < 8 }.sortedBy { it.name.length }
136137
val mdConfig = readUserPluginConfigOrDefault(BuildInCommandOwner, default = BaseConfig()).markdown
137138
if (mdConfig.enable) {
138139
val md = tencentCustomMarkdown {
139140
h1("没有找到与 \"${match}\" 有关的信息")
140141
+"是否想要查询:"
142+
indexedList {
143+
d.forEach {
144+
+it.name
145+
}
146+
}
141147
}
142148
val btn = tencentCustomKeyboard {
143-
filterIndexed { index, _ -> index < 4 }
144-
.sortedBy { it.name.length }
145-
.forEachIndexed { idx, stu ->
149+
d.forEachIndexed { idx, stu ->
146150
row {
147151
button(idx) {
148152
render {
149-
label = stu.name
153+
label = (idx + 1).toString()
150154
}
151155
action {
152156
data = "/攻略 ${stu.name}"
153157
}
154158
}
155159
}
156160
}
157-
}
161+
}.windowed(4)
158162
sendMessage(MessageChainBuilder().append(md).append(btn).build())
159163
} else {
160164
sendMessage("没有与${match}对应的信息, 是否想要输入:\n${
161-
filterIndexed { index, _ -> index < 4 }
162-
.mapIndexed { index, it -> "${index + 1}. /攻略 ${it.name}" }
165+
d.mapIndexed { index, it -> "${index + 1}. /攻略 ${it.name}" }
163166
.joinToString("\n")
164167
}")
165168
}

0 commit comments

Comments
 (0)