Skip to content

Commit d941160

Browse files
authored
nonstandard forward msg api (#248)
* send forward msg support (untested) * remove `sendForward` implementations & create a special `nonstandard` package for SendxxxForwardMsgApi * review * review * apiDump
1 parent b229f49 commit d941160

File tree

6 files changed

+227
-2
lines changed

6 files changed

+227
-2
lines changed

simbot-component-onebot-v11/simbot-component-onebot-v11-core/api/simbot-component-onebot-v11-core.api

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,62 @@ public final class love/forte/simbot/component/onebot/v11/core/api/SetRestartApi
17791779
public static synthetic fun create$default (Llove/forte/simbot/component/onebot/v11/core/api/SetRestartApi$Factory;Ljava/lang/Long;ILjava/lang/Object;)Llove/forte/simbot/component/onebot/v11/core/api/SetRestartApi;
17801780
}
17811781

1782+
public final class love/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgApi : love/forte/simbot/component/onebot/v11/core/api/OneBotApi {
1783+
public static final field Factory Llove/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgApi$Factory;
1784+
public synthetic fun <init> (Ljava/lang/Object;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
1785+
public static final fun create (Llove/forte/simbot/common/id/ID;Llove/forte/simbot/component/onebot/v11/core/api/OneBotMessageOutgoing;)Llove/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgApi;
1786+
public fun getAction ()Ljava/lang/String;
1787+
public fun getApiResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy;
1788+
public fun getBody ()Ljava/lang/Object;
1789+
public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy;
1790+
}
1791+
1792+
public final class love/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgApi$Factory {
1793+
public final fun create (Llove/forte/simbot/common/id/ID;Llove/forte/simbot/component/onebot/v11/core/api/OneBotMessageOutgoing;)Llove/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgApi;
1794+
}
1795+
1796+
public final class love/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgResult {
1797+
public static final field Companion Llove/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgResult$Companion;
1798+
public final fun component1 ()Llove/forte/simbot/common/id/IntID;
1799+
public final fun component2 ()Llove/forte/simbot/common/id/StringID;
1800+
public final fun copy (Llove/forte/simbot/common/id/IntID;Llove/forte/simbot/common/id/StringID;)Llove/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgResult;
1801+
public static synthetic fun copy$default (Llove/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgResult;Llove/forte/simbot/common/id/IntID;Llove/forte/simbot/common/id/StringID;ILjava/lang/Object;)Llove/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgResult;
1802+
public fun equals (Ljava/lang/Object;)Z
1803+
public final fun getForwardId ()Llove/forte/simbot/common/id/StringID;
1804+
public final fun getMessageId ()Llove/forte/simbot/common/id/IntID;
1805+
public fun hashCode ()I
1806+
public fun toString ()Ljava/lang/String;
1807+
}
1808+
1809+
public synthetic class love/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgResult$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
1810+
public static final field INSTANCE Llove/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgResult$$serializer;
1811+
public final fun childSerializers ()[Lkotlinx/serialization/KSerializer;
1812+
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
1813+
public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Llove/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgResult;
1814+
public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
1815+
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
1816+
public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Llove/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgResult;)V
1817+
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
1818+
}
1819+
1820+
public final class love/forte/simbot/component/onebot/v11/core/api/nonstandard/SendGroupForwardMsgResult$Companion {
1821+
public final fun serializer ()Lkotlinx/serialization/KSerializer;
1822+
}
1823+
1824+
public final class love/forte/simbot/component/onebot/v11/core/api/nonstandard/SendPrivateForwardMsgApi : love/forte/simbot/component/onebot/v11/core/api/OneBotApi {
1825+
public static final field Factory Llove/forte/simbot/component/onebot/v11/core/api/nonstandard/SendPrivateForwardMsgApi$Factory;
1826+
public synthetic fun <init> (Ljava/lang/Object;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
1827+
public static final fun create (Llove/forte/simbot/common/id/ID;Llove/forte/simbot/component/onebot/v11/core/api/OneBotMessageOutgoing;)Llove/forte/simbot/component/onebot/v11/core/api/nonstandard/SendPrivateForwardMsgApi;
1828+
public fun getAction ()Ljava/lang/String;
1829+
public fun getApiResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy;
1830+
public fun getBody ()Ljava/lang/Object;
1831+
public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy;
1832+
}
1833+
1834+
public final class love/forte/simbot/component/onebot/v11/core/api/nonstandard/SendPrivateForwardMsgApi$Factory {
1835+
public final fun create (Llove/forte/simbot/common/id/ID;Llove/forte/simbot/component/onebot/v11/core/api/OneBotMessageOutgoing;)Llove/forte/simbot/component/onebot/v11/core/api/nonstandard/SendPrivateForwardMsgApi;
1836+
}
1837+
17821838
public abstract interface class love/forte/simbot/component/onebot/v11/core/bot/OneBotBot : love/forte/simbot/bot/Bot, love/forte/simbot/component/onebot/v11/core/api/OneBotApiExecutable {
17831839
public synthetic fun getAccessToken ()Ljava/lang/String;
17841840
public abstract fun getApiAccessToken ()Ljava/lang/String;

simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/actor/OneBotFriend.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,4 @@ public interface OneBotFriend : Contact, SendLikeSupport, OneBotStrangerAware {
8181
*/
8282
@ST
8383
override suspend fun send(text: String): OneBotMessageReceipt
84-
8584
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import kotlin.jvm.JvmStatic
2727

2828

2929
/**
30-
* [send_private_msg 发送私聊消息](https://github.com/botuniverse/onebot-11/blob/master/api/public.md#send_private_msg-发送私聊消息)
30+
* [`send_private_msg`-发送私聊消息](https://github.com/botuniverse/onebot-11/blob/master/api/public.md#send_private_msg-发送私聊消息)
3131
*
3232
* @author ForteScarlet
3333
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright (c) 2025. ForteScarlet.
3+
*
4+
* This file is part of simbot-component-onebot.
5+
*
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.
9+
*
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.
13+
*
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/>.
16+
*/
17+
18+
package love.forte.simbot.component.onebot.v11.core.api.nonstandard
19+
20+
import kotlinx.serialization.DeserializationStrategy
21+
import kotlinx.serialization.SerialName
22+
import kotlinx.serialization.Serializable
23+
import love.forte.simbot.common.id.ID
24+
import love.forte.simbot.common.id.IntID
25+
import love.forte.simbot.common.id.StringID
26+
import love.forte.simbot.common.id.literal
27+
import love.forte.simbot.component.onebot.common.annotations.ApiResultConstructor
28+
import love.forte.simbot.component.onebot.v11.core.api.OneBotApi
29+
import love.forte.simbot.component.onebot.v11.core.api.OneBotApiResult
30+
import love.forte.simbot.component.onebot.v11.core.api.OneBotMessageOutgoing
31+
import kotlin.jvm.JvmStatic
32+
33+
/**
34+
* [`send_group_forward_msg`-发送群合并转发消息 - 非标准接口](https://llonebot.apifox.cn/api-226189162)
35+
*
36+
* @since 1.9.0
37+
* @author Aliorpse
38+
*/
39+
public class SendGroupForwardMsgApi private constructor(
40+
override val body: Any,
41+
) : OneBotApi<SendGroupForwardMsgResult> {
42+
override val action: String
43+
get() = ACTION
44+
45+
override val resultDeserializer: DeserializationStrategy<SendGroupForwardMsgResult>
46+
get() = SendGroupForwardMsgResult.serializer()
47+
48+
override val apiResultDeserializer: DeserializationStrategy<OneBotApiResult<SendGroupForwardMsgResult>>
49+
get() = RES_SER
50+
51+
public companion object Factory {
52+
private const val ACTION: String = "send_group_forward_msg"
53+
54+
private val RES_SER = OneBotApiResult.Companion.serializer(SendGroupForwardMsgResult.serializer())
55+
56+
/**
57+
* 构建一个 [SendGroupForwardMsgApi].
58+
*
59+
* @param groupId 群号
60+
* @param messages 要发送的内容
61+
*/
62+
@JvmStatic
63+
public fun create(
64+
groupId: ID,
65+
messages: OneBotMessageOutgoing,
66+
): SendGroupForwardMsgApi = SendGroupForwardMsgApi(Body(groupId.literal, messages))
67+
}
68+
69+
/**
70+
* @property groupId 群号
71+
* @property messages 要发送的内容
72+
*/
73+
@Serializable
74+
internal data class Body(
75+
@SerialName("group_id")
76+
val groupId: String,
77+
val messages: OneBotMessageOutgoing,
78+
)
79+
}
80+
81+
/**
82+
* [SendGroupForwardMsgApi] 的响应体。
83+
*
84+
* @property messageId 消息 ID
85+
* @property forwardId RES ID
86+
*/
87+
@Serializable
88+
public data class SendGroupForwardMsgResult @ApiResultConstructor constructor(
89+
@SerialName("message_id")
90+
public val messageId: IntID,
91+
@SerialName("forward_id")
92+
public val forwardId: StringID
93+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright (c) 2025. ForteScarlet.
3+
*
4+
* This file is part of simbot-component-onebot.
5+
*
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.
9+
*
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.
13+
*
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/>.
16+
*/
17+
18+
package love.forte.simbot.component.onebot.v11.core.api.nonstandard
19+
20+
import kotlinx.serialization.DeserializationStrategy
21+
import kotlinx.serialization.SerialName
22+
import kotlinx.serialization.Serializable
23+
import love.forte.simbot.common.id.ID
24+
import love.forte.simbot.common.id.literal
25+
import love.forte.simbot.component.onebot.v11.core.api.OneBotApi
26+
import love.forte.simbot.component.onebot.v11.core.api.OneBotApiResult
27+
import love.forte.simbot.component.onebot.v11.core.api.OneBotMessageOutgoing
28+
import love.forte.simbot.component.onebot.v11.core.api.SendMsgResult
29+
import kotlin.jvm.JvmStatic
30+
31+
/**
32+
* [`send_private_forward_msg`-发送私聊合并转发消息 - 非标准接口](https://llonebot.apifox.cn/api-226189040)
33+
*
34+
* @since 1.9.0
35+
* @author Aliorpse
36+
*/
37+
public class SendPrivateForwardMsgApi private constructor(
38+
override val body: Any
39+
) : OneBotApi<SendMsgResult> {
40+
41+
override val action: String
42+
get() = ACTION
43+
44+
override val resultDeserializer: DeserializationStrategy<SendMsgResult>
45+
get() = SendMsgResult.serializer()
46+
47+
override val apiResultDeserializer: DeserializationStrategy<OneBotApiResult<SendMsgResult>>
48+
get() = RES_SER
49+
50+
public companion object Factory {
51+
private const val ACTION = "send_private_forward_msg"
52+
private val RES_SER = OneBotApiResult.Companion.serializer(SendMsgResult.serializer())
53+
54+
/**
55+
* 构建一个 [SendPrivateForwardMsgApi].
56+
* @param userId 对方 QQ 号
57+
* @param messages 要发送的内容
58+
*/
59+
@JvmStatic
60+
public fun create(
61+
userId: ID,
62+
messages: OneBotMessageOutgoing,
63+
): SendPrivateForwardMsgApi = SendPrivateForwardMsgApi(Body(userId.literal, messages))
64+
}
65+
66+
/**
67+
* @property userId 对方 QQ 号
68+
* @property messages 要发送的内容
69+
*/
70+
@Serializable
71+
internal data class Body(
72+
@SerialName("user_id")
73+
val userId: String,
74+
val messages: OneBotMessageOutgoing,
75+
)
76+
}

simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmMain/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
exports love.forte.simbot.component.onebot.v11.core;
3131
exports love.forte.simbot.component.onebot.v11.core.actor;
3232
exports love.forte.simbot.component.onebot.v11.core.api;
33+
exports love.forte.simbot.component.onebot.v11.core.api.nonstandard;
3334
exports love.forte.simbot.component.onebot.v11.core.bot;
3435
exports love.forte.simbot.component.onebot.v11.core.component;
3536
exports love.forte.simbot.component.onebot.v11.core.event;

0 commit comments

Comments
 (0)