Skip to content

Commit 2d7bc45

Browse files
committed
release: v1.0.0
1 parent 429a4e6 commit 2d7bc45

File tree

4 files changed

+80
-15
lines changed
  • .changelog
  • buildSrc/src/main/kotlin
  • simbot-component-onebot-v11/simbot-component-onebot-v11-core/src

4 files changed

+80
-15
lines changed

.changelog/v1.0.0.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
> 对应核心版本: [**v4.1.0**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.1.0)
2+
3+
4+
我们欢迎并期望着您的的[反馈](https://github.com/simple-robot/simbot-component-onebot/issues)[协助](https://github.com/simple-robot/simbot-component-onebot/pulls)
5+
感谢您的贡献与支持!
6+
7+
也欢迎您为我们献上一颗 `star`,这是对我们最大的鼓励与认可!

buildSrc/src/main/kotlin/P.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ object P {
3737
override val description: String get() = DESCRIPTION
3838
override val homepage: String get() = HOMEPAGE
3939

40-
const val VERSION = "1.0.0-RC"
41-
const val NEXT_VERSION = "1.0.0"
40+
const val VERSION = "1.0.0"
41+
const val NEXT_VERSION = "1.0.1"
4242

4343
override val snapshotVersion = "$NEXT_VERSION-SNAPSHOT"
4444
override val version = if (isSnapshot()) snapshotVersion else VERSION

simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/utils/MessageUtil.kt

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,7 @@ internal fun sendMsgApi(
101101
autoEscape = true
102102
)
103103
} else {
104-
val newMessage = ArrayList<OneBotMessageSegment>(message.size + 1)
105-
var hasReply = false
106-
for (segment in message) {
107-
if (!hasReply && segment is OneBotReply) {
108-
hasReply = true
109-
}
110-
111-
newMessage.add(segment)
112-
}
113-
114-
if (!hasReply) {
115-
newMessage.add(OneBotReply.create(reply))
116-
}
104+
val newMessage = resolveReplyMessageSegmentList(message, reply)
117105

118106
SendMsgApi.create(
119107
messageType = messageType,
@@ -124,6 +112,26 @@ internal fun sendMsgApi(
124112
}
125113
}
126114

115+
internal fun resolveReplyMessageSegmentList(
116+
message: List<OneBotMessageSegment>,
117+
reply: ID,
118+
): List<OneBotMessageSegment> {
119+
val newMessage = ArrayList<OneBotMessageSegment>(message.size + 1)
120+
var hasReply = false
121+
for (segment in message) {
122+
if (!hasReply && segment is OneBotReply) {
123+
hasReply = true
124+
}
125+
126+
newMessage.add(segment)
127+
}
128+
129+
if (!hasReply) {
130+
newMessage.add(0, OneBotReply.create(reply))
131+
}
132+
return newMessage
133+
}
134+
127135
internal fun sendPrivateMsgApi(
128136
target: ID,
129137
message: List<OneBotMessageSegment>,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package love.forte.simbot.component.onebot.v11.core.utils
2+
3+
import love.forte.simbot.common.id.IntID.Companion.ID
4+
import love.forte.simbot.component.onebot.v11.message.segment.OneBotAt
5+
import love.forte.simbot.component.onebot.v11.message.segment.OneBotDice
6+
import love.forte.simbot.component.onebot.v11.message.segment.OneBotReply
7+
import kotlin.test.Test
8+
import kotlin.test.assertContentEquals
9+
import kotlin.test.assertEquals
10+
import kotlin.test.assertIs
11+
12+
13+
/**
14+
*
15+
* @author ForteScarlet
16+
*/
17+
class ReplyMessageSegmentListTests {
18+
19+
@Test
20+
fun resolveReplyMessageSegmentListWithoutReplyTest() {
21+
val list = listOf(
22+
OneBotAt.create("1"),
23+
OneBotAt.createAtAll(),
24+
OneBotDice,
25+
)
26+
27+
val newList = resolveReplyMessageSegmentList(list, 0.ID)
28+
29+
assertEquals(4, newList.size)
30+
assertIs<OneBotReply>(newList.first())
31+
assertContentEquals(list, newList.subList(1, newList.size))
32+
}
33+
34+
@Test
35+
fun resolveReplyMessageSegmentListWithReplyTest() {
36+
val list = listOf(
37+
OneBotAt.create("1"),
38+
OneBotReply.create(10.ID),
39+
OneBotDice,
40+
)
41+
42+
val newList = resolveReplyMessageSegmentList(list, 0.ID)
43+
44+
println(newList)
45+
46+
assertEquals(3, newList.size)
47+
assertContentEquals(list, newList)
48+
}
49+
50+
}

0 commit comments

Comments
 (0)