Skip to content

Commit 192aedc

Browse files
authored
Merge pull request #291 from simple-robot/dev/support-kook-voice-channel
增加 KookVoiceChannel 和 KookVoiceMember 等语音频道相关API支持
2 parents 765fba9 + a005757 commit 192aedc

File tree

22 files changed

+733
-298
lines changed

22 files changed

+733
-298
lines changed

simbot-component-kook-api/src/commonMain/kotlin/love/forte/simbot/kook/api/channel/ChannelKickoutApi.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ public class ChannelKickoutApi private constructor(
3939
channelId: String,
4040
userId: String
4141
) : KookPostApi<Unit>() {
42-
// TODO 在 KookVoiceChannel 中添加支持的上层API
43-
4442
public companion object Factory {
4543
private val PATH = ApiPath.create("channel", "kickout")
4644

simbot-component-kook-api/src/commonMain/kotlin/love/forte/simbot/kook/api/channel/ChannelMoveUserApi.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ package love.forte.simbot.kook.api.channel
2323
import kotlinx.serialization.DeserializationStrategy
2424
import kotlinx.serialization.SerialName
2525
import kotlinx.serialization.Serializable
26-
import kotlinx.serialization.builtins.ListSerializer
27-
import kotlinx.serialization.json.JsonElement
26+
import kotlinx.serialization.builtins.serializer
2827
import love.forte.simbot.kook.api.KookPostApi
2928
import kotlin.jvm.JvmStatic
3029

@@ -40,7 +39,7 @@ import kotlin.jvm.JvmStatic
4039
public class ChannelMoveUserApi private constructor(
4140
targetId: String,
4241
userIds: List<String>
43-
) : KookPostApi<List<JsonElement>>() {
42+
) : KookPostApi<Unit>() {
4443

4544
public companion object Factory {
4645
private val PATH = ApiPath.create("channel", "move-user")
@@ -66,8 +65,8 @@ public class ChannelMoveUserApi private constructor(
6665
ChannelMoveUserApi(targetId, userIds.asList())
6766
}
6867

69-
override val resultDeserializationStrategy: DeserializationStrategy<List<JsonElement>>
70-
get() = ListSerializer(JsonElement.serializer())
68+
override val resultDeserializationStrategy: DeserializationStrategy<Unit>
69+
get() = Unit.serializer()
7170

7271
override val apiPath: ApiPath
7372
get() = PATH

simbot-component-kook-api/src/commonTest/kotlin/love/forte/simbot/kook/api/channel/ChannelMoveUserApiTest.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,6 @@ class ChannelMoveUserApiTest {
281281
}
282282

283283
val client = HttpClient(mockEngine)
284-
val dataList = api.requestData(client, authorization)
285-
286-
assertNotNull(dataList)
287-
assertEquals(3, dataList.size)
288-
289-
// Verify we got JsonElement objects back
290-
assertTrue(dataList.all { it.toString().isNotEmpty() })
284+
api.requestData(client, authorization)
291285
}
292286
}

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

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ public abstract interface class love/forte/simbot/component/kook/KookChannel : l
3131
public fun deleteAsync ([Llove/forte/simbot/ability/DeleteOption;)Ljava/util/concurrent/CompletableFuture;
3232
public fun deleteBlocking ([Llove/forte/simbot/ability/DeleteOption;)V
3333
public fun deleteReserve ([Llove/forte/simbot/ability/DeleteOption;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
34+
public abstract fun getBot ()Llove/forte/simbot/component/kook/bot/KookBot;
3435
public abstract fun getCategory ()Llove/forte/simbot/component/kook/KookCategory;
3536
public abstract fun getCoroutineContext ()Lkotlin/coroutines/CoroutineContext;
3637
public fun getId ()Llove/forte/simbot/common/id/ID;
3738
public fun getName ()Ljava/lang/String;
3839
public abstract fun getSource ()Llove/forte/simbot/kook/objects/Channel;
3940
}
4041

41-
public abstract interface class love/forte/simbot/component/kook/KookChatChannel : kotlinx/coroutines/CoroutineScope, love/forte/simbot/component/kook/KookChannel, love/forte/simbot/definition/ChatChannel {
42+
public abstract interface class love/forte/simbot/component/kook/KookChatCapableChannel : kotlinx/coroutines/CoroutineScope, love/forte/simbot/component/kook/KookChannel, love/forte/simbot/definition/ChatChannel {
4243
public abstract fun getCategory ()Llove/forte/simbot/component/kook/KookCategory;
4344
public abstract fun getCoroutineContext ()Lkotlin/coroutines/CoroutineContext;
4445
public fun getName ()Ljava/lang/String;
@@ -50,9 +51,9 @@ public abstract interface class love/forte/simbot/component/kook/KookChatChannel
5051
public abstract synthetic fun send (Llove/forte/simbot/message/Message;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
5152
public synthetic fun send (Llove/forte/simbot/message/MessageContent;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
5253
public abstract synthetic fun send (Llove/forte/simbot/message/MessageContent;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
53-
public static synthetic fun send$default (Llove/forte/simbot/component/kook/KookChatChannel;Ljava/lang/String;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
54-
public static synthetic fun send$default (Llove/forte/simbot/component/kook/KookChatChannel;Llove/forte/simbot/message/Message;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
55-
public static synthetic fun send$default (Llove/forte/simbot/component/kook/KookChatChannel;Llove/forte/simbot/message/MessageContent;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
54+
public static synthetic fun send$default (Llove/forte/simbot/component/kook/KookChatCapableChannel;Ljava/lang/String;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
55+
public static synthetic fun send$default (Llove/forte/simbot/component/kook/KookChatCapableChannel;Llove/forte/simbot/message/Message;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
56+
public static synthetic fun send$default (Llove/forte/simbot/component/kook/KookChatCapableChannel;Llove/forte/simbot/message/MessageContent;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
5657
public fun sendAsync (ILjava/lang/String;Llove/forte/simbot/common/id/ID;Ljava/lang/String;Llove/forte/simbot/common/id/ID;)Ljava/util/concurrent/CompletableFuture;
5758
public fun sendAsync (Ljava/lang/String;)Ljava/util/concurrent/CompletableFuture;
5859
public fun sendAsync (Ljava/lang/String;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;)Ljava/util/concurrent/CompletableFuture;
@@ -61,9 +62,9 @@ public abstract interface class love/forte/simbot/component/kook/KookChatChannel
6162
public fun sendAsync (Llove/forte/simbot/message/Message;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;)Ljava/util/concurrent/CompletableFuture;
6263
public fun sendAsync (Llove/forte/simbot/message/MessageContent;)Ljava/util/concurrent/CompletableFuture;
6364
public fun sendAsync (Llove/forte/simbot/message/MessageContent;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;)Ljava/util/concurrent/CompletableFuture;
64-
public static synthetic fun sendAsync$default (Llove/forte/simbot/component/kook/KookChatChannel;Ljava/lang/String;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Ljava/util/concurrent/CompletableFuture;
65-
public static synthetic fun sendAsync$default (Llove/forte/simbot/component/kook/KookChatChannel;Llove/forte/simbot/message/Message;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Ljava/util/concurrent/CompletableFuture;
66-
public static synthetic fun sendAsync$default (Llove/forte/simbot/component/kook/KookChatChannel;Llove/forte/simbot/message/MessageContent;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Ljava/util/concurrent/CompletableFuture;
65+
public static synthetic fun sendAsync$default (Llove/forte/simbot/component/kook/KookChatCapableChannel;Ljava/lang/String;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Ljava/util/concurrent/CompletableFuture;
66+
public static synthetic fun sendAsync$default (Llove/forte/simbot/component/kook/KookChatCapableChannel;Llove/forte/simbot/message/Message;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Ljava/util/concurrent/CompletableFuture;
67+
public static synthetic fun sendAsync$default (Llove/forte/simbot/component/kook/KookChatCapableChannel;Llove/forte/simbot/message/MessageContent;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Ljava/util/concurrent/CompletableFuture;
6768
public fun sendBlocking (ILjava/lang/String;Llove/forte/simbot/common/id/ID;Ljava/lang/String;Llove/forte/simbot/common/id/ID;)Llove/forte/simbot/component/kook/message/KookMessageReceipt;
6869
public fun sendBlocking (Ljava/lang/String;)Llove/forte/simbot/component/kook/message/KookMessageReceipt;
6970
public synthetic fun sendBlocking (Ljava/lang/String;)Llove/forte/simbot/message/MessageReceipt;
@@ -75,9 +76,9 @@ public abstract interface class love/forte/simbot/component/kook/KookChatChannel
7576
public fun sendBlocking (Llove/forte/simbot/message/MessageContent;)Llove/forte/simbot/component/kook/message/KookMessageReceipt;
7677
public synthetic fun sendBlocking (Llove/forte/simbot/message/MessageContent;)Llove/forte/simbot/message/MessageReceipt;
7778
public fun sendBlocking (Llove/forte/simbot/message/MessageContent;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;)Llove/forte/simbot/component/kook/message/KookMessageReceipt;
78-
public static synthetic fun sendBlocking$default (Llove/forte/simbot/component/kook/KookChatChannel;Ljava/lang/String;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Llove/forte/simbot/component/kook/message/KookMessageReceipt;
79-
public static synthetic fun sendBlocking$default (Llove/forte/simbot/component/kook/KookChatChannel;Llove/forte/simbot/message/Message;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Llove/forte/simbot/component/kook/message/KookMessageReceipt;
80-
public static synthetic fun sendBlocking$default (Llove/forte/simbot/component/kook/KookChatChannel;Llove/forte/simbot/message/MessageContent;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Llove/forte/simbot/component/kook/message/KookMessageReceipt;
79+
public static synthetic fun sendBlocking$default (Llove/forte/simbot/component/kook/KookChatCapableChannel;Ljava/lang/String;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Llove/forte/simbot/component/kook/message/KookMessageReceipt;
80+
public static synthetic fun sendBlocking$default (Llove/forte/simbot/component/kook/KookChatCapableChannel;Llove/forte/simbot/message/Message;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Llove/forte/simbot/component/kook/message/KookMessageReceipt;
81+
public static synthetic fun sendBlocking$default (Llove/forte/simbot/component/kook/KookChatCapableChannel;Llove/forte/simbot/message/MessageContent;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Llove/forte/simbot/component/kook/message/KookMessageReceipt;
8182
public fun sendReserve (ILjava/lang/String;Llove/forte/simbot/common/id/ID;Ljava/lang/String;Llove/forte/simbot/common/id/ID;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
8283
public fun sendReserve (Ljava/lang/String;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
8384
public fun sendReserve (Ljava/lang/String;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
@@ -86,9 +87,12 @@ public abstract interface class love/forte/simbot/component/kook/KookChatChannel
8687
public fun sendReserve (Llove/forte/simbot/message/Message;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
8788
public fun sendReserve (Llove/forte/simbot/message/MessageContent;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
8889
public fun sendReserve (Llove/forte/simbot/message/MessageContent;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
89-
public static synthetic fun sendReserve$default (Llove/forte/simbot/component/kook/KookChatChannel;Ljava/lang/String;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
90-
public static synthetic fun sendReserve$default (Llove/forte/simbot/component/kook/KookChatChannel;Llove/forte/simbot/message/Message;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
91-
public static synthetic fun sendReserve$default (Llove/forte/simbot/component/kook/KookChatChannel;Llove/forte/simbot/message/MessageContent;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
90+
public static synthetic fun sendReserve$default (Llove/forte/simbot/component/kook/KookChatCapableChannel;Ljava/lang/String;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
91+
public static synthetic fun sendReserve$default (Llove/forte/simbot/component/kook/KookChatCapableChannel;Llove/forte/simbot/message/Message;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
92+
public static synthetic fun sendReserve$default (Llove/forte/simbot/component/kook/KookChatCapableChannel;Llove/forte/simbot/message/MessageContent;Llove/forte/simbot/common/id/ID;Llove/forte/simbot/common/id/ID;ILjava/lang/Object;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
93+
}
94+
95+
public abstract interface class love/forte/simbot/component/kook/KookChatChannel : love/forte/simbot/component/kook/KookChatCapableChannel {
9296
}
9397

9498
public final class love/forte/simbot/component/kook/KookComponent : love/forte/simbot/component/Component {
@@ -166,8 +170,13 @@ public abstract interface class love/forte/simbot/component/kook/KookGuild : kot
166170
public fun getOwnerReserve ()Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
167171
public abstract fun getSource ()Llove/forte/simbot/kook/objects/Guild;
168172
public fun getTopic ()Ljava/lang/String;
173+
public fun getVoiceChannel (Llove/forte/simbot/common/id/ID;)Llove/forte/simbot/component/kook/KookVoiceChannel;
174+
public fun getVoiceChannelAsync (Llove/forte/simbot/common/id/ID;)Ljava/util/concurrent/CompletableFuture;
175+
public fun getVoiceChannelReserve (Llove/forte/simbot/common/id/ID;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
176+
public abstract fun getVoiceChannels ()Llove/forte/simbot/common/collectable/Collectable;
169177
public abstract synthetic fun member (Llove/forte/simbot/common/id/ID;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
170178
public abstract synthetic fun owner (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
179+
public abstract synthetic fun voiceChannel (Llove/forte/simbot/common/id/ID;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
171180
}
172181

173182
public final class love/forte/simbot/component/kook/KookGuildNotExistsException : java/util/NoSuchElementException {
@@ -257,6 +266,27 @@ public abstract interface class love/forte/simbot/component/kook/KookUserChat :
257266
public fun sendReserve (Llove/forte/simbot/message/MessageContent;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
258267
}
259268

269+
public abstract interface class love/forte/simbot/component/kook/KookVoiceChannel : love/forte/simbot/component/kook/KookChatChannel {
270+
public abstract fun getMembers ()Llove/forte/simbot/common/collectable/Collectable;
271+
public abstract synthetic fun kickoutMember (Llove/forte/simbot/common/id/ID;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
272+
public fun kickoutMemberAsync (Llove/forte/simbot/common/id/ID;)Ljava/util/concurrent/CompletableFuture;
273+
public fun kickoutMemberBlocking (Llove/forte/simbot/common/id/ID;)V
274+
public fun kickoutMemberReserve (Llove/forte/simbot/common/id/ID;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
275+
public abstract synthetic fun moveMember (Llove/forte/simbot/common/id/ID;Ljava/lang/Iterable;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
276+
public synthetic fun moveMember (Llove/forte/simbot/common/id/ID;[Llove/forte/simbot/common/id/ID;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
277+
public fun moveMemberAsync (Llove/forte/simbot/common/id/ID;Ljava/lang/Iterable;)Ljava/util/concurrent/CompletableFuture;
278+
public fun moveMemberAsync (Llove/forte/simbot/common/id/ID;[Llove/forte/simbot/common/id/ID;)Ljava/util/concurrent/CompletableFuture;
279+
public fun moveMemberBlocking (Llove/forte/simbot/common/id/ID;Ljava/lang/Iterable;)V
280+
public fun moveMemberBlocking (Llove/forte/simbot/common/id/ID;[Llove/forte/simbot/common/id/ID;)V
281+
public fun moveMemberReserve (Llove/forte/simbot/common/id/ID;Ljava/lang/Iterable;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
282+
public fun moveMemberReserve (Llove/forte/simbot/common/id/ID;[Llove/forte/simbot/common/id/ID;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
283+
}
284+
285+
public abstract interface class love/forte/simbot/component/kook/KookVoiceMember : love/forte/simbot/component/kook/KookMember {
286+
public abstract fun kickout (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
287+
public abstract fun move (Llove/forte/simbot/common/id/ID;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
288+
}
289+
260290
public abstract interface class love/forte/simbot/component/kook/bot/KookBot : kotlinx/coroutines/CoroutineScope, love/forte/simbot/bot/Bot {
261291
public fun cancel (Ljava/lang/Throwable;)V
262292
public fun getAvatar ()Ljava/lang/String;

simbot-component-kook-core/src/commonMain/kotlin/love/forte/simbot/component/kook/KookChannel.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import love.forte.simbot.ability.DeleteSupport
2222
import love.forte.simbot.ability.StandardDeleteOption
2323
import love.forte.simbot.common.id.ID
2424
import love.forte.simbot.common.id.StringID.Companion.ID
25+
import love.forte.simbot.component.kook.bot.KookBot
2526
import love.forte.simbot.definition.Channel
2627
import love.forte.simbot.suspendrunner.ST
2728
import kotlin.coroutines.CoroutineContext
@@ -37,6 +38,12 @@ import love.forte.simbot.kook.objects.Channel as KChannel
3738
* @author ForteScarlet
3839
*/
3940
public interface KookChannel : Channel, DeleteSupport {
41+
/**
42+
* Channel 所属 bot
43+
* @since 4.2.0
44+
*/
45+
public val bot: KookBot
46+
4047
override val coroutineContext: CoroutineContext
4148

4249
override val category: KookCategory?

0 commit comments

Comments
 (0)