Skip to content

Commit cb00630

Browse files
committed
improve(nonstandard-apis): refactor message ID handling to use LongID in SendGroupForwardMsgApi and related tests
1 parent 6ef4664 commit cb00630

File tree

4 files changed

+44
-28
lines changed

4 files changed

+44
-28
lines changed

simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/api/GetMsgApi.kt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
/*
2-
* Copyright (c) 2024. ForteScarlet.
2+
* Copyright (c) 2024-2025. ForteScarlet.
33
*
4-
* This file is part of simbot-component-onebot.
4+
* Project https://github.com/simple-robot/simbot-component-onebot
5+
56
*
6-
* simbot-component-onebot is free software: you can redistribute it and/or modify it under the terms
7-
* of 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.
7+
* This project and this file are part of the Simple Robot Library (Alias: simple-robot, simbot, etc.).
98
*
10-
* simbot-component-onebot 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.
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Lesser General Public License as published by
11+
* the Free Software Foundation, either version 3 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* Lesser GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the Lesser GNU General Public License
20+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1321
*
14-
* You should have received a copy of the GNU Lesser General Public License along with simbot-component-onebot.
15-
* If not, see <https://www.gnu.org/licenses/>.
1622
*/
1723

1824
package love.forte.simbot.component.onebot.v11.core.api
@@ -87,9 +93,9 @@ public data class GetMsgResult @ApiResultConstructor constructor(
8793
@SerialName("message_type")
8894
public val messageType: String,
8995
@SerialName("message_id")
90-
public val messageId: IntID,
96+
public val messageId: IntID, // TODO to LongID?
9197
@SerialName("real_id")
92-
public val realId: IntID,
98+
public val realId: IntID, // TODO to LongID?
9399
@property:ExperimentalSimbotAPI
94100
public val sender: JsonObject, // Any = TODO("sender?"),
95101
public val message: List<OneBotMessageSegment> = emptyList(), // Any = ("message?"),

simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/api/SendMsgApi.kt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
/*
2-
* Copyright (c) 2024. ForteScarlet.
2+
* Copyright (c) 2024-2025. ForteScarlet.
33
*
4-
* This file is part of simbot-component-onebot.
4+
* Project https://github.com/simple-robot/simbot-component-onebot
5+
56
*
6-
* simbot-component-onebot is free software: you can redistribute it and/or modify it under the terms
7-
* of 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.
7+
* This project and this file are part of the Simple Robot Library (Alias: simple-robot, simbot, etc.).
98
*
10-
* simbot-component-onebot 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.
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Lesser General Public License as published by
11+
* the Free Software Foundation, either version 3 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* Lesser GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the Lesser GNU General Public License
20+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1321
*
14-
* You should have received a copy of the GNU Lesser General Public License along with simbot-component-onebot.
15-
* If not, see <https://www.gnu.org/licenses/>.
1622
*/
1723

1824
package love.forte.simbot.component.onebot.v11.core.api
@@ -144,5 +150,5 @@ public class SendMsgApi private constructor(
144150
@Serializable
145151
public data class SendMsgResult @ApiResultConstructor constructor(
146152
@SerialName("message_id")
147-
public val messageId: IntID,
153+
public val messageId: IntID, // TODO to LongID?
148154
)

simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgApi.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import kotlinx.serialization.DeserializationStrategy
2727
import kotlinx.serialization.SerialName
2828
import kotlinx.serialization.Serializable
2929
import love.forte.simbot.common.id.ID
30-
import love.forte.simbot.common.id.IntID
30+
import love.forte.simbot.common.id.LongID
31+
import love.forte.simbot.common.id.NumericalID
3132
import love.forte.simbot.common.id.literal
3233
import love.forte.simbot.component.onebot.common.annotations.ApiResultConstructor
3334
import love.forte.simbot.component.onebot.v11.core.api.OneBotApi
@@ -103,7 +104,10 @@ public class SendGroupForwardMsgApi private constructor(
103104
@OneBotNonStandardApi
104105
public data class SendGroupForwardMsgResult @ApiResultConstructor constructor(
105106
@SerialName("message_id")
106-
public val messageId: IntID,
107+
private val longMessageId: LongID,
107108
@SerialName("forward_id")
108109
public val forwardId: ID
109-
)
110+
) {
111+
public val messageId: NumericalID
112+
get() = longMessageId
113+
}

simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonTest/kotlin/love/forte/simbot/component/onebot/v11/core/api/SendGroupForwardMsgTests.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class SendGroupForwardMsgTests {
125125
// 执行请求并验证结果
126126
val result = api.requestData(client, "http://127.0.0.1:8080/")
127127

128-
assertEquals(2026505362, result.messageId.value)
128+
assertEquals(2026505362L, result.messageId.toLong())
129129
assertEquals("zUfJpEhzJgXxJID2cIwUoiRk7dMLSgnbhwb8yPrPz8iK6IsBn2uUQArcosp4WrNH", result.forwardId.literal)
130130
}
131131

@@ -211,7 +211,7 @@ class SendGroupForwardMsgTests {
211211
// 执行请求并验证结果
212212
val result = api.requestData(client, "http://127.0.0.1:8080/")
213213

214-
assertEquals(1234567890, result.messageId.value)
214+
assertEquals(1234567890L, result.messageId.toLong())
215215
assertEquals("abcdefghijklmnopqrstuvwxyz", result.forwardId.literal)
216216
}
217217
}

0 commit comments

Comments
 (0)