|
3 | 3 | package com.diyigemt.arona.arona.command
|
4 | 4 |
|
5 | 5 | import com.diyigemt.arona.arona.Arona
|
6 |
| -import com.diyigemt.arona.arona.database.DatabaseProvider.dbQuery |
7 | 6 | import com.diyigemt.arona.arona.database.DatabaseProvider.dbQuerySuspended
|
8 | 7 | import com.diyigemt.arona.arona.database.image.ImageCacheSchema.Companion.findImage
|
9 | 8 | import com.diyigemt.arona.arona.database.image.contactType
|
@@ -92,6 +91,7 @@ class TrainerCommand : AbstractCommand(
|
92 | 91 | private suspend fun getImage(name: String): ServerResponse<List<ImageQueryData>> {
|
93 | 92 | return NetworkTool.request<List<ImageQueryData>>(BackendEndpoint.QueryImage) {
|
94 | 93 | parameter("name", name)
|
| 94 | + parameter("method", 3) |
95 | 95 | }.getOrThrow()
|
96 | 96 | }
|
97 | 97 |
|
@@ -133,33 +133,36 @@ class TrainerCommand : AbstractCommand(
|
133 | 133 | getImage(match).run {
|
134 | 134 | data?.run r1@{
|
135 | 135 | if (code != 200) {
|
| 136 | + val d = filterIndexed { index, _ -> index < 8 }.sortedBy { it.name.length } |
136 | 137 | val mdConfig = readUserPluginConfigOrDefault(BuildInCommandOwner, default = BaseConfig()).markdown
|
137 | 138 | if (mdConfig.enable) {
|
138 | 139 | val md = tencentCustomMarkdown {
|
139 | 140 | h1("没有找到与 \"${match}\" 有关的信息")
|
140 | 141 | +"是否想要查询:"
|
| 142 | + indexedList { |
| 143 | + d.forEach { |
| 144 | + +it.name |
| 145 | + } |
| 146 | + } |
141 | 147 | }
|
142 | 148 | val btn = tencentCustomKeyboard {
|
143 |
| - filterIndexed { index, _ -> index < 4 } |
144 |
| - .sortedBy { it.name.length } |
145 |
| - .forEachIndexed { idx, stu -> |
| 149 | + d.forEachIndexed { idx, stu -> |
146 | 150 | row {
|
147 | 151 | button(idx) {
|
148 | 152 | render {
|
149 |
| - label = stu.name |
| 153 | + label = (idx + 1).toString() |
150 | 154 | }
|
151 | 155 | action {
|
152 | 156 | data = "/攻略 ${stu.name}"
|
153 | 157 | }
|
154 | 158 | }
|
155 | 159 | }
|
156 | 160 | }
|
157 |
| - } |
| 161 | + }.windowed(4) |
158 | 162 | sendMessage(MessageChainBuilder().append(md).append(btn).build())
|
159 | 163 | } else {
|
160 | 164 | 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}" } |
163 | 166 | .joinToString("\n")
|
164 | 167 | }")
|
165 | 168 | }
|
|
0 commit comments