1
1
/*
2
- * Copyright (c) 2023. ForteScarlet.
2
+ * Copyright (c) 2023-2024 . ForteScarlet.
3
3
*
4
- * This file is part of simbot-component-kook.
4
+ * This file is part of simbot-component-kook.
5
5
*
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.
9
10
*
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.
13
15
*
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/>.
16
19
*/
17
20
18
21
package love.forte.simbot.component.kook.bot
@@ -25,20 +28,25 @@ import love.forte.simbot.bot.GuildRelation
25
28
import love.forte.simbot.common.collectable.Collectable
26
29
import love.forte.simbot.common.id.ID
27
30
import love.forte.simbot.common.id.StringID.Companion.ID
31
+ import love.forte.simbot.common.id.literal
28
32
import love.forte.simbot.component.kook.KookComponent
29
33
import love.forte.simbot.component.kook.KookGuild
30
34
import love.forte.simbot.component.kook.KookUserChat
31
35
import love.forte.simbot.component.kook.message.KookAsset
32
36
import love.forte.simbot.component.kook.message.KookAssetImage
37
+ import love.forte.simbot.component.kook.message.KookChannelMessageDetailsContent.Companion.toContent
38
+ import love.forte.simbot.component.kook.message.KookMessageContent
33
39
import love.forte.simbot.component.kook.util.requestDataBy
34
40
import love.forte.simbot.kook.api.ApiResponseException
35
41
import love.forte.simbot.kook.api.ApiResultException
36
42
import love.forte.simbot.kook.api.asset.Asset
37
43
import love.forte.simbot.kook.api.asset.CreateAssetApi
44
+ import love.forte.simbot.kook.api.message.GetChannelMessageViewApi
38
45
import love.forte.simbot.kook.api.userchat.GetUserChatListApi
39
46
import love.forte.simbot.kook.messages.MessageType
40
47
import love.forte.simbot.kook.stdlib.Ticket
41
48
import love.forte.simbot.logger.Logger
49
+ import love.forte.simbot.message.MessageReference
42
50
import love.forte.simbot.suspendrunner.ST
43
51
import love.forte.simbot.suspendrunner.STP
44
52
import kotlin.coroutines.CoroutineContext
@@ -162,6 +170,23 @@ public interface KookBot : Bot, CoroutineScope {
162
170
@Deprecated(" Unsupported in KOOK" , ReplaceWith (" null" ))
163
171
override val groupRelation: GroupRelation ?
164
172
get() = null
173
+
174
+ /* *
175
+ * 根据引用ID查询对应的 **频道消息** 的 [KookMessageContent]。
176
+ */
177
+ @ST
178
+ override suspend fun messageFromId (id : ID ): KookMessageContent {
179
+ val view = GetChannelMessageViewApi .create(id.literal).requestDataBy(this )
180
+ return view.toContent(this )
181
+ }
182
+
183
+ /* *
184
+ * 根据引用查询对应的 **频道消息** 的 [KookMessageContent]。
185
+ */
186
+ @ST
187
+ override suspend fun messageFromReference (reference : MessageReference ): KookMessageContent {
188
+ return messageFromId(reference.id)
189
+ }
165
190
}
166
191
167
192
/* *
0 commit comments