Skip to content

Commit

Permalink
Merge pull request #96 from simple-robot/dev/main
Browse files Browse the repository at this point in the history
Release: v1.3.0
  • Loading branch information
ForteScarlet authored Aug 17, 2024
2 parents 907b349 + 7c68664 commit d2da4a5
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .changelog/v1.3.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
> 对应核心版本: [**v4.6.0**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.6.0)

我们欢迎并期望着您的的[反馈](https://github.com/simple-robot/simbot-component-onebot/issues)[协助](https://github.com/simple-robot/simbot-component-onebot/pulls)
感谢您的贡献与支持!

也欢迎您为我们献上一颗 `star`,这是对我们最大的鼓励与认可!
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/P.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ object P {
override val description: String get() = DESCRIPTION
override val homepage: String get() = HOMEPAGE

const val VERSION = "1.2.0"
const val NEXT_VERSION = "1.2.1"
const val VERSION = "1.3.0"
const val NEXT_VERSION = "1.3.1"

override val snapshotVersion = "$NEXT_VERSION-SNAPSHOT"
override val version = if (isSnapshot()) snapshotVersion else VERSION
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[versions]
kotlin = "2.0.0"
kotlin = "2.0.10"
kotlinx-coroutines = "1.8.1"
kotlinx-serialization = "1.7.1"
dokka = "1.9.20"
ktor = "2.3.12"
openjdk-jmh = "1.37"
log4j = "2.23.1"
# simbot
simbot = "4.5.0"
simbot = "4.6.0"
suspendTransform = "0.9.0"
gradleCommon = "0.6.0"
# ksp
ksp = "2.0.0-1.0.24"
ksp = "2.0.10-1.0.24"
# https://square.github.io/kotlinpoet/
kotlinPoet = "1.18.1"
# https://mockk.io/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,8 @@ public abstract interface class love/forte/simbot/component/onebot/v11/core/bot/
public abstract fun getName ()Ljava/lang/String;
public abstract fun getUserId ()Llove/forte/simbot/common/id/ID;
public abstract fun isMe (Llove/forte/simbot/common/id/ID;)Z
public synthetic fun messageFromIdBlocking (Llove/forte/simbot/common/id/ID;)Llove/forte/simbot/message/MessageContent;
public synthetic fun messageFromReferenceBlocking (Llove/forte/simbot/message/MessageReference;)Llove/forte/simbot/message/MessageContent;
public abstract fun push (Ljava/lang/String;)Lkotlinx/coroutines/flow/Flow;
public fun pushAndLaunch (Ljava/lang/String;)Lkotlinx/coroutines/Job;
public abstract synthetic fun queryLoginInfo (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package love.forte.simbot.component.onebot.v11.core.bot

import io.ktor.client.*
import io.ktor.client.statement.*
import io.ktor.http.*
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.Flow
Expand All @@ -42,6 +41,7 @@ import love.forte.simbot.component.onebot.v11.core.actor.OneBotStranger
import love.forte.simbot.component.onebot.v11.core.api.*
import love.forte.simbot.component.onebot.v11.message.OneBotMessageContent
import love.forte.simbot.event.EventResult
import love.forte.simbot.message.MessageReference
import love.forte.simbot.suspendrunner.ST
import kotlin.coroutines.CoroutineContext
import kotlin.jvm.JvmSynthetic
Expand Down Expand Up @@ -241,13 +241,50 @@ public interface OneBotBot : Bot, OneBotApiExecutable {
* 注意:此API是实验性的,未来可能会随时被变更或删除。
*
* @see GetMsgApi
* @throws Throwable 任何API请求过程中可能产生的异常,
* 例如消息不存在
* @throws RuntimeException 任何API请求过程中可能产生的异常,
* 例如消息不存在或反序列化错误。
*/
@ST
@ExperimentalOneBotAPI
public suspend fun getMessageContent(messageId: ID): OneBotMessageContent

/**
* 根据 [id] 使用 [GetMsgApi] 查询消息内容,
* 并得到对应的 [OneBotMessageContent]。
*
* 注意:此API是实验性的,未来可能会随时被变更或删除,
* 同 [getMessageContent]。
*
* @see GetMsgApi
* @see getMessageContent
* @throws RuntimeException 任何API请求过程中可能产生的异常,
* 例如消息不存在或反序列化错误。
*
* @since 1.3.0
*/
@ST
@ExperimentalOneBotAPI
override suspend fun messageFromId(id: ID): OneBotMessageContent = getMessageContent(id)

/**
* 根据消息引用的id使用 [GetMsgApi] 查询消息内容,
* 并得到对应的 [OneBotMessageContent]。
*
* 注意:此API是实验性的,未来可能会随时被变更或删除,
* 同 [getMessageContent]。
*
* @see getMessageContent
*
* @see GetMsgApi
* @throws RuntimeException 任何API请求过程中可能产生的异常,
* 例如消息不存在或反序列化错误。
*
* @since 1.3.0
*/
@ST
@ExperimentalOneBotAPI
override suspend fun messageFromReference(reference: MessageReference): OneBotMessageContent =
getMessageContent(id)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ import love.forte.simbot.ability.DeleteOption
import love.forte.simbot.ability.StandardDeleteOption
import love.forte.simbot.common.id.ID
import love.forte.simbot.component.onebot.v11.core.api.DeleteMsgApi
import love.forte.simbot.component.onebot.v11.core.api.GetMsgApi
import love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImpl
import love.forte.simbot.component.onebot.v11.message.OneBotMessageContent
import love.forte.simbot.component.onebot.v11.message.resolveToMessageElement
import love.forte.simbot.component.onebot.v11.message.segment.OneBotMessageSegment
import love.forte.simbot.component.onebot.v11.message.segment.OneBotReply
import love.forte.simbot.component.onebot.v11.message.segment.OneBotText
import love.forte.simbot.message.Messages
import love.forte.simbot.message.toMessages
Expand Down Expand Up @@ -56,6 +58,13 @@ internal class OneBotMessageContentImpl(
sb?.toString()
}

override suspend fun referenceMessage(): OneBotMessageContent? {
val ref = messages.firstNotNullOfOrNull { it as? OneBotReply }
?: return null

return bot.getMessageContent(ref.id)
}

override suspend fun delete(vararg options: DeleteOption) {
runCatching {
bot.executeData(DeleteMsgApi.create(id))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
public abstract interface class love/forte/simbot/component/onebot/v11/message/OneBotMessageContent : love/forte/simbot/message/MessageContent {
public abstract fun delete ([Llove/forte/simbot/ability/DeleteOption;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract synthetic fun delete ([Llove/forte/simbot/ability/DeleteOption;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun getId ()Llove/forte/simbot/common/id/ID;
public abstract fun getMessages ()Llove/forte/simbot/message/Messages;
public abstract fun getPlainText ()Ljava/lang/String;
public fun getReference ()Llove/forte/simbot/component/onebot/v11/message/segment/OneBotReply;
public synthetic fun getReference ()Llove/forte/simbot/message/MessageReference;
public fun getReferenceAsync ()Ljava/util/concurrent/CompletableFuture;
public fun getReferenceMessage ()Llove/forte/simbot/component/onebot/v11/message/OneBotMessageContent;
public synthetic fun getReferenceMessage ()Llove/forte/simbot/message/MessageContent;
public fun getReferenceMessageAsync ()Ljava/util/concurrent/CompletableFuture;
public fun getReferenceMessageReserve ()Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
public fun getReferenceReserve ()Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
public abstract fun getSourceSegments ()Ljava/util/List;
public fun reference (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public synthetic fun reference (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun reference$suspendImpl (Llove/forte/simbot/component/onebot/v11/message/OneBotMessageContent;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract synthetic fun referenceMessage (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public abstract interface class love/forte/simbot/component/onebot/v11/message/OneBotMessageElement : love/forte/simbot/message/Message$Element {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
`simbot-onebot-dokka-partial-configure`
// 没用到
// `simbot-onebot-suspend-transform-configure`
`simbot-onebot-suspend-transform-configure`

alias(libs.plugins.ksp)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import love.forte.simbot.message.MessageContent
import love.forte.simbot.message.Messages
import love.forte.simbot.message.PlainText
import love.forte.simbot.suspendrunner.STP
import kotlin.jvm.JvmSynthetic


/**
Expand Down Expand Up @@ -70,6 +71,16 @@ public interface OneBotMessageContent : MessageContent {
override suspend fun reference(): OneBotReply? =
messages.firstNotNullOfOrNull { it as? OneBotReply }

/**
* 根据 [消息引用][reference] 信息通过API查询对应引用的消息内容。
*
* @throws RuntimeException 任何可能在请求API过程中产生的异常
*
* @since 1.3.0
*/
@STP
override suspend fun referenceMessage(): OneBotMessageContent?

/**
* 消息中所有的 [文本消息][PlainText]
* (或者说 [sourceSegments] 中所有的 [OneBotText])
Expand All @@ -88,6 +99,7 @@ public interface OneBotMessageContent : MessageContent {
* @throws Exception 任何请求API过程中可能会产生的异常,
* 例如因权限不足或消息不存在得到的请求错误
*/
@JvmSynthetic
override suspend fun delete(vararg options: DeleteOption)
}

Expand Down

0 comments on commit d2da4a5

Please sign in to comment.