Skip to content

Commit e01188c

Browse files
authored
Merge pull request #272 from simple-robot/dev/SendChannelMessageApi-template-id
为 SendChannelMessageApi 增加 templateId 属性与相关的构建参数
2 parents 33c1a73 + fdfd024 commit e01188c

File tree

3 files changed

+75
-7
lines changed

3 files changed

+75
-7
lines changed

buildSrc/src/main/kotlin/P.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ object P : ProjectDetail() {
3535
get() = HOMEPAGE
3636

3737
const val VERSION = "4.1.5"
38-
const val NEXT_VERSION = "4.1.6"
38+
const val NEXT_VERSION = "4.2.0"
3939

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

simbot-component-kook-api/api/simbot-component-kook-api.api

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1433,11 +1433,12 @@ public final class love/forte/simbot/kook/api/message/MessageReactor$Companion {
14331433

14341434
public final class love/forte/simbot/kook/api/message/SendChannelMessageApi : love/forte/simbot/kook/api/KookPostApi {
14351435
public static final field Factory Llove/forte/simbot/kook/api/message/SendChannelMessageApi$Factory;
1436-
public synthetic fun <init> (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
1436+
public synthetic fun <init> (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
14371437
public static final fun builder ()Llove/forte/simbot/kook/api/message/SendChannelMessageApi$Builder;
14381438
public static final fun builder (Ljava/lang/String;Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi$Builder;
14391439
public static final fun create (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi;
14401440
public static final fun create (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi;
1441+
public static final fun create (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi;
14411442
public static final fun create (Ljava/lang/String;Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi;
14421443
public fun getResultDeserializationStrategy ()Lkotlinx/serialization/DeserializationStrategy;
14431444
}
@@ -1451,6 +1452,7 @@ public final class love/forte/simbot/kook/api/message/SendChannelMessageApi$Buil
14511452
public final fun getQuote ()Ljava/lang/String;
14521453
public final fun getTargetId ()Ljava/lang/String;
14531454
public final fun getTempTargetId ()Ljava/lang/String;
1455+
public final fun getTemplateId ()Ljava/lang/String;
14541456
public final fun getType ()Ljava/lang/Integer;
14551457
public final fun nonce (Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi$Builder;
14561458
public final fun quote (Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi$Builder;
@@ -1459,9 +1461,11 @@ public final class love/forte/simbot/kook/api/message/SendChannelMessageApi$Buil
14591461
public final fun setQuote (Ljava/lang/String;)V
14601462
public final fun setTargetId (Ljava/lang/String;)V
14611463
public final fun setTempTargetId (Ljava/lang/String;)V
1464+
public final fun setTemplateId (Ljava/lang/String;)V
14621465
public final fun setType (Ljava/lang/Integer;)V
14631466
public final fun targetId (Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi$Builder;
14641467
public final fun tempTargetId (Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi$Builder;
1468+
public final fun templateId (Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi$Builder;
14651469
public final fun type (Ljava/lang/Integer;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi$Builder;
14661470
public final fun type (Llove/forte/simbot/kook/api/message/SendMessageType;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi$Builder;
14671471
}
@@ -1471,10 +1475,12 @@ public final class love/forte/simbot/kook/api/message/SendChannelMessageApi$Fact
14711475
public final fun builder (Ljava/lang/String;Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi$Builder;
14721476
public final fun create (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi;
14731477
public final fun create (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi;
1478+
public final fun create (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi;
14741479
public final fun create (Ljava/lang/String;Ljava/lang/String;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi;
14751480
public final synthetic fun create (Lkotlin/jvm/functions/Function1;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi;
14761481
public static synthetic fun create$default (Llove/forte/simbot/kook/api/message/SendChannelMessageApi$Factory;Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi;
14771482
public static synthetic fun create$default (Llove/forte/simbot/kook/api/message/SendChannelMessageApi$Factory;Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi;
1483+
public static synthetic fun create$default (Llove/forte/simbot/kook/api/message/SendChannelMessageApi$Factory;Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Llove/forte/simbot/kook/api/message/SendChannelMessageApi;
14781484
}
14791485

14801486
public final class love/forte/simbot/kook/api/message/SendDirectMessageApi : love/forte/simbot/kook/api/KookPostApi {

simbot-component-kook-api/src/commonMain/kotlin/love/forte/simbot/kook/api/message/SendChannelMessageApi.kt

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,15 @@ public class SendChannelMessageApi private constructor(
3939
private val type: Int? = null,
4040
private val targetId: String,
4141
private val content: String,
42-
private val quote: String? = null,
43-
private val nonce: String? = null,
44-
private val tempTargetId: String? = null,
42+
private val quote: String?,
43+
private val nonce: String?,
44+
private val tempTargetId: String?,
45+
/**
46+
* 模板消息id, 如果使用了,content会作为模板消息的input。
47+
* 参见[模板消息](https://developer.kookapp.cn/doc/http/template)
48+
* @since 4.2.0
49+
*/
50+
private val templateId: String?
4551
) : KookPostApi<SendMessageResult>() {
4652
public companion object Factory {
4753
private val PATH = ApiPath.create("message", "create")
@@ -64,13 +70,47 @@ public class SendChannelMessageApi private constructor(
6470
quote: String? = null,
6571
nonce: String? = null,
6672
tempTargetId: String? = null,
73+
): SendChannelMessageApi = create(
74+
type = type,
75+
targetId = targetId,
76+
content = content,
77+
quote = quote,
78+
nonce = nonce,
79+
tempTargetId = tempTargetId,
80+
templateId = null
81+
)
82+
83+
/**
84+
* 构造 [发送频道聊天消息][SendChannelMessageApi] 实例。
85+
*
86+
* @since 4.2.0
87+
*
88+
* @param type 消息类型, 不传默认为 1, 代表文本类型。 `9` 代表 kmarkdown 消息, `10` 代表卡片消息。
89+
* @param targetId 目标频道 id
90+
* @param content 消息内容
91+
* @param quote 回复某条消息的 msgId
92+
* @param nonce nonce, 服务端不做处理, 原样返回
93+
* @param tempTargetId 用户 id,如果传了,代表该消息是临时消息,该消息不会存数据库,但是会在频道内只给该用户推送临时消息。
94+
* 用于在频道内针对用户的操作进行单独的回应通知等。
95+
* @param templateId 模板 id, 如果使用了,content会作为模板消息的input。
96+
*/
97+
@JvmStatic
98+
public fun create(
99+
type: Int? = null,
100+
targetId: String,
101+
content: String,
102+
quote: String? = null,
103+
nonce: String? = null,
104+
tempTargetId: String? = null,
105+
templateId: String? = null,
67106
): SendChannelMessageApi = SendChannelMessageApi(
68107
type = type,
69108
targetId = targetId,
70109
content = content,
71110
quote = quote,
72111
nonce = nonce,
73112
tempTargetId = tempTargetId,
113+
templateId = templateId
74114
)
75115

76116
/**
@@ -89,6 +129,10 @@ public class SendChannelMessageApi private constructor(
89129
type = type,
90130
targetId = targetId,
91131
content = content,
132+
quote = null,
133+
nonce = null,
134+
tempTargetId = null,
135+
templateId = null
92136
)
93137

94138
/**
@@ -154,10 +198,18 @@ public class SendChannelMessageApi private constructor(
154198
public var nonce: String? = null
155199

156200
/**
157-
* 用户 id,如果传了,代表该消息是临时消息,该消息不会存数据库,但是会在频道内只给该用户推送临时消息。用于在频道内针对用户的操作进行单独的回应通知等。
201+
* 用户 id,如果传了,代表该消息是临时消息,该消息不会存数据库,但是会在频道内只给该用户推送临时消息。
202+
* 用于在频道内针对用户的操作进行单独的回应通知等。
158203
*/
159204
public var tempTargetId: String? = null
160205

206+
/**
207+
* 模板消息id, 如果使用了,content会作为模板消息的input。
208+
* 参见[模板消息](https://developer.kookapp.cn/doc/http/template)
209+
* @since 4.2.0
210+
*/
211+
public var templateId: String? = null
212+
161213
/**
162214
* 消息类型
163215
*/
@@ -189,10 +241,17 @@ public class SendChannelMessageApi private constructor(
189241
public fun nonce(nonce: String?): Builder = apply { this.nonce = nonce }
190242

191243
/**
192-
* 用户 id,如果传了,代表该消息是临时消息,该消息不会存数据库,但是会在频道内只给该用户推送临时消息。用于在频道内针对用户的操作进行单独的回应通知等。
244+
* 用户 id,如果传了,代表该消息是临时消息,该消息不会存数据库,但是会在频道内只给该用户推送临时消息。
245+
* 用于在频道内针对用户的操作进行单独的回应通知等。
193246
*/
194247
public fun tempTargetId(tempTargetId: String?): Builder = apply { this.tempTargetId = tempTargetId }
195248

249+
/**
250+
* 模板消息ID。
251+
* @see templateId
252+
*/
253+
public fun templateId(templateId: String?): Builder = apply { this.templateId = templateId }
254+
196255
/**
197256
* 构建一个 [发送频道聊天消息][SendChannelMessageApi] 实例。
198257
*/
@@ -203,6 +262,7 @@ public class SendChannelMessageApi private constructor(
203262
quote = quote,
204263
nonce = nonce,
205264
tempTargetId = tempTargetId,
265+
templateId = templateId,
206266
)
207267
}
208268

@@ -213,6 +273,7 @@ public class SendChannelMessageApi private constructor(
213273
quote = quote,
214274
nonce = nonce,
215275
tempTargetId = tempTargetId,
276+
templateId = templateId,
216277
)
217278

218279
@Serializable
@@ -223,6 +284,7 @@ public class SendChannelMessageApi private constructor(
223284
@SerialName("quote") val quote: String? = null,
224285
@SerialName("nonce") val nonce: String? = null,
225286
@SerialName("temp_target_id") val tempTargetId: String? = null,
287+
@SerialName("template_id") val templateId: String? = null,
226288
)
227289

228290
}

0 commit comments

Comments
 (0)