Skip to content

Commit

Permalink
release: v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ForteScarlet committed Jul 1, 2024
1 parent 429a4e6 commit 2d7bc45
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .changelog/v1.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
> 对应核心版本: [**v4.1.0**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.1.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.0.0-RC"
const val NEXT_VERSION = "1.0.0"
const val VERSION = "1.0.0"
const val NEXT_VERSION = "1.0.1"

override val snapshotVersion = "$NEXT_VERSION-SNAPSHOT"
override val version = if (isSnapshot()) snapshotVersion else VERSION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,7 @@ internal fun sendMsgApi(
autoEscape = true
)
} else {
val newMessage = ArrayList<OneBotMessageSegment>(message.size + 1)
var hasReply = false
for (segment in message) {
if (!hasReply && segment is OneBotReply) {
hasReply = true
}

newMessage.add(segment)
}

if (!hasReply) {
newMessage.add(OneBotReply.create(reply))
}
val newMessage = resolveReplyMessageSegmentList(message, reply)

SendMsgApi.create(
messageType = messageType,
Expand All @@ -124,6 +112,26 @@ internal fun sendMsgApi(
}
}

internal fun resolveReplyMessageSegmentList(
message: List<OneBotMessageSegment>,
reply: ID,
): List<OneBotMessageSegment> {
val newMessage = ArrayList<OneBotMessageSegment>(message.size + 1)
var hasReply = false
for (segment in message) {
if (!hasReply && segment is OneBotReply) {
hasReply = true
}

newMessage.add(segment)
}

if (!hasReply) {
newMessage.add(0, OneBotReply.create(reply))
}
return newMessage
}

internal fun sendPrivateMsgApi(
target: ID,
message: List<OneBotMessageSegment>,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package love.forte.simbot.component.onebot.v11.core.utils

import love.forte.simbot.common.id.IntID.Companion.ID
import love.forte.simbot.component.onebot.v11.message.segment.OneBotAt
import love.forte.simbot.component.onebot.v11.message.segment.OneBotDice
import love.forte.simbot.component.onebot.v11.message.segment.OneBotReply
import kotlin.test.Test
import kotlin.test.assertContentEquals
import kotlin.test.assertEquals
import kotlin.test.assertIs


/**
*
* @author ForteScarlet
*/
class ReplyMessageSegmentListTests {

@Test
fun resolveReplyMessageSegmentListWithoutReplyTest() {
val list = listOf(
OneBotAt.create("1"),
OneBotAt.createAtAll(),
OneBotDice,
)

val newList = resolveReplyMessageSegmentList(list, 0.ID)

assertEquals(4, newList.size)
assertIs<OneBotReply>(newList.first())
assertContentEquals(list, newList.subList(1, newList.size))
}

@Test
fun resolveReplyMessageSegmentListWithReplyTest() {
val list = listOf(
OneBotAt.create("1"),
OneBotReply.create(10.ID),
OneBotDice,
)

val newList = resolveReplyMessageSegmentList(list, 0.ID)

println(newList)

assertEquals(3, newList.size)
assertContentEquals(list, newList)
}

}

0 comments on commit 2d7bc45

Please sign in to comment.