Skip to content

Commit

Permalink
Merge pull request #171 from simple-robot/dev/new-intents-config-type
Browse files Browse the repository at this point in the history
增加一个 `bitBased` 类型的 `IntentsConfig`,用来快捷地通过比特位标记来进行配置
  • Loading branch information
ForteScarlet authored Jul 15, 2024
2 parents 7095c73 + 9d3eed7 commit 7ddfa6f
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 53 deletions.
58 changes: 29 additions & 29 deletions .github/workflows/deploy-v4-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,32 +122,32 @@ jobs:
uses: actions/deploy-pages@v1

# https://www.jetbrains.com/help/writerside/configure-search.html
publish-indexes:
# Requires the build-job results
needs: [build, test]
runs-on: ubuntu-latest
container:
image: registry.jetbrains.team/p/writerside/builder/algolia-publisher:2.0.32-3

env:

CONFIG_JSON_VERSION: ${{ fromJSON(needs.build.outputs.config_json).productVersion }}

steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: algolia-indexes


- name: Unzip artifact
run: |
unzip -O UTF-8 -qq ${{ env.ALGOLIA_ARTIFACT }} -d algolia-indexes
env "algolia-key=${{secrets.ALGOLIA_KEY}}" java -jar /opt/builder/help-publication-agent.jar \
update-index \
--application-name ${{env.ALGOLIA_APP_NAME}} \
--index-name ${{env.ALGOLIA_INDEX_NAME}} \
--product ${{env.INSTANCE_NAME}} \
--version ${{env.CONFIG_JSON_VERSION}} \
--index-directory algolia-indexes/ \
2>&1 | tee algolia-update-index-log.txt
# publish-indexes:
# # Requires the build-job results
# needs: [build, test]
# runs-on: ubuntu-latest
# container:
# image: registry.jetbrains.team/p/writerside/builder/algolia-publisher:2.0.32-3
#
# env:
#
# CONFIG_JSON_VERSION: ${{ fromJSON(needs.build.outputs.config_json).productVersion }}
#
# steps:
# - name: Download artifact
# uses: actions/download-artifact@v3
# with:
# name: algolia-indexes
#
#
# - name: Unzip artifact
# run: |
# unzip -O UTF-8 -qq ${{ env.ALGOLIA_ARTIFACT }} -d algolia-indexes
# env "algolia-key=${{secrets.ALGOLIA_KEY}}" java -jar /opt/builder/help-publication-agent.jar \
# update-index \
# --application-name ${{env.ALGOLIA_APP_NAME}} \
# --index-name ${{env.ALGOLIA_INDEX_NAME}} \
# --product ${{env.INSTANCE_NAME}} \
# --version ${{env.CONFIG_JSON_VERSION}} \
# --index-directory algolia-indexes/ \
# 2>&1 | tee algolia-update-index-log.txt
6 changes: 3 additions & 3 deletions Writerside/cfg/buildprofiles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<locale-code>zh-CN</locale-code>
<noindex-content>false</noindex-content>
<analytics-head-script-file>head-script.html</analytics-head-script-file>
<algolia-id>VLLZ4JZE8Z</algolia-id>
<algolia-index>qg-doc</algolia-index>
<algolia-api-key>e60d9ee16618a0ad3a338ecc73cb840e</algolia-api-key>
<!-- <algolia-id>VLLZ4JZE8Z</algolia-id>-->
<!-- <algolia-index>qg-doc</algolia-index>-->
<!-- <algolia-api-key>e60d9ee16618a0ad3a338ecc73cb840e</algolia-api-key>-->
<web-root>http://component-qqguild.simbot.forte.love</web-root>
</variables>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2537,6 +2537,7 @@ public final class love/forte/simbot/qguild/event/EventIntents$AudioAction : lov
public static final field AUDIO_ON_MIC_TYPE Ljava/lang/String;
public static final field AUDIO_START_TYPE Ljava/lang/String;
public static final field INSTANCE Llove/forte/simbot/qguild/event/EventIntents$AudioAction;
public static final field INTENTS_INDEX I
public fun equals (Ljava/lang/Object;)Z
public static final fun getIntents ()I
public fun getIntentsValue ()I
Expand All @@ -2548,6 +2549,7 @@ public final class love/forte/simbot/qguild/event/EventIntents$AudioOrLiveChanne
public static final field AUDIO_OR_LIVE_CHANNEL_MEMBER_ENTER_TYPE Ljava/lang/String;
public static final field AUDIO_OR_LIVE_CHANNEL_MEMBER_EXIT_TYPE Ljava/lang/String;
public static final field INSTANCE Llove/forte/simbot/qguild/event/EventIntents$AudioOrLiveChannelMember;
public static final field INTENTS_INDEX I
public fun equals (Ljava/lang/Object;)Z
public static final fun getIntents ()I
public fun getIntentsValue ()I
Expand All @@ -2562,6 +2564,7 @@ public final class love/forte/simbot/qguild/event/EventIntents$DirectMessage : l
public static final field DIRECT_MESSAGE_CREATE_TYPE Ljava/lang/String;
public static final field DIRECT_MESSAGE_DELETE_TYPE Ljava/lang/String;
public static final field INSTANCE Llove/forte/simbot/qguild/event/EventIntents$DirectMessage;
public static final field INTENTS_INDEX I
public fun equals (Ljava/lang/Object;)Z
public static final fun getIntents ()I
public fun getIntentsValue ()I
Expand All @@ -2579,6 +2582,7 @@ public final class love/forte/simbot/qguild/event/EventIntents$ForumsEvent : lov
public static final field FORUM_THREAD_DELETE_TYPE Ljava/lang/String;
public static final field FORUM_THREAD_UPDATE_TYPE Ljava/lang/String;
public static final field INSTANCE Llove/forte/simbot/qguild/event/EventIntents$ForumsEvent;
public static final field INTENTS_INDEX I
public fun equals (Ljava/lang/Object;)Z
public static final fun getIntents ()I
public fun getIntentsValue ()I
Expand All @@ -2598,6 +2602,7 @@ public final class love/forte/simbot/qguild/event/EventIntents$GroupAndC2CEvent
public static final field GROUP_MSG_RECEIVE_TYPE Ljava/lang/String;
public static final field GROUP_MSG_REJECT_TYPE Ljava/lang/String;
public static final field INSTANCE Llove/forte/simbot/qguild/event/EventIntents$GroupAndC2CEvent;
public static final field INTENTS_INDEX I
public fun equals (Ljava/lang/Object;)Z
public static final fun getIntents ()I
public fun getIntentsValue ()I
Expand All @@ -2610,6 +2615,7 @@ public final class love/forte/simbot/qguild/event/EventIntents$GuildMembers : lo
public static final field GUILD_MEMBER_REMOVE_TYPE Ljava/lang/String;
public static final field GUILD_MEMBER_UPDATE_TYPE Ljava/lang/String;
public static final field INSTANCE Llove/forte/simbot/qguild/event/EventIntents$GuildMembers;
public static final field INTENTS_INDEX I
public fun equals (Ljava/lang/Object;)Z
public static final fun getIntents ()I
public fun getIntentsValue ()I
Expand All @@ -2619,6 +2625,7 @@ public final class love/forte/simbot/qguild/event/EventIntents$GuildMembers : lo

