-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #273 from simple-robot/dev/intents-appender
增加用于Intents的DSL API
- Loading branch information
Showing
10 changed files
with
330 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...nent-qq-guild-api/src/commonMain/kotlin/love/forte/simbot/qguild/event/IntentsAppender.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2025. ForteScarlet. | ||
* | ||
* This file is part of simbot-component-qq-guild. | ||
* | ||
* simbot-component-qq-guild is free software: you can redistribute it and/or modify it under the terms | ||
* of the GNU Lesser General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* simbot-component-qq-guild is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along with simbot-component-qq-guild. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package love.forte.simbot.qguild.event | ||
|
||
/** | ||
* 一个 [Intents] 追加器。 | ||
* 用于方便配置类等类型对外提供Kotlin中更便捷的DSL API使用的接口类型。 | ||
* | ||
* 例如: | ||
* | ||
* ```kotlin | ||
* intents { | ||
* guilds() | ||
* groupAndC2C() | ||
* } | ||
* ``` | ||
* | ||
* 相关操作由KSP生成 inline API,性能无损且随着 [EventIntents] 的变化自动更新,可靠又便捷。 | ||
* | ||
* 借助工厂API [IntentsAppender] 也可以用来通过 DSL API 构建一个 [Intents] 值。 | ||
* | ||
* @since 4.1.4 | ||
*/ | ||
public interface IntentsAppender { | ||
public fun appendIntents(intents: Intents) | ||
} | ||
|
||
public inline fun IntentsAppender.intents(block: IntentsAppenderOp.() -> Unit) { | ||
IntentsAppenderOp(this).block() | ||
} | ||
|
||
|
Oops, something went wrong.