Skip to content

Commit 370cc61

Browse files
committed
refactor(core): 移除测试中的过期注解,优化客户端引擎逻辑
close #294
1 parent 51286be commit 370cc61

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

simbot-component-kook-core/api/simbot-component-kook-core.api

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ public abstract interface class love/forte/simbot/component/kook/KookVoiceMember
318318
public fun moveReserve (Llove/forte/simbot/common/id/ID;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
319319
}
320320

321+
public abstract interface annotation class love/forte/simbot/component/kook/blacklist/ExperimentalBlacklistApi : java/lang/annotation/Annotation {
322+
}
323+
321324
public abstract interface class love/forte/simbot/component/kook/bot/KookBot : kotlinx/coroutines/CoroutineScope, love/forte/simbot/bot/Bot {
322325
public fun cancel (Ljava/lang/Throwable;)V
323326
public fun getAvatar ()Ljava/lang/String;

simbot-component-kook-core/src/commonTest/kotlin/love/forte/simbot/component/kook/blacklist/KookGuildBlacklistOperatorTest.kt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020

2121
package love.forte.simbot.component.kook.blacklist
2222

23-
import io.ktor.client.*
2423
import io.ktor.client.engine.*
2524
import io.ktor.client.engine.mock.*
26-
import io.ktor.client.request.*
2725
import io.ktor.http.*
2826
import kotlinx.coroutines.flow.toList
2927
import kotlinx.coroutines.test.runTest
@@ -51,22 +49,15 @@ import kotlin.test.assertTrue
5149
*
5250
* @author ForteScarlet
5351
*/
54-
@OptIn(ExperimentalBlacklistApi::class)
5552
class KookGuildBlacklistOperatorTest {
5653

57-
/**
58-
* 创建一个用于测试的 mock HttpClient
59-
*/
60-
private fun createMockClient(handler: suspend MockRequestHandleScope.(HttpRequestData) -> HttpResponseData): HttpClient {
61-
return HttpClient(MockEngine(handler))
62-
}
63-
6454
/**
6555
* 创建一个用于测试的 mock KookBot
6656
*/
6757
private fun createMockBot(client: HttpClientEngine): KookBot {
6858
val sourceBot = BotFactory.create(Ticket.botWsTicket("test_client_id", "test_token")) {
69-
clientEngine = client // TODO()
59+
clientEngine = client
60+
wsEngine = client
7061
}
7162

7263
return object : KookBot {

simbot-component-kook-stdlib/src/commonMain/kotlin/love/forte/simbot/kook/stdlib/internal/ActualEnumMap.kt

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
/*
2-
* Copyright (c) 2023. ForteScarlet.
2+
* Copyright (c) 2023-2025. ForteScarlet.
33
*
4-
* This file is part of simbot-component-kook.
4+
* This file is part of simbot-component-kook.
55
*
6-
* simbot-component-kook is free software: you can redistribute it and/or modify it under the terms of
7-
* the GNU Lesser General Public License as published by the Free Software Foundation,
8-
* either version 3 of the License, or (at your option) any later version.
6+
* simbot-component-kook is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
910
*
10-
* simbot-component-kook is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11-
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12-
* See the GNU Lesser General Public License for more details.
11+
* simbot-component-kook is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
1315
*
14-
* You should have received a copy of the GNU Lesser General Public License along with simbot-component-kook,
15-
* If not, see <https://www.gnu.org/licenses/>.
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with simbot-component-kook,
18+
* If not, see <https://www.gnu.org/licenses/>.
1619
*/
1720

1821
package love.forte.simbot.kook.stdlib.internal
@@ -40,12 +43,12 @@ internal class ActualEnumMap<E : Enum<E>, V> private constructor(private val val
4043
}
4144

4245
/**
43-
* @throws IndexOutOfBoundsException if key is out of range
46+
* @throws IndexOutOfBoundsException if [key] is out of range
4447
*/
4548
operator fun get(key: E): V = values[key.ordinal]
4649

4750
/**
48-
* @throws IndexOutOfBoundsException if key is out of range
51+
* @throws IndexOutOfBoundsException if [key] is out of range
4952
*/
5053
operator fun set(key: E, value: V) {
5154
values[key.ordinal] = value

0 commit comments

Comments
 (0)