public final class love/forte/simbot/qguild/event/EventIntents$GuildMessageReactions : love/forte/simbot/qguild/event/EventIntents {
public static final field INSTANCE Llove/forte/simbot/qguild/event/EventIntents$GuildMessageReactions;
public static final field INTENTS_INDEX I
public static final field MESSAGE_REACTION_ADD_TYPE Ljava/lang/String;
public static final field MESSAGE_REACTION_REMOVE_TYPE Ljava/lang/String;
public fun equals (Ljava/lang/Object;)Z
Expand All @@ -2630,6 +2637,7 @@ public final class love/forte/simbot/qguild/event/EventIntents$GuildMessageReact

public final class love/forte/simbot/qguild/event/EventIntents$GuildMessages : love/forte/simbot/qguild/event/EventIntents {
public static final field INSTANCE Llove/forte/simbot/qguild/event/EventIntents$GuildMessages;
public static final field INTENTS_INDEX I
public static final field MESSAGE_CREATE_TYPE Ljava/lang/String;
public static final field MESSAGE_DELETE_TYPE Ljava/lang/String;
public fun equals (Ljava/lang/Object;)Z
Expand All @@ -2647,6 +2655,7 @@ public final class love/forte/simbot/qguild/event/EventIntents$Guilds : love/for
public static final field GUILD_DELETE_TYPE Ljava/lang/String;
public static final field GUILD_UPDATE_TYPE Ljava/lang/String;
public static final field INSTANCE Llove/forte/simbot/qguild/event/EventIntents$Guilds;
public static final field INTENTS_INDEX I
public fun equals (Ljava/lang/Object;)Z
public static final fun getIntents ()I
public fun getIntentsValue ()I
Expand All @@ -2656,6 +2665,7 @@ public final class love/forte/simbot/qguild/event/EventIntents$Guilds : love/for

public final class love/forte/simbot/qguild/event/EventIntents$Interaction : love/forte/simbot/qguild/event/EventIntents {
public static final field INSTANCE Llove/forte/simbot/qguild/event/EventIntents$Interaction;
public static final field INTENTS_INDEX I
public static final field INTERACTION_CREATE_TYPE Ljava/lang/String;
public fun equals (Ljava/lang/Object;)Z
public static final fun getIntents ()I
Expand All @@ -2666,6 +2676,7 @@ public final class love/forte/simbot/qguild/event/EventIntents$Interaction : lov

public final class love/forte/simbot/qguild/event/EventIntents$MessageAudit : love/forte/simbot/qguild/event/EventIntents {
public static final field INSTANCE Llove/forte/simbot/qguild/event/EventIntents$MessageAudit;
public static final field INTENTS_INDEX I
public static final field MESSAGE_AUDIT_PASS_TYPE Ljava/lang/String;
public static final field MESSAGE_AUDIT_REJECT_TYPE Ljava/lang/String;
public fun equals (Ljava/lang/Object;)Z
Expand All @@ -2677,6 +2688,7 @@ public final class love/forte/simbot/qguild/event/EventIntents$MessageAudit : lo

public final class love/forte/simbot/qguild/event/EventIntents$OpenForumsEvent : love/forte/simbot/qguild/event/EventIntents {
public static final field INSTANCE Llove/forte/simbot/qguild/event/EventIntents$OpenForumsEvent;
public static final field INTENTS_INDEX I
public static final field OPEN_FORUM_POST_CREATE_TYPE Ljava/lang/String;
public static final field OPEN_FORUM_POST_DELETE_TYPE Ljava/lang/String;
public static final field OPEN_FORUM_REPLY_CREATE_TYPE Ljava/lang/String;
Expand All @@ -2694,6 +2706,7 @@ public final class love/forte/simbot/qguild/event/EventIntents$OpenForumsEvent :
public final class love/forte/simbot/qguild/event/EventIntents$PublicGuildMessages : love/forte/simbot/qguild/event/EventIntents {
public static final field AT_MESSAGE_CREATE_TYPE Ljava/lang/String;
public static final field INSTANCE Llove/forte/simbot/qguild/event/EventIntents$PublicGuildMessages;
public static final field INTENTS_INDEX I
public static final field PUBLIC_MESSAGE_DELETE_TYPE Ljava/lang/String;
public fun equals (Ljava/lang/Object;)Z
public static final fun getIntents ()I
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ public sealed class EventIntents {
*
*/
public data object Guilds : EventIntents() {
internal const val INTENTS: Int = 1 shl 0
public const val INTENTS_INDEX: Int = 0
internal const val INTENTS: Int = 1 shl INTENTS_INDEX

/** 频道事件 `intents` */
@get:JvmStatic
Expand Down Expand Up @@ -157,7 +158,8 @@ public sealed class EventIntents {
* ```
*/
public data object GuildMembers : EventIntents() {
internal const val INTENTS = 1 shl 1
public const val INTENTS_INDEX: Int = 1
internal const val INTENTS = 1 shl INTENTS_INDEX

/** 频道成员事件 `intents` */
@get:JvmStatic
Expand Down Expand Up @@ -187,7 +189,8 @@ public sealed class EventIntents {
*/
@PrivateDomainOnly
public data object GuildMessages : EventIntents() {
internal const val INTENTS = 1 shl 9
public const val INTENTS_INDEX: Int = 9
internal const val INTENTS = 1 shl INTENTS_INDEX

/** 频道消息事件 `intents` */
@get:JvmStatic
Expand All @@ -212,7 +215,8 @@ public sealed class EventIntents {
* ```
*/
public data object GuildMessageReactions : EventIntents() {
internal const val INTENTS: Int = 1 shl 10
public const val INTENTS_INDEX: Int = 10
internal const val INTENTS: Int = 1 shl INTENTS_INDEX

/** 表情表态事件 `intents` */
@get:JvmStatic
Expand All @@ -238,7 +242,8 @@ public sealed class EventIntents {
* ```
*/
public data object DirectMessage : EventIntents() {
internal const val INTENTS: Int = 1 shl 12
public const val INTENTS_INDEX: Int = 12
internal const val INTENTS: Int = 1 shl INTENTS_INDEX

/** 表情表态事件 `intents` */
@get:JvmStatic
Expand Down Expand Up @@ -269,7 +274,8 @@ public sealed class EventIntents {
* ```
*/
public data object OpenForumsEvent : EventIntents() {
internal const val INTENTS: Int = 1 shl 18
public const val INTENTS_INDEX: Int = 18
internal const val INTENTS: Int = 1 shl INTENTS_INDEX

/** 论坛事件 `intents` */
@get:JvmStatic
Expand Down Expand Up @@ -310,7 +316,8 @@ public sealed class EventIntents {
* ```
*/
public data object AudioOrLiveChannelMember : EventIntents() {
internal const val INTENTS: Int = 1 shl 19
public const val INTENTS_INDEX: Int = 19
internal const val INTENTS: Int = 1 shl INTENTS_INDEX

/** 音视频/直播子频道成员进出事件 `intents` */
@get:JvmStatic
Expand Down Expand Up @@ -344,7 +351,8 @@ public sealed class EventIntents {
* ```
*/
public data object GroupAndC2CEvent : EventIntents() {
internal const val INTENTS: Int = 1 shl 25
public const val INTENTS_INDEX: Int = 25
internal const val INTENTS: Int = 1 shl INTENTS_INDEX

/** C2C群聊相关事件 `intents` */
@get:JvmStatic
Expand Down Expand Up @@ -412,7 +420,8 @@ public sealed class EventIntents {
* ```
*/
public data object Interaction : EventIntents() {
internal const val INTENTS: Int = 1 shl 26
public const val INTENTS_INDEX: Int = 26
internal const val INTENTS: Int = 1 shl INTENTS_INDEX

/** 互动事件 `intents` */
@get:JvmStatic
Expand All @@ -435,7 +444,8 @@ public sealed class EventIntents {
* ```
*/
public data object MessageAudit : EventIntents() {
internal const val INTENTS: Int = 1 shl 27
public const val INTENTS_INDEX: Int = 27
internal const val INTENTS: Int = 1 shl INTENTS_INDEX

/** 互动事件 `intents` */
@get:JvmStatic
Expand Down Expand Up @@ -468,7 +478,8 @@ public sealed class EventIntents {
*/
@PrivateDomainOnly
public data object ForumsEvent : EventIntents() {
internal const val INTENTS: Int = 1 shl 28
public const val INTENTS_INDEX: Int = 28
internal const val INTENTS: Int = 1 shl INTENTS_INDEX

/** 论坛事件 `intents` */
@get:JvmStatic
Expand Down Expand Up @@ -515,7 +526,8 @@ public sealed class EventIntents {
*/
@PrivateDomainOnly
public data object AudioAction : EventIntents() {
internal const val INTENTS: Int = 1 shl 29
public const val INTENTS_INDEX: Int = 29
internal const val INTENTS: Int = 1 shl INTENTS_INDEX

/** 论坛事件 `intents` */
@get:JvmStatic
Expand Down Expand Up @@ -548,7 +560,8 @@ public sealed class EventIntents {
*/
@PrivateDomainOnly
public data object PublicGuildMessages : EventIntents() {
internal const val INTENTS = 1 shl 30
public const val INTENTS_INDEX: Int = 30
internal const val INTENTS: Int = 1 shl INTENTS_INDEX

/** 论坛事件 `intents` */
@get:JvmStatic
Expand Down Expand Up @@ -592,7 +605,8 @@ public sealed class EventIntents {
*
* @see EventIntentsAggregation.allEventIntents

Check warning on line 606 in simbot-component-qq-guild-api/src/commonMain/kotlin/love/forte/simbot/qguild/event/EventIntents.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unresolved reference in KDoc

Cannot resolve symbol 'allEventIntents'

Check warning on line 606 in simbot-component-qq-guild-api/src/commonMain/kotlin/love/forte/simbot/qguild/event/EventIntents.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unresolved reference in KDoc

Cannot resolve symbol 'EventIntentsAggregation'
*/
@Deprecated("Use EventIntentsAggregation.allEventIntents",
@Deprecated(
"Use EventIntentsAggregation.allEventIntents",
ReplaceWith("EventIntentsAggregation.allEventIntents()")
)
public val EventIntentsInstances: Array<EventIntents>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,18 @@ public abstract class love/forte/simbot/component/qguild/bot/config/IntentsConfi
public static final synthetic fun write$Self (Llove/forte/simbot/component/qguild/bot/config/IntentsConfig;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}

public final class love/forte/simbot/component/qguild/bot/config/IntentsConfig$Bits : love/forte/simbot/component/qguild/bot/config/IntentsConfig {
public fun <init> (Ljava/util/Set;)V
public final fun component1 ()Ljava/util/Set;
public final fun copy (Ljava/util/Set;)Llove/forte/simbot/component/qguild/bot/config/IntentsConfig$Bits;
public static synthetic fun copy$default (Llove/forte/simbot/component/qguild/bot/config/IntentsConfig$Bits;Ljava/util/Set;ILjava/lang/Object;)Llove/forte/simbot/component/qguild/bot/config/IntentsConfig$Bits;
public fun equals (Ljava/lang/Object;)Z
public final fun getBits ()Ljava/util/Set;
public fun getIntents-DNrqdk0 ()I
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class love/forte/simbot/component/qguild/bot/config/IntentsConfig$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public sealed class IntentsConfig {
* "names": ["Guilds", "PublicGuildMessages"]
* }
* ```
* @property names 继承了 [EventIntents] 的 `object` 的简单类名,例如 `Guilds`.
* @property names 继承了 [EventIntents] 的 `object` 的简单名称,例如 `Guilds`,
* 可参考 [EventIntentsAggregation.getByName] 参考所有可用名称列表。

Check warning on line 66 in simbot-component-qq-guild-core/src/commonMain/kotlin/love/forte/simbot/component/qguild/bot/config/IntentsConfig.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unresolved reference in KDoc

Cannot resolve symbol 'EventIntentsAggregation'

Check warning on line 66 in simbot-component-qq-guild-core/src/commonMain/kotlin/love/forte/simbot/component/qguild/bot/config/IntentsConfig.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unresolved reference in KDoc

Cannot resolve symbol 'getByName'
* @throws NoSuchElementException 如果名称没有找到

Check warning on line 67 in simbot-component-qq-guild-core/src/commonMain/kotlin/love/forte/simbot/component/qguild/bot/config/IntentsConfig.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unresolved reference in KDoc

Cannot resolve symbol 'NoSuchElementException'
*/
@Serializable
@UsedOnlyForConfigSerialization
@SerialName("nameBased")
public data class Names(val names: Set<String>) : IntentsConfig() {

override val intents: Intents
get() {
if (names.isEmpty()) {
Expand All @@ -81,4 +81,26 @@ public sealed class IntentsConfig {
}
}

/**
* 通过 [Intents] 的位索引值来配置 [Intents] 的结果。
* ```json
* {
* "type": "bitBased",
* "bits": [0, 1, 30]
* }
* ```
* 上面的 `0, 1, 30` 即代表订阅 `1<<0 | 1<<1 | 1<<30`
*
* @property bits 需要订阅的bit的位索引,值应当在 0 ~ 31 之内,
* 但是代码内不做校验。
*/
@SerialName("bitBased")
public data class Bits(val bits: Set<Int>) : IntentsConfig() {
override val intents: Intents
get() {
val intentsValue = bits.fold(0) { acc, index -> acc or (1 shl index) }
return Intents(intentsValue)
}
}

}
Loading

0 comments on commit 7ddfa6f

Please sign in to comment.