From ea33166203dff24862bf1af220200f13102a6d49 Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Sat, 8 Jun 2024 17:22:18 +0800 Subject: [PATCH 01/13] =?UTF-8?q?feat(core):=20Notice=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E7=9A=84=E7=BB=86=E5=88=86=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/message/OneBotGroupMessageEvent.kt | 5 +- .../core/event/meta/OneBotHeartbeatEvent.kt | 20 ++- .../core/event/notice/OneBotFriendAddEvent.kt | 39 ++++++ .../event/notice/OneBotFriendRecallEvent.kt | 55 ++++++++ .../event/notice/OneBotGroupAdminEvent.kt | 89 ++++++++++++ .../core/event/notice/OneBotGroupBanEvent.kt | 114 +++++++++++++++ .../event/notice/OneBotGroupChangeEvent.kt | 132 ++++++++++++++++++ .../event/notice/OneBotGroupRecallEvent.kt | 69 +++++++++ .../event/notice/OneBotGroupUploadEvent.kt | 63 +++++++++ .../core/event/notice/OneBotNoticeEvent.kt | 11 +- .../core/event/notice/OneBotNotifyEvent.kt | 73 ++++++++++ .../v11/event/message/GroupMessageEvent.kt | 2 +- .../v11/event/notice/GroupAdminEvent.kt | 14 +- .../onebot/v11/event/notice/GroupBanEvent.kt | 14 +- 14 files changed, 683 insertions(+), 17 deletions(-) create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotFriendAddEvent.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotFriendRecallEvent.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupAdminEvent.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupBanEvent.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupChangeEvent.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupRecallEvent.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupUploadEvent.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent.kt diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotGroupMessageEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotGroupMessageEvent.kt index 8b177eb..a205b8f 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotGroupMessageEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotGroupMessageEvent.kt @@ -18,6 +18,7 @@ package love.forte.simbot.component.onebot.v11.core.event.message import love.forte.simbot.common.id.ID +import love.forte.simbot.common.id.LongID import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember import love.forte.simbot.component.onebot.v11.event.message.GroupMessageEvent @@ -58,13 +59,13 @@ public interface OneBotGroupMessageEvent : OneBotMessageEvent, ChatGroupEvent { /** * 群号 */ - public val groupId: ID + public val groupId: LongID get() = sourceEvent.groupId /** * 发送者 QQ 号 */ - public val userId: ID + public val userId: LongID get() = sourceEvent.userId /** diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/meta/OneBotHeartbeatEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/meta/OneBotHeartbeatEvent.kt index e674b39..c64a289 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/meta/OneBotHeartbeatEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/meta/OneBotHeartbeatEvent.kt @@ -17,11 +17,9 @@ package love.forte.simbot.component.onebot.v11.core.event.meta -import love.forte.simbot.annotations.Api4J import love.forte.simbot.component.onebot.v11.common.api.StatusResult import love.forte.simbot.component.onebot.v11.event.meta.HeartbeatEvent import love.forte.simbot.component.onebot.v11.event.meta.MetaEvent -import kotlin.jvm.JvmSynthetic import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds @@ -45,14 +43,14 @@ public interface OneBotHeartbeatEvent : OneBotMetaEvent { /** * 到下次心跳的间隔,单位毫秒 */ - @Api4J - public val intervalValue: Long + public val intervalMilliseconds: Long get() = sourceEvent.interval - - /** - * 到下次心跳的间隔 - */ - @get:JvmSynthetic - public val interval: Duration - get() = sourceEvent.interval.milliseconds } + +/** + * 到下次心跳的间隔 + * + * @see OneBotHeartbeatEvent.intervalMilliseconds + */ +public inline val OneBotHeartbeatEvent.interval: Duration + get() = intervalMilliseconds.milliseconds diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotFriendAddEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotFriendAddEvent.kt new file mode 100644 index 0000000..fdad848 --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotFriendAddEvent.kt @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.notice + +import love.forte.simbot.common.id.LongID +import love.forte.simbot.component.onebot.v11.event.notice.FriendAddEvent + + +/** + * 好友新增事件。 + * + * @see FriendAddEvent + */ +public interface OneBotFriendAddEvent : OneBotNoticeEvent { + override val sourceEvent: FriendAddEvent + + /** + * 此好友的ID + */ + public val userId: LongID + get() = sourceEvent.userId + + // friend? or content()? +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotFriendRecallEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotFriendRecallEvent.kt new file mode 100644 index 0000000..5a86ebd --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotFriendRecallEvent.kt @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.notice + +import love.forte.simbot.common.id.ID +import love.forte.simbot.common.id.LongID +import love.forte.simbot.component.onebot.v11.core.actor.OneBotFriend +import love.forte.simbot.component.onebot.v11.event.notice.FriendRecallEvent +import love.forte.simbot.event.ContactEvent +import love.forte.simbot.suspendrunner.STP + + +/** + * 好友消息撤回事件 + * @see FriendRecallEvent + * @author ForteScarlet + */ +public interface OneBotFriendRecallEvent : OneBotNoticeEvent, ContactEvent { + override val sourceEvent: FriendRecallEvent + + /** + * 消息ID + */ + public val messageId: ID + get() = sourceEvent.messageId + + /** + * 消息发送人的ID + */ + public val authorId: LongID + get() = sourceEvent.userId + + /** + * 好友 + * + * @throws Exception + */ + @STP + override suspend fun content(): OneBotFriend +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupAdminEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupAdminEvent.kt new file mode 100644 index 0000000..c9307db --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupAdminEvent.kt @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.notice + +import love.forte.simbot.common.id.LongID +import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup +import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember +import love.forte.simbot.component.onebot.v11.event.notice.GroupAdminEvent +import love.forte.simbot.event.MemberEvent +import love.forte.simbot.suspendrunner.STP + + +/** + * 群管理员变动事件 + * @see GroupAdminEvent + * + * @author ForteScarlet + */ +public interface OneBotGroupAdminEvent : OneBotNoticeEvent, MemberEvent { + override val sourceEvent: GroupAdminEvent + + /** + * 群号 + */ + public val groupId: LongID + get() = sourceEvent.groupId + + /** + * 被操作的群成员ID + */ + public val userId: LongID + get() = sourceEvent.userId + + /** + * 事件子类型,分别表示设置和取消管理员。 + * 可能的值: `set`、`unset` + * + * @see GroupAdminEvent.subType + */ + public val subType: String + get() = sourceEvent.subType + + /** + * 是被 _任职_ 为管理, + * 即 [subType] == [GroupAdminEvent.SUB_TYPE_SET]. + */ + public val isSet: Boolean + get() = subType == GroupAdminEvent.SUB_TYPE_SET + + /** + * 群 + * + * @throws Exception + */ + @STP + override suspend fun source(): OneBotGroup + + /** + * 被操作的群成员 + * + * @throws Exception + */ + @STP + override suspend fun content(): OneBotMember +} + +/** + * 是被 _免职_ , + * 即 [OneBotGroupAdminEvent.isSet] == `false`. + * + * @see OneBotGroupAdminEvent.isSet + */ +public inline val OneBotGroupAdminEvent.isNotSet: Boolean + get() = !isSet diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupBanEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupBanEvent.kt new file mode 100644 index 0000000..3b562d6 --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupBanEvent.kt @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.notice + +import love.forte.simbot.common.id.LongID +import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup +import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember +import love.forte.simbot.component.onebot.v11.event.notice.GroupBanEvent +import love.forte.simbot.event.MemberEvent +import love.forte.simbot.suspendrunner.STP +import kotlin.time.Duration +import kotlin.time.Duration.Companion.seconds + + +/** + * 群禁言事件 + * + * @see GroupBanEvent + * + * @author ForteScarlet + */ +public interface OneBotGroupBanEvent : OneBotNoticeEvent, MemberEvent { + override val sourceEvent: GroupBanEvent + + /** + * 事件子类型,分别表示禁言、解除禁言。 + * 可能的值: `ban`、`lift_ban` + * + * @see GroupBanEvent.subType + */ + public val subType: String + get() = sourceEvent.subType + + /** + * 是否为禁言。 + * 即 [subType] == [GroupBanEvent.SUB_TYPE_BAN] + */ + public val isBan: Boolean + get() = subType == GroupBanEvent.SUB_TYPE_BAN + + /** + * 群号 + */ + public val groupId: LongID + get() = sourceEvent.groupId + + /** + * 被操作群成员的ID + */ + public val userId: LongID + get() = sourceEvent.userId + + /** + * 操作者的ID + */ + public val operatorId: LongID + get() = sourceEvent.operatorId + + /** + * 禁言时长,单位秒。 + * + * @see GroupBanEvent.duration + */ + public val durationSeconds: Long + get() = sourceEvent.duration + + /** + * 被禁言成员 + * + * @throws Exception + */ + @STP + override suspend fun content(): OneBotMember + + /** + * 所在群 + * + * @throws Exception + */ + @STP + override suspend fun source(): OneBotGroup +} + +/** + * 禁言时长 + * + * @see OneBotGroupBanEvent.durationSeconds + */ +public inline val OneBotGroupBanEvent.duration: Duration + get() = durationSeconds.seconds + +/** + * 是否为解除禁言。 + * 即 [OneBotGroupBanEvent.isBan] == `false` + * + * @see OneBotGroupBanEvent.isBan + */ +public inline val OneBotGroupBanEvent.isLeftBan: Boolean + get() = !isBan diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupChangeEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupChangeEvent.kt new file mode 100644 index 0000000..6f241b8 --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupChangeEvent.kt @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.notice + +import love.forte.simbot.common.id.LongID +import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup +import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember +import love.forte.simbot.component.onebot.v11.event.notice.GroupDecreaseEvent +import love.forte.simbot.component.onebot.v11.event.notice.GroupIncreaseEvent +import love.forte.simbot.event.MemberDecreaseEvent +import love.forte.simbot.event.MemberIncreaseEvent +import love.forte.simbot.event.MemberIncreaseOrDecreaseEvent +import love.forte.simbot.suspendrunner.STP + +/** + * 群成员增加或减少事件 + * + * @see OneBotGroupMemberIncreaseEvent + * @see OneBotGroupMemberDecreaseEvent + */ +public interface OneBotGroupChangeEvent : OneBotNoticeEvent, MemberIncreaseOrDecreaseEvent { + /** + * 群号 + */ + public val groupId: LongID + + /** + * 增加或离去的群成员ID + */ + public val userId: LongID + + /** + * 群 + * @throws Exception + */ + @STP + override suspend fun content(): OneBotGroup + + /** + * 增加或离去的成员。 + * 如果无法获取则可能得到 `null`, + * 例如成员已经离去而无法获取。 + * @throws Exception + */ + @STP + override suspend fun member(): OneBotMember? +} + +/** + * 群成员增加事件 + * + * @see GroupIncreaseEvent + */ +public interface OneBotGroupMemberIncreaseEvent : OneBotGroupChangeEvent, MemberIncreaseEvent { + override val sourceEvent: GroupIncreaseEvent + + /** + * 群号 + */ + override val groupId: LongID + get() = sourceEvent.groupId + + /** + * 增加群成员ID + */ + override val userId: LongID + get() = sourceEvent.userId + + /** + * 群 + * @throws Exception + */ + @STP + override suspend fun content(): OneBotGroup + + /** + * 增加的成员 + * @throws Exception + */ + @STP + override suspend fun member(): OneBotMember +} + +/** + * 群成员减少事件 + * + * @see GroupDecreaseEvent + */ +public interface OneBotGroupMemberDecreaseEvent : OneBotGroupChangeEvent, MemberDecreaseEvent { + override val sourceEvent: GroupDecreaseEvent + + /** + * 群号 + */ + override val groupId: LongID + get() = sourceEvent.groupId + + /** + * 离去的群成员ID + */ + override val userId: LongID + get() = sourceEvent.userId + + /** + * 群 + * @throws Exception + */ + @STP + override suspend fun content(): OneBotGroup + + /** + * 离去的成员。已经离去无法获取, + * 始终得到 null + */ + @STP + override suspend fun member(): OneBotMember? = null +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupRecallEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupRecallEvent.kt new file mode 100644 index 0000000..b6e5187 --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupRecallEvent.kt @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.notice + +import love.forte.simbot.common.id.ID +import love.forte.simbot.common.id.LongID +import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup +import love.forte.simbot.component.onebot.v11.event.notice.GroupRecallEvent +import love.forte.simbot.event.ChatGroupEvent +import love.forte.simbot.suspendrunner.STP + + +/** + * 群消息撤回事件 + * + * @see GroupRecallEvent + * + * @author ForteScarlet + */ +public interface OneBotGroupRecallEvent : OneBotNoticeEvent, ChatGroupEvent { + override val sourceEvent: GroupRecallEvent + + /** + * 消息ID + */ + public val messageId: ID + get() = sourceEvent.messageId + + /** + * 群号 + */ + public val groupId: LongID + get() = sourceEvent.groupId + + /** + * 被撤回消息的发送者ID + */ + public val authorId: LongID + get() = sourceEvent.userId + + /** + * 操作者ID + */ + public val operatorId: LongID + get() = sourceEvent.operatorId + + /** + * 群 + * + * @throws Exception + */ + @STP + override suspend fun content(): OneBotGroup +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupUploadEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupUploadEvent.kt new file mode 100644 index 0000000..7f8b295 --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupUploadEvent.kt @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.notice + +import love.forte.simbot.common.id.LongID +import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup +import love.forte.simbot.component.onebot.v11.event.notice.GroupUploadEvent +import love.forte.simbot.event.ChatGroupEvent +import love.forte.simbot.suspendrunner.STP + + +/** + * 群文件上传事件 + * + * @see GroupUploadEvent + * @author ForteScarlet + */ +public interface OneBotGroupUploadEvent : OneBotNoticeEvent, ChatGroupEvent { + override val sourceEvent: GroupUploadEvent + + /** + * 群号 + */ + public val groupId: LongID + get() = sourceEvent.groupId + + /** + * 上传者ID + */ + public val userId: LongID + get() = sourceEvent.userId + + /** + * [GroupUploadEvent] 原始事件中的 [文件信息][GroupUploadEvent.file] + * + * @see GroupUploadEvent.file + */ + public val fileInfo: GroupUploadEvent.FileInfo + get() = sourceEvent.file + + /** + * 群 + * + * @throws Exception + */ + @STP + override suspend fun content(): OneBotGroup +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNoticeEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNoticeEvent.kt index 06b9fde..feee271 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNoticeEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNoticeEvent.kt @@ -17,13 +17,22 @@ package love.forte.simbot.component.onebot.v11.core.event.notice +import love.forte.simbot.common.time.Timestamp import love.forte.simbot.component.onebot.v11.core.event.OneBotBotEvent +import love.forte.simbot.component.onebot.v11.core.utils.timestamp +import love.forte.simbot.component.onebot.v11.event.notice.NoticeEvent /** + * 通知事件 + * + * @see NoticeEvent * * @author ForteScarlet */ public interface OneBotNoticeEvent : OneBotBotEvent { - // TODO + override val sourceEvent: NoticeEvent + + override val timestamp: Timestamp + get() = sourceEvent.timestamp() } diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent.kt new file mode 100644 index 0000000..92638a2 --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent.kt @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.notice + +import love.forte.simbot.common.id.LongID +import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup +import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember +import love.forte.simbot.component.onebot.v11.event.notice.NotifyEvent +import love.forte.simbot.event.MemberEvent +import love.forte.simbot.suspendrunner.STP + + +/** + * 群成员荣誉变更事件 + * + * @see NotifyEvent + * @author ForteScarlet + */ +public interface OneBotNotifyEvent : OneBotNoticeEvent, MemberEvent { + override val sourceEvent: NotifyEvent + + /** + * 荣誉类型. + * + * @see NotifyEvent.honorType + */ + public val honorType: String + get() = sourceEvent.honorType + + /** + * 群号 + */ + public val groupId: LongID + get() = sourceEvent.groupId + + /** + * 成员ID + */ + public val userId: LongID + get() = sourceEvent.userId + + /** + * 群 + * + * @throws Exception + */ + @STP + override suspend fun source(): OneBotGroup + + /** + * 群成员 + * + * @throws Exception + */ + @STP + override suspend fun content(): OneBotMember + +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/message/GroupMessageEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/message/GroupMessageEvent.kt index d4e1cc7..c3a5cdc 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/message/GroupMessageEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/message/GroupMessageEvent.kt @@ -55,7 +55,7 @@ public data class GroupMessageEvent @SourceEventConstructor constructor( @SerialName("message_id") override val messageId: ID, @SerialName("group_id") - public val groupId: ID, + public val groupId: LongID, @SerialName("message_type") override val messageType: String, @SerialName("sub_type") diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/notice/GroupAdminEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/notice/GroupAdminEvent.kt index 873135c..af62c53 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/notice/GroupAdminEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/notice/GroupAdminEvent.kt @@ -51,4 +51,16 @@ public data class GroupAdminEvent( public val groupId: LongID, @SerialName("user_id") public val userId: LongID, -) : NoticeEvent +) : NoticeEvent { + public companion object { + /** + * @see GroupAdminEvent.subType + */ + public const val SUB_TYPE_SET: String = "set" + + /** + * @see GroupAdminEvent.subType + */ + public const val SUB_TYPE_UNSET: String = "unset" + } +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/notice/GroupBanEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/notice/GroupBanEvent.kt index a4c2247..2cb8633 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/notice/GroupBanEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/notice/GroupBanEvent.kt @@ -56,4 +56,16 @@ public data class GroupBanEvent( @SerialName("user_id") public val userId: LongID, public val duration: Long, -) : NoticeEvent +) : NoticeEvent { + public companion object { + /** + * @see GroupBanEvent.subType + */ + public const val SUB_TYPE_BAN: String = "ban" + + /** + * @see GroupBanEvent.subType + */ + public const val SUB_TYPE_LIFT_BAN: String = "lift_ban" + } +} From 46a531d3cc7b3ae9b0fc0da5c57703dfacf671bb Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Sat, 8 Jun 2024 18:06:12 +0800 Subject: [PATCH 02/13] =?UTF-8?q?feat(core):=20Notice=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 3 + .../EventTypeResolverProcessor.kt | 23 ++++-- .../IncludeMessageElementsProcessor.kt | 7 +- .../build.gradle.kts | 3 +- .../common/annotations/ComponentOpts.kt | 40 ++++++++++ .../build.gradle.kts | 3 +- .../onebot/v11/core/bot/OneBotBot.kt | 8 ++ .../v11/core/bot/internal/OneBotBotImpl.kt | 69 +++++++++++------ .../onebot/v11/core/event/OneBotEvent.kt | 2 +- .../v11/core/event/OneBotUnknownEvent.kt | 8 -- .../v11/core/event/OneBotUnsupportedEvent.kt | 8 -- .../internal/meta/OneBotMetaEventImpl.kt | 14 ---- .../notice/OneBotFriendAddEventImpl.kt | 44 +++++++++++ .../notice/OneBotFriendRecallEventImpl.kt | 50 ++++++++++++ .../notice/OneBotGroupAdminEventImpl.kt | 57 ++++++++++++++ .../notice/OneBotGroupBanEventImpl.kt | 62 +++++++++++++++ .../notice/OneBotGroupChangeEventImpl.kt | 76 +++++++++++++++++++ .../notice/OneBotGroupRecallEventImpl.kt | 50 ++++++++++++ .../notice/OneBotGroupUploadEventImpl.kt | 50 ++++++++++++ .../internal/notice/OneBotNotifyEventImpl.kt | 62 +++++++++++++++ .../request/OneBotRequestEventImpl.kt | 5 -- .../core/event/message/OneBotMessageEvent.kt | 5 -- .../core/event/notice/OneBotNoticeEvent.kt | 5 -- .../build.gradle.kts | 11 ++- 24 files changed, 582 insertions(+), 83 deletions(-) create mode 100644 simbot-component-onebot-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/common/annotations/ComponentOpts.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotFriendAddEventImpl.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotFriendRecallEventImpl.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupAdminEventImpl.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupBanEventImpl.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupChangeEventImpl.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupRecallEventImpl.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupUploadEventImpl.kt create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotNotifyEventImpl.kt diff --git a/build.gradle.kts b/build.gradle.kts index 4524485..f66e20e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -125,6 +125,9 @@ apiValidation { // 实验性和内部API可能无法保证二进制兼容 nonPublicMarkers.addAll( listOf( + "love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI", + "love.forte.simbot.component.onebot.common.annotations.ExperimentalOneBotAPI", + "love.forte.simbot.annotations.ExperimentalSimbotAPI", "love.forte.simbot.annotations.InternalSimbotAPI", "love.forte.simbot.component.onebot.common.annotations.ApiResultConstructor", diff --git a/internal-processors/event-type-resolver-processor/src/main/kotlin/onebot11/internal/processors/eventtyperesolver/EventTypeResolverProcessor.kt b/internal-processors/event-type-resolver-processor/src/main/kotlin/onebot11/internal/processors/eventtyperesolver/EventTypeResolverProcessor.kt index c40bfdb..6227aea 100644 --- a/internal-processors/event-type-resolver-processor/src/main/kotlin/onebot11/internal/processors/eventtyperesolver/EventTypeResolverProcessor.kt +++ b/internal-processors/event-type-resolver-processor/src/main/kotlin/onebot11/internal/processors/eventtyperesolver/EventTypeResolverProcessor.kt @@ -27,8 +27,16 @@ import com.google.devtools.ksp.processing.SymbolProcessorProvider import com.google.devtools.ksp.symbol.KSAnnotated import com.google.devtools.ksp.symbol.KSClassDeclaration import com.google.devtools.ksp.symbol.KSType -import com.squareup.kotlinpoet.* +import com.squareup.kotlinpoet.AnnotationSpec +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.CodeBlock +import com.squareup.kotlinpoet.FileSpec +import com.squareup.kotlinpoet.FunSpec import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy +import com.squareup.kotlinpoet.STRING +import com.squareup.kotlinpoet.WildcardTypeName +import com.squareup.kotlinpoet.asTypeName +import com.squareup.kotlinpoet.buildCodeBlock import com.squareup.kotlinpoet.jvm.jvmMultifileClass import com.squareup.kotlinpoet.jvm.jvmName import com.squareup.kotlinpoet.ksp.toClassName @@ -80,7 +88,10 @@ private const val FUNCTION_RESOLVER_SUB_TYPE_NAME = "resolveEventSubTypeFieldNam private const val FILE_NAME = "EventResolver.generated" private const val FILE_JVM_NAME = "EventResolvers" -private val InternalSimbotAPIClassName = ClassName("love.forte.simbot.annotations", "InternalSimbotAPI") +private val InternalAPIClassName = ClassName( + "love.forte.simbot.component.onebot.common.annotations", + "InternalOneBotAPI" +) private class EventTypeResolverProcessor(val environment: SymbolProcessorEnvironment) : SymbolProcessor { private val generated = AtomicBoolean(false) @@ -201,7 +212,7 @@ private class EventTypeResolverProcessor(val environment: SymbolProcessorEnviron rootSubEventTypes: List ): FunSpec { return FunSpec.builder(FUNCTION_RESOLVER_SERIALIZER_NAME).apply { - addAnnotation(InternalSimbotAPIClassName) + addAnnotation(InternalAPIClassName) addParameter(FUNCTION_EVENT_PARAM_NAME, EventClassName) returns( KSerializerClassName.parameterizedBy( @@ -365,7 +376,7 @@ private class EventTypeResolverProcessor(val environment: SymbolProcessorEnviron values: Map> ): FunSpec { return FunSpec.builder(FUNCTION_RESOLVER_SERIALIZER_NAME).apply { - addAnnotation(InternalSimbotAPIClassName) + addAnnotation(InternalAPIClassName) addParameter(FUNCTION_POST_TYPE_PARAM_NAME, STRING) addParameter(FUNCTION_SUB_TYPE_PARAM_NAME, STRING) returns( @@ -399,7 +410,7 @@ private class EventTypeResolverProcessor(val environment: SymbolProcessorEnviron values: Map> ): FunSpec { return FunSpec.builder(FUNCTION_RESOLVER_TYPE_NAME).apply { - addAnnotation(InternalSimbotAPIClassName) + addAnnotation(InternalAPIClassName) addParameter(FUNCTION_POST_TYPE_PARAM_NAME, STRING) addParameter(FUNCTION_SUB_TYPE_PARAM_NAME, STRING) returns( @@ -434,7 +445,7 @@ private class EventTypeResolverProcessor(val environment: SymbolProcessorEnviron rootSubEventTypes: List ): FunSpec { return FunSpec.builder(FUNCTION_RESOLVER_SUB_TYPE_NAME).apply { - addAnnotation(InternalSimbotAPIClassName) + addAnnotation(InternalAPIClassName) addParameter(FUNCTION_POST_TYPE_PARAM_NAME, STRING) returns(STRING.copy(nullable = true)) diff --git a/internal-processors/include-component-message-elements-processor/src/main/kotlin/onebot11/internal/processors/includemessageelements/IncludeMessageElementsProcessor.kt b/internal-processors/include-component-message-elements-processor/src/main/kotlin/onebot11/internal/processors/includemessageelements/IncludeMessageElementsProcessor.kt index dbad714..fa5781d 100644 --- a/internal-processors/include-component-message-elements-processor/src/main/kotlin/onebot11/internal/processors/includemessageelements/IncludeMessageElementsProcessor.kt +++ b/internal-processors/include-component-message-elements-processor/src/main/kotlin/onebot11/internal/processors/includemessageelements/IncludeMessageElementsProcessor.kt @@ -72,7 +72,10 @@ private const val SEGMENT_FUNCTION_NAME = "includeAllOneBotSegmentImpls" private const val FILE_NAME = "OneBotMessageElements.generated" -private val InternalSimbotAPIClassName = ClassName("love.forte.simbot.annotations", "InternalSimbotAPI") +private val InternalAPIClassName = ClassName( + "love.forte.simbot.component.onebot.common.annotations", + "InternalOneBotAPI" +) private class IncludeMessageElementsProcessor(val environment: SymbolProcessorEnvironment) : SymbolProcessor { private val generated = AtomicBoolean(false) @@ -183,7 +186,7 @@ private class IncludeMessageElementsProcessor(val environment: SymbolProcessorEn return FunSpec.builder(functionName).apply { addModifiers(KModifier.PUBLIC) - addAnnotation(InternalSimbotAPIClassName) + addAnnotation(InternalAPIClassName) receiver(PolymorphicModuleBuilderClassName.parameterizedBy(baseType)) for (impl in impls) { addCode("%M(%T.serializer())\n", memberName, impl.toClassName()) diff --git a/simbot-component-onebot-common/build.gradle.kts b/simbot-component-onebot-common/build.gradle.kts index 8f59a0c..7da0863 100644 --- a/simbot-component-onebot-common/build.gradle.kts +++ b/simbot-component-onebot-common/build.gradle.kts @@ -37,7 +37,8 @@ kotlin { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { optIn.addAll( - "love.forte.simbot.annotations.InternalSimbotAPI" + "love.forte.simbot.annotations.InternalSimbotAPI", + "love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI" ) } diff --git a/simbot-component-onebot-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/common/annotations/ComponentOpts.kt b/simbot-component-onebot-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/common/annotations/ComponentOpts.kt new file mode 100644 index 0000000..55b4c9d --- /dev/null +++ b/simbot-component-onebot-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/common/annotations/ComponentOpts.kt @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.common.annotations + +/** + * 标记为仅用于OneBot组件内部使用的API,可能会随时变更、删除 + */ +@Retention(AnnotationRetention.BINARY) +@RequiresOptIn( + message = "仅用于OneBot组件内部使用的API,可能会随时变更、删除", + level = RequiresOptIn.Level.ERROR +) +@MustBeDocumented +public annotation class InternalOneBotAPI + +/** + * 标记为OneBot组件中仍处于实验阶段的API,可能会随时变更、删除 + */ +@Retention(AnnotationRetention.BINARY) +@RequiresOptIn( + message = "OneBot组件中仍处于实验阶段的API,可能会随时变更、删除", + level = RequiresOptIn.Level.ERROR +) +@MustBeDocumented +public annotation class ExperimentalOneBotAPI diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/build.gradle.kts b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/build.gradle.kts index d1f9edf..4165b43 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/build.gradle.kts +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/build.gradle.kts @@ -42,7 +42,8 @@ kotlin { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { optIn.addAll( - "love.forte.simbot.annotations.InternalSimbotAPI" + "love.forte.simbot.annotations.InternalSimbotAPI", + "love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI" ) } diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBot.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBot.kt index d8f8c98..6393aa1 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBot.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBot.kt @@ -27,6 +27,7 @@ import love.forte.simbot.bot.GroupRelation import love.forte.simbot.bot.GuildRelation import love.forte.simbot.common.collectable.Collectable import love.forte.simbot.common.id.ID +import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI import love.forte.simbot.component.onebot.v11.core.actor.OneBotFriend import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup import love.forte.simbot.component.onebot.v11.core.api.GetLoginInfoApi @@ -58,6 +59,13 @@ public interface OneBotBot : Bot { */ public val configuration: OneBotBotConfiguration + /** + * 由 [OneBotBot] 衍生出的 actor 使用的 [CoroutineContext]。 + * 源自 [coroutineContext], 但是不包含 [Job][kotlinx.coroutines.Job]。 + */ + @InternalOneBotAPI + public val subContext: CoroutineContext + /** * [OneBotBot] 用于请求API的 [HttpClient]。 */ diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt index 37f3180..ab91fe1 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt @@ -84,9 +84,17 @@ import love.forte.simbot.component.onebot.v11.core.event.internal.message.OneBot import love.forte.simbot.component.onebot.v11.core.event.internal.message.OneBotGroupPrivateMessageEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.message.OneBotNormalGroupMessageEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.message.OneBotNoticeGroupMessageEventImpl -import love.forte.simbot.component.onebot.v11.core.event.internal.meta.OneBotDefaultMetaEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.meta.OneBotHeartbeatEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.meta.OneBotLifecycleEventImpl +import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotFriendAddEventImpl +import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotFriendRecallEventImpl +import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotGroupAdminEventImpl +import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotGroupBanEventImpl +import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotGroupMemberDecreaseEventImpl +import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotGroupMemberIncreaseEventImpl +import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotGroupRecallEventImpl +import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotGroupUploadEventImpl +import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotNotifyEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.request.OneBotFriendRequestEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.request.OneBotGroupRequestEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.stage.OneBotBotStartedEventImpl @@ -96,7 +104,15 @@ import love.forte.simbot.component.onebot.v11.event.message.GroupMessageEvent import love.forte.simbot.component.onebot.v11.event.message.PrivateMessageEvent import love.forte.simbot.component.onebot.v11.event.meta.HeartbeatEvent import love.forte.simbot.component.onebot.v11.event.meta.LifecycleEvent -import love.forte.simbot.component.onebot.v11.event.meta.MetaEvent +import love.forte.simbot.component.onebot.v11.event.notice.FriendAddEvent +import love.forte.simbot.component.onebot.v11.event.notice.FriendRecallEvent +import love.forte.simbot.component.onebot.v11.event.notice.GroupAdminEvent +import love.forte.simbot.component.onebot.v11.event.notice.GroupBanEvent +import love.forte.simbot.component.onebot.v11.event.notice.GroupDecreaseEvent +import love.forte.simbot.component.onebot.v11.event.notice.GroupIncreaseEvent +import love.forte.simbot.component.onebot.v11.event.notice.GroupRecallEvent +import love.forte.simbot.component.onebot.v11.event.notice.GroupUploadEvent +import love.forte.simbot.component.onebot.v11.event.notice.NotifyEvent import love.forte.simbot.component.onebot.v11.event.request.FriendRequestEvent import love.forte.simbot.component.onebot.v11.event.request.GroupRequestEvent import love.forte.simbot.component.onebot.v11.event.resolveEventSerializer @@ -133,7 +149,7 @@ internal class OneBotBotImpl( job.invokeOnCompletion { apiClient.close() } } - internal val subContext = coroutineContext.minusKey(Job) + override val subContext = coroutineContext.minusKey(Job) private val logger = LoggerFactory .getLogger( @@ -504,6 +520,7 @@ internal class OneBotBotImpl( val bot = this@OneBotBotImpl return when (event) { + //region 消息事件 // 群消息、匿名消息、系统消息 is GroupMessageEvent -> when (event.subType) { GroupMessageEvent.SUB_TYPE_NORMAL -> @@ -554,27 +571,20 @@ internal class OneBotBotImpl( bot ) } + //endregion - //region Meta events - is MetaEvent -> when (event) { - is LifecycleEvent -> OneBotLifecycleEventImpl( - raw, - event, - bot, - ) - - is HeartbeatEvent -> OneBotHeartbeatEventImpl( - raw, - event, - bot, - ) + //region 元事件 + is LifecycleEvent -> OneBotLifecycleEventImpl( + raw, + event, + bot, + ) - else -> OneBotDefaultMetaEventImpl( - raw, - event, - bot - ) - } + is HeartbeatEvent -> OneBotHeartbeatEventImpl( + raw, + event, + bot, + ) //endregion //region 申请事件 @@ -583,6 +593,7 @@ internal class OneBotBotImpl( event, bot ) + is GroupRequestEvent -> OneBotGroupRequestEventImpl( raw, event, @@ -591,7 +602,19 @@ internal class OneBotBotImpl( // 其余未知的申请事件扔到 unsupported //endregion - // TODO notice events + //region notice events + is FriendAddEvent -> OneBotFriendAddEventImpl(raw, event, bot) + is FriendRecallEvent -> OneBotFriendRecallEventImpl(raw, event, bot) + is GroupAdminEvent -> OneBotGroupAdminEventImpl(raw, event, bot) + is GroupBanEvent -> OneBotGroupBanEventImpl(raw, event, bot) + is GroupIncreaseEvent -> OneBotGroupMemberIncreaseEventImpl(raw, event, bot) + is GroupDecreaseEvent -> OneBotGroupMemberDecreaseEventImpl(raw, event, bot) + is GroupRecallEvent -> OneBotGroupRecallEventImpl(raw, event, bot) + is GroupUploadEvent -> OneBotGroupUploadEventImpl(raw, event, bot) + is NotifyEvent -> OneBotNotifyEventImpl(raw, event, bot) + + //endregion + is UnknownEvent -> OneBotUnknownEvent(raw, event) else -> OneBotUnsupportedEvent(raw, event) diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/OneBotEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/OneBotEvent.kt index 2925bb5..9cf5524 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/OneBotEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/OneBotEvent.kt @@ -59,7 +59,7 @@ public interface OneBotEvent : OneBotCommonEvent { /** * 事件发生的时间戳 */ - public val timestamp: Timestamp + override val time: Timestamp get() = sourceEvent.timestamp() /** diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/OneBotUnknownEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/OneBotUnknownEvent.kt index ca0b93d..eaf19b9 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/OneBotUnknownEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/OneBotUnknownEvent.kt @@ -20,8 +20,6 @@ package love.forte.simbot.component.onebot.v11.core.event import love.forte.simbot.annotations.FragileSimbotAPI import love.forte.simbot.common.id.ID import love.forte.simbot.common.id.UUID -import love.forte.simbot.common.time.Timestamp -import love.forte.simbot.component.onebot.v11.core.utils.timestamp import love.forte.simbot.component.onebot.v11.event.UnknownEvent @@ -43,10 +41,4 @@ public data class OneBotUnknownEvent( * 一个无意义的随机ID。 */ override val id: ID = UUID.random() - - /** - * 事件时间。 - */ - override val time: Timestamp - get() = sourceEvent.timestamp() } diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/OneBotUnsupportedEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/OneBotUnsupportedEvent.kt index 460067b..87069e5 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/OneBotUnsupportedEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/OneBotUnsupportedEvent.kt @@ -20,8 +20,6 @@ package love.forte.simbot.component.onebot.v11.core.event import love.forte.simbot.annotations.FragileSimbotAPI import love.forte.simbot.common.id.ID import love.forte.simbot.common.id.UUID -import love.forte.simbot.common.time.Timestamp -import love.forte.simbot.component.onebot.v11.core.utils.timestamp import love.forte.simbot.component.onebot.v11.event.UnknownEvent /** @@ -72,10 +70,4 @@ public data class OneBotUnsupportedEvent( * 一个无意义的随机ID。 */ override val id: ID = UUID.random() - - /** - * 事件时间。 - */ - override val time: Timestamp - get() = sourceEvent.timestamp() } diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/meta/OneBotMetaEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/meta/OneBotMetaEventImpl.kt index c64cb9c..38900d1 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/meta/OneBotMetaEventImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/meta/OneBotMetaEventImpl.kt @@ -19,16 +19,13 @@ package love.forte.simbot.component.onebot.v11.core.event.internal.meta import love.forte.simbot.common.id.ID import love.forte.simbot.common.id.UUID -import love.forte.simbot.common.time.Timestamp import love.forte.simbot.component.onebot.v11.core.bot.OneBotBot import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString import love.forte.simbot.component.onebot.v11.core.event.meta.OneBotHeartbeatEvent import love.forte.simbot.component.onebot.v11.core.event.meta.OneBotLifecycleEvent import love.forte.simbot.component.onebot.v11.core.event.meta.OneBotMetaEvent -import love.forte.simbot.component.onebot.v11.core.utils.timestamp import love.forte.simbot.component.onebot.v11.event.meta.HeartbeatEvent import love.forte.simbot.component.onebot.v11.event.meta.LifecycleEvent -import love.forte.simbot.component.onebot.v11.event.meta.MetaEvent /** * OneBot中的元事件类型。 @@ -36,9 +33,6 @@ import love.forte.simbot.component.onebot.v11.event.meta.MetaEvent */ internal abstract class OneBotMetaEventImpl : OneBotMetaEvent { override val id: ID = UUID.random() - - override val time: Timestamp - get() = sourceEvent.timestamp() } internal class OneBotHeartbeatEventImpl( @@ -59,11 +53,3 @@ internal class OneBotLifecycleEventImpl( eventToString("OneBotLifecycleEvent") } -internal class OneBotDefaultMetaEventImpl( - override val sourceEventRaw: String?, - override val sourceEvent: MetaEvent, - override val bot: OneBotBot, -) : OneBotMetaEventImpl() { - override fun toString(): String = - eventToString("OneBotDefaultMetaEvent") -} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotFriendAddEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotFriendAddEventImpl.kt new file mode 100644 index 0000000..798f9d6 --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotFriendAddEventImpl.kt @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.internal.notice + +import love.forte.simbot.common.id.ID +import love.forte.simbot.common.id.StringID.Companion.ID +import love.forte.simbot.component.onebot.v11.core.bot.OneBotBot +import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString +import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotFriendAddEvent +import love.forte.simbot.component.onebot.v11.event.notice.FriendAddEvent + + +/** + * + * @author ForteScarlet + */ +internal class OneBotFriendAddEventImpl( + override val sourceEventRaw: String?, + override val sourceEvent: FriendAddEvent, + override val bot: OneBotBot +) : OneBotFriendAddEvent { + override val id: ID + get() = with(sourceEvent) { + "$postType-$noticeType-$userId-$time" + }.ID + + override fun toString(): String = + eventToString("OneBotFriendAddEvent") +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotFriendRecallEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotFriendRecallEventImpl.kt new file mode 100644 index 0000000..7eda0e3 --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotFriendRecallEventImpl.kt @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.internal.notice + +import love.forte.simbot.common.id.ID +import love.forte.simbot.common.id.StringID.Companion.ID +import love.forte.simbot.component.onebot.v11.core.actor.OneBotFriend +import love.forte.simbot.component.onebot.v11.core.bot.OneBotBot +import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString +import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotFriendRecallEvent +import love.forte.simbot.component.onebot.v11.event.notice.FriendRecallEvent + + +/** + * + * @author ForteScarlet + */ +internal class OneBotFriendRecallEventImpl( + override val sourceEventRaw: String?, + override val sourceEvent: FriendRecallEvent, + override val bot: OneBotBot +) : OneBotFriendRecallEvent { + override val id: ID + get() = with(sourceEvent) { + "$postType-$noticeType-$userId-$messageId-$time" + }.ID + + override suspend fun content(): OneBotFriend { + return bot.contactRelation.contact(sourceEvent.userId) + ?: error("Friend with id ${sourceEvent.userId} not found") + } + + override fun toString(): String = + eventToString("OneBotFriendRecallEvent") +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupAdminEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupAdminEventImpl.kt new file mode 100644 index 0000000..0a4a889 --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupAdminEventImpl.kt @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.internal.notice + +import love.forte.simbot.common.id.ID +import love.forte.simbot.common.id.StringID.Companion.ID +import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup +import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember +import love.forte.simbot.component.onebot.v11.core.actor.internal.toMember +import love.forte.simbot.component.onebot.v11.core.api.GetGroupMemberInfoApi +import love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImpl +import love.forte.simbot.component.onebot.v11.core.bot.requestDataBy +import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString +import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotGroupAdminEvent +import love.forte.simbot.component.onebot.v11.event.notice.GroupAdminEvent + +internal class OneBotGroupAdminEventImpl( + override val sourceEventRaw: String?, + override val sourceEvent: GroupAdminEvent, + override val bot: OneBotBotImpl +) : OneBotGroupAdminEvent { + override val id: ID + get() = with(sourceEvent) { + "$postType-$noticeType-$subType-$groupId-$userId-$time" + }.ID + + override suspend fun content(): OneBotMember { + // TODO 换成 groupRelation + return GetGroupMemberInfoApi.create( + groupId = sourceEvent.groupId, + userId = sourceEvent.userId + ).requestDataBy(bot).toMember(bot) + } + + override suspend fun source(): OneBotGroup { + return bot.groupRelation.group(sourceEvent.groupId) + ?: error("Group with id ${sourceEvent.groupId} not found") + } + + override fun toString(): String = + eventToString("OneBotGroupAdminEvent") +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupBanEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupBanEventImpl.kt new file mode 100644 index 0000000..cd2ec5e --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupBanEventImpl.kt @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.internal.notice + +import love.forte.simbot.common.id.ID +import love.forte.simbot.common.id.StringID.Companion.ID +import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup +import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember +import love.forte.simbot.component.onebot.v11.core.actor.internal.toMember +import love.forte.simbot.component.onebot.v11.core.api.GetGroupMemberInfoApi +import love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImpl +import love.forte.simbot.component.onebot.v11.core.bot.requestDataBy +import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString +import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotGroupBanEvent +import love.forte.simbot.component.onebot.v11.event.notice.GroupBanEvent + + +/** + * + * @author ForteScarlet + */ +internal class OneBotGroupBanEventImpl( + override val sourceEventRaw: String?, + override val sourceEvent: GroupBanEvent, + override val bot: OneBotBotImpl +) : OneBotGroupBanEvent { + override val id: ID + get() = with(sourceEvent) { + "$postType-$noticeType-$subType-$groupId-$userId-$time" + }.ID + + override suspend fun content(): OneBotMember { + // TODO 换成 groupRelation + return GetGroupMemberInfoApi.create( + groupId = sourceEvent.groupId, + userId = sourceEvent.userId + ).requestDataBy(bot).toMember(bot) + } + + override suspend fun source(): OneBotGroup { + return bot.groupRelation.group(sourceEvent.groupId) + ?: error("Group with id ${sourceEvent.groupId} not found") + } + + override fun toString(): String = + eventToString("OneBotGroupBanEvent") +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupChangeEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupChangeEventImpl.kt new file mode 100644 index 0000000..88d7ebd --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupChangeEventImpl.kt @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.internal.notice + +import love.forte.simbot.common.id.ID +import love.forte.simbot.common.id.StringID.Companion.ID +import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup +import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember +import love.forte.simbot.component.onebot.v11.core.actor.internal.toMember +import love.forte.simbot.component.onebot.v11.core.api.GetGroupMemberInfoApi +import love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImpl +import love.forte.simbot.component.onebot.v11.core.bot.requestDataBy +import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString +import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotGroupChangeEvent +import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotGroupMemberDecreaseEvent +import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotGroupMemberIncreaseEvent +import love.forte.simbot.component.onebot.v11.event.notice.GroupDecreaseEvent +import love.forte.simbot.component.onebot.v11.event.notice.GroupIncreaseEvent + + +/** + * + * @author ForteScarlet + */ +internal abstract class OneBotGroupChangeEventImpl : OneBotGroupChangeEvent { + override val id: ID + get() = with(sourceEvent) { + "$postType-$noticeType-$groupId-$userId-$time" + }.ID + + override suspend fun content(): OneBotGroup { + return bot.groupRelation.group(groupId) + ?: error("Group with id $groupId not found") + } +} + +internal class OneBotGroupMemberIncreaseEventImpl( + override val sourceEventRaw: String?, + override val sourceEvent: GroupIncreaseEvent, + override val bot: OneBotBotImpl +) : OneBotGroupChangeEventImpl(), OneBotGroupMemberIncreaseEvent { + override suspend fun member(): OneBotMember { + // TODO 换成 groupRelation + return GetGroupMemberInfoApi.create( + groupId = sourceEvent.groupId, + userId = sourceEvent.userId + ).requestDataBy(bot).toMember(bot) + } + + override fun toString(): String = + eventToString("OneBotGroupMemberIncreaseEvent") +} +internal class OneBotGroupMemberDecreaseEventImpl( + override val sourceEventRaw: String?, + override val sourceEvent: GroupDecreaseEvent, + override val bot: OneBotBotImpl +) : OneBotGroupChangeEventImpl(), OneBotGroupMemberDecreaseEvent { + + override fun toString(): String = + eventToString("OneBotGroupMemberDecreaseEvent") +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupRecallEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupRecallEventImpl.kt new file mode 100644 index 0000000..427ab9f --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupRecallEventImpl.kt @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.internal.notice + +import love.forte.simbot.common.id.ID +import love.forte.simbot.common.id.StringID.Companion.ID +import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup +import love.forte.simbot.component.onebot.v11.core.bot.OneBotBot +import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString +import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotGroupRecallEvent +import love.forte.simbot.component.onebot.v11.event.notice.GroupRecallEvent + + +/** + * + * @author ForteScarlet + */ +internal class OneBotGroupRecallEventImpl( + override val sourceEventRaw: String?, + override val sourceEvent: GroupRecallEvent, + override val bot: OneBotBot +) : OneBotGroupRecallEvent { + override val id: ID + get() = with(sourceEvent) { + "$postType-$noticeType-$groupId-$userId-$messageId-$time" + }.ID + + override suspend fun content(): OneBotGroup { + return bot.groupRelation.group(groupId) + ?: error("Group with id $groupId not found") + } + + override fun toString(): String = + eventToString("OneBotGroupRecallEvent") +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupUploadEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupUploadEventImpl.kt new file mode 100644 index 0000000..905e44c --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupUploadEventImpl.kt @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.internal.notice + +import love.forte.simbot.common.id.ID +import love.forte.simbot.common.id.StringID.Companion.ID +import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup +import love.forte.simbot.component.onebot.v11.core.bot.OneBotBot +import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString +import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotGroupUploadEvent +import love.forte.simbot.component.onebot.v11.event.notice.GroupUploadEvent + + +/** + * + * @author ForteScarlet + */ +internal class OneBotGroupUploadEventImpl( + override val sourceEventRaw: String?, + override val sourceEvent: GroupUploadEvent, + override val bot: OneBotBot +) : OneBotGroupUploadEvent { + override val id: ID + get() = with(sourceEvent) { + "$postType-$noticeType-$groupId-$userId-$time" + }.ID + + override suspend fun content(): OneBotGroup { + return bot.groupRelation.group(groupId) + ?: error("Group with id $groupId not found") + } + + override fun toString(): String = + eventToString("OneBotGroupUploadEvent") +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotNotifyEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotNotifyEventImpl.kt new file mode 100644 index 0000000..1774975 --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotNotifyEventImpl.kt @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024. ForteScarlet. + * + * This file is part of simbot-component-onebot. + * + * simbot-component-onebot 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-onebot 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-onebot. + * If not, see . + */ + +package love.forte.simbot.component.onebot.v11.core.event.internal.notice + +import love.forte.simbot.common.id.ID +import love.forte.simbot.common.id.StringID.Companion.ID +import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup +import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember +import love.forte.simbot.component.onebot.v11.core.actor.internal.toMember +import love.forte.simbot.component.onebot.v11.core.api.GetGroupMemberInfoApi +import love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImpl +import love.forte.simbot.component.onebot.v11.core.bot.requestDataBy +import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString +import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotNotifyEvent +import love.forte.simbot.component.onebot.v11.event.notice.NotifyEvent + + +/** + * + * @author ForteScarlet + */ +internal class OneBotNotifyEventImpl( + override val sourceEventRaw: String?, + override val sourceEvent: NotifyEvent, + override val bot: OneBotBotImpl +) : OneBotNotifyEvent { + override val id: ID + get() = with(sourceEvent) { + "$postType-$noticeType-$subType-$groupId-$userId-$time" + }.ID + + override suspend fun source(): OneBotGroup { + return bot.groupRelation.group(groupId) + ?: error("Group with id $groupId not found") + } + + override suspend fun content(): OneBotMember { + // TODO 换成 groupRelation + return GetGroupMemberInfoApi.create( + groupId = sourceEvent.groupId, + userId = sourceEvent.userId + ).requestDataBy(bot).toMember(bot) + } + + override fun toString(): String = + eventToString("OneBotNotifyEvent") +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/request/OneBotRequestEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/request/OneBotRequestEventImpl.kt index e57fdfd..843f71b 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/request/OneBotRequestEventImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/request/OneBotRequestEventImpl.kt @@ -19,7 +19,6 @@ package love.forte.simbot.component.onebot.v11.core.event.internal.request import love.forte.simbot.common.id.ID import love.forte.simbot.common.id.UUID -import love.forte.simbot.common.time.Timestamp import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup import love.forte.simbot.component.onebot.v11.core.actor.OneBotStranger import love.forte.simbot.component.onebot.v11.core.actor.internal.toStranger @@ -33,7 +32,6 @@ import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString import love.forte.simbot.component.onebot.v11.core.event.request.OneBotFriendRequestEvent import love.forte.simbot.component.onebot.v11.core.event.request.OneBotGroupRequestEvent import love.forte.simbot.component.onebot.v11.core.event.request.OneBotRequestEvent -import love.forte.simbot.component.onebot.v11.core.utils.timestamp import love.forte.simbot.component.onebot.v11.event.request.FriendRequestEvent import love.forte.simbot.component.onebot.v11.event.request.GroupRequestEvent @@ -41,9 +39,6 @@ import love.forte.simbot.component.onebot.v11.event.request.GroupRequestEvent internal abstract class OneBotRequestEventImpl : OneBotRequestEvent { override val id: ID = UUID.random() - override val time: Timestamp - get() = sourceEvent.timestamp() - override suspend fun accept() { doSetRequest(true) } diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotMessageEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotMessageEvent.kt index 4d0be93..120d37a 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotMessageEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotMessageEvent.kt @@ -17,10 +17,8 @@ package love.forte.simbot.component.onebot.v11.core.event.message -import love.forte.simbot.common.time.Timestamp import love.forte.simbot.component.onebot.v11.core.bot.OneBotBot import love.forte.simbot.component.onebot.v11.core.event.OneBotBotEvent -import love.forte.simbot.component.onebot.v11.core.utils.timestamp import love.forte.simbot.component.onebot.v11.message.OneBotMessageContent import love.forte.simbot.component.onebot.v11.message.OneBotMessageReceipt import love.forte.simbot.component.onebot.v11.message.segment.OneBotReply @@ -43,9 +41,6 @@ public interface OneBotMessageEvent : OneBotBotEvent, MessageEvent { override val bot: OneBotBot override val sourceEvent: OBSourceMessageEvent - override val time: Timestamp - get() = sourceEvent.timestamp() - /** * 基于本事件回复一条消息 [message]。 * diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNoticeEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNoticeEvent.kt index feee271..f215622 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNoticeEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNoticeEvent.kt @@ -17,9 +17,7 @@ package love.forte.simbot.component.onebot.v11.core.event.notice -import love.forte.simbot.common.time.Timestamp import love.forte.simbot.component.onebot.v11.core.event.OneBotBotEvent -import love.forte.simbot.component.onebot.v11.core.utils.timestamp import love.forte.simbot.component.onebot.v11.event.notice.NoticeEvent @@ -32,7 +30,4 @@ import love.forte.simbot.component.onebot.v11.event.notice.NoticeEvent */ public interface OneBotNoticeEvent : OneBotBotEvent { override val sourceEvent: NoticeEvent - - override val timestamp: Timestamp - get() = sourceEvent.timestamp() } diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-event/build.gradle.kts b/simbot-component-onebot-v11/simbot-component-onebot-v11-event/build.gradle.kts index 2e23e05..a1eaf0d 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-event/build.gradle.kts +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-event/build.gradle.kts @@ -21,6 +21,7 @@ import love.forte.gradle.common.kotlin.multiplatform.applyTier1 import love.forte.gradle.common.kotlin.multiplatform.applyTier2 import love.forte.gradle.common.kotlin.multiplatform.applyTier3 import org.jetbrains.dokka.gradle.DokkaTaskPartial +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi plugins { kotlin("multiplatform") @@ -38,10 +39,12 @@ kotlin { explicitApi() applyDefaultHierarchyTemplate() - sourceSets.configureEach { - languageSettings { - optIn("love.forte.simbot.annotations.InternalSimbotAPI") - } + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerOptions { + optIn.addAll( + "love.forte.simbot.annotations.InternalSimbotAPI", + "love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI" + ) } configKotlinJvm() From bcf1c143298ff1ebf8a4f4bf4f357bf395fcd912 Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Sat, 8 Jun 2024 18:25:23 +0800 Subject: [PATCH 03/13] =?UTF-8?q?test:=20=E9=83=A8=E5=88=86=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v11/core/bot/internal/OneBotBotImpl.kt | 211 +++++++++--------- .../core/event/ResolveRawEventToEventTests.kt | 49 ++++ 2 files changed, 155 insertions(+), 105 deletions(-) create mode 100644 simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonTest/kotlin/love/forte/simbot/component/onebot/v11/core/event/ResolveRawEventToEventTests.kt diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt index ab91fe1..83476ad 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt @@ -515,111 +515,6 @@ internal class OneBotBotImpl( } } - @OptIn(FragileSimbotAPI::class) - private fun resolveRawEventToEvent(raw: String, event: OBRawEvent): Event { - val bot = this@OneBotBotImpl - - return when (event) { - //region 消息事件 - // 群消息、匿名消息、系统消息 - is GroupMessageEvent -> when (event.subType) { - GroupMessageEvent.SUB_TYPE_NORMAL -> - OneBotNormalGroupMessageEventImpl( - raw, - event, - bot - ) - - GroupMessageEvent.SUB_TYPE_ANONYMOUS -> - OneBotAnonymousGroupMessageEventImpl( - raw, - event, - bot - ) - - GroupMessageEvent.SUB_TYPE_NOTICE -> - OneBotNoticeGroupMessageEventImpl( - raw, - event, - bot - ) - - else -> OneBotDefaultGroupMessageEventImpl( - raw, - event, - bot - ) - } - - // 好友私聊消息、成员临时会话 - is PrivateMessageEvent -> when (event.subType) { - PrivateMessageEvent.SUB_TYPE_FRIEND -> OneBotFriendMessageEventImpl( - raw, - event, - bot - ) - - PrivateMessageEvent.SUB_TYPE_GROUP -> OneBotGroupPrivateMessageEventImpl( - raw, - event, - bot - ) - - else -> OneBotDefaultPrivateMessageEventImpl( - raw, - event, - bot - ) - } - //endregion - - //region 元事件 - is LifecycleEvent -> OneBotLifecycleEventImpl( - raw, - event, - bot, - ) - - is HeartbeatEvent -> OneBotHeartbeatEventImpl( - raw, - event, - bot, - ) - //endregion - - //region 申请事件 - is FriendRequestEvent -> OneBotFriendRequestEventImpl( - raw, - event, - bot - ) - - is GroupRequestEvent -> OneBotGroupRequestEventImpl( - raw, - event, - bot - ) - // 其余未知的申请事件扔到 unsupported - //endregion - - //region notice events - is FriendAddEvent -> OneBotFriendAddEventImpl(raw, event, bot) - is FriendRecallEvent -> OneBotFriendRecallEventImpl(raw, event, bot) - is GroupAdminEvent -> OneBotGroupAdminEventImpl(raw, event, bot) - is GroupBanEvent -> OneBotGroupBanEventImpl(raw, event, bot) - is GroupIncreaseEvent -> OneBotGroupMemberIncreaseEventImpl(raw, event, bot) - is GroupDecreaseEvent -> OneBotGroupMemberDecreaseEventImpl(raw, event, bot) - is GroupRecallEvent -> OneBotGroupRecallEventImpl(raw, event, bot) - is GroupUploadEvent -> OneBotGroupUploadEventImpl(raw, event, bot) - is NotifyEvent -> OneBotNotifyEventImpl(raw, event, bot) - - //endregion - - - is UnknownEvent -> OneBotUnknownEvent(raw, event) - else -> OneBotUnsupportedEvent(raw, event) - } - } private fun pushEvent(event: Event): Job { return eventProcessor @@ -685,3 +580,109 @@ internal class OneBotBotImpl( } + +@OptIn(FragileSimbotAPI::class) +internal fun OneBotBotImpl.resolveRawEventToEvent(raw: String, event: OBRawEvent): Event { + val bot = this + + return when (event) { + //region 消息事件 + // 群消息、匿名消息、系统消息 + is GroupMessageEvent -> when (event.subType) { + GroupMessageEvent.SUB_TYPE_NORMAL -> + OneBotNormalGroupMessageEventImpl( + raw, + event, + bot + ) + + GroupMessageEvent.SUB_TYPE_ANONYMOUS -> + OneBotAnonymousGroupMessageEventImpl( + raw, + event, + bot + ) + + GroupMessageEvent.SUB_TYPE_NOTICE -> + OneBotNoticeGroupMessageEventImpl( + raw, + event, + bot + ) + + else -> OneBotDefaultGroupMessageEventImpl( + raw, + event, + bot + ) + } + + // 好友私聊消息、成员临时会话 + is PrivateMessageEvent -> when (event.subType) { + PrivateMessageEvent.SUB_TYPE_FRIEND -> OneBotFriendMessageEventImpl( + raw, + event, + bot + ) + + PrivateMessageEvent.SUB_TYPE_GROUP -> OneBotGroupPrivateMessageEventImpl( + raw, + event, + bot + ) + + else -> OneBotDefaultPrivateMessageEventImpl( + raw, + event, + bot + ) + } + //endregion + + //region 元事件 + is LifecycleEvent -> OneBotLifecycleEventImpl( + raw, + event, + bot, + ) + + is HeartbeatEvent -> OneBotHeartbeatEventImpl( + raw, + event, + bot, + ) + //endregion + + //region 申请事件 + is FriendRequestEvent -> OneBotFriendRequestEventImpl( + raw, + event, + bot + ) + + is GroupRequestEvent -> OneBotGroupRequestEventImpl( + raw, + event, + bot + ) + // 其余未知的申请事件扔到 unsupported + //endregion + + //region notice events + is FriendAddEvent -> OneBotFriendAddEventImpl(raw, event, bot) + is FriendRecallEvent -> OneBotFriendRecallEventImpl(raw, event, bot) + is GroupAdminEvent -> OneBotGroupAdminEventImpl(raw, event, bot) + is GroupBanEvent -> OneBotGroupBanEventImpl(raw, event, bot) + is GroupIncreaseEvent -> OneBotGroupMemberIncreaseEventImpl(raw, event, bot) + is GroupDecreaseEvent -> OneBotGroupMemberDecreaseEventImpl(raw, event, bot) + is GroupRecallEvent -> OneBotGroupRecallEventImpl(raw, event, bot) + is GroupUploadEvent -> OneBotGroupUploadEventImpl(raw, event, bot) + is NotifyEvent -> OneBotNotifyEventImpl(raw, event, bot) + + //endregion + + + is UnknownEvent -> OneBotUnknownEvent(raw, event) + else -> OneBotUnsupportedEvent(raw, event) + } +} diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonTest/kotlin/love/forte/simbot/component/onebot/v11/core/event/ResolveRawEventToEventTests.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonTest/kotlin/love/forte/simbot/component/onebot/v11/core/event/ResolveRawEventToEventTests.kt new file mode 100644 index 0000000..9946701 --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonTest/kotlin/love/forte/simbot/component/onebot/v11/core/event/ResolveRawEventToEventTests.kt @@ -0,0 +1,49 @@ +package love.forte.simbot.component.onebot.v11.core.event + +import kotlinx.serialization.KSerializer +import love.forte.simbot.component.onebot.v11.core.OneBot11 +import love.forte.simbot.component.onebot.v11.event.Event +import love.forte.simbot.component.onebot.v11.event.message.GroupMessageEvent + + +/** + * + * @author ForteScarlet + */ +class ResolveRawEventToEventTests { + + // @Test // TODO + fun resolveGroupMessageEventTest() { + val event = decodeEvent( + GroupMessageEvent.serializer(), + "" + ) + + } +} + +private fun decodeEvent( + serializer: KSerializer, + raw: String +): T { + return OneBot11.DefaultJson.decodeFromString( + serializer, + raw + ) +} + +// GroupMessageEvent +// PrivateMessageEvent +// HeartbeatEvent +// LifecycleEvent +// FriendAddEvent +// FriendRecallEvent +// GroupAdminEvent +// GroupBanEvent +// GroupDecreaseEvent +// GroupIncreaseEvent +// GroupRecallEvent +// GroupUploadEvent +// NotifyEvent +// FriendRequestEvent +// GroupRequestEvent From fb024ae5ad320016c951704728d96bf2d77e9fcf Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Sun, 9 Jun 2024 00:35:20 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E6=94=AF=E6=8C=81=E5=8C=BA=E5=88=86=E8=8D=A3=E8=AA=89?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E3=80=81=E7=BA=A2=E5=8C=85=E4=BA=BA=E6=B0=94?= =?UTF-8?q?=E7=8E=8B=E4=BA=8B=E4=BB=B6=E5=92=8C=E6=88=B3=E4=B8=80=E6=88=B3?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v11/core/bot/internal/OneBotBotImpl.kt | 101 +++++++----------- .../internal/notice/OneBotNotifyEventImpl.kt | 45 +++++++- .../core/event/notice/OneBotNotifyEvent.kt | 55 +++++++++- .../onebot/v11/event/notice/NotifyEvent.kt | 37 ++++++- 4 files changed, 164 insertions(+), 74 deletions(-) diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt index 83476ad..0dee792 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt @@ -86,6 +86,7 @@ import love.forte.simbot.component.onebot.v11.core.event.internal.message.OneBot import love.forte.simbot.component.onebot.v11.core.event.internal.message.OneBotNoticeGroupMessageEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.meta.OneBotHeartbeatEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.meta.OneBotLifecycleEventImpl +import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotBotSelfPokeEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotFriendAddEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotFriendRecallEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotGroupAdminEventImpl @@ -94,6 +95,9 @@ import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotG import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotGroupMemberIncreaseEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotGroupRecallEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotGroupUploadEventImpl +import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotHonorEventImpl +import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotLuckyKingEventImpl +import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotMemberPokeEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotNotifyEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.request.OneBotFriendRequestEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.request.OneBotGroupRequestEventImpl @@ -473,7 +477,7 @@ internal class OneBotBotImpl( resolveRawEvent(eventRaw) }.getOrElse { e -> val exMsg = "Failed to resolve raw event $eventRaw, " + - "session and bot will be closed exceptionally" + "session and bot will be closed exceptionally" val ex = IllegalStateException( exMsg, @@ -580,92 +584,49 @@ internal class OneBotBotImpl( } - @OptIn(FragileSimbotAPI::class) internal fun OneBotBotImpl.resolveRawEventToEvent(raw: String, event: OBRawEvent): Event { val bot = this + fun unsupported(): OneBotUnsupportedEvent = + OneBotUnsupportedEvent(raw, event) + return when (event) { //region 消息事件 // 群消息、匿名消息、系统消息 is GroupMessageEvent -> when (event.subType) { GroupMessageEvent.SUB_TYPE_NORMAL -> - OneBotNormalGroupMessageEventImpl( - raw, - event, - bot - ) + OneBotNormalGroupMessageEventImpl(raw, event, bot) GroupMessageEvent.SUB_TYPE_ANONYMOUS -> - OneBotAnonymousGroupMessageEventImpl( - raw, - event, - bot - ) + OneBotAnonymousGroupMessageEventImpl(raw, event, bot) GroupMessageEvent.SUB_TYPE_NOTICE -> - OneBotNoticeGroupMessageEventImpl( - raw, - event, - bot - ) - - else -> OneBotDefaultGroupMessageEventImpl( - raw, - event, - bot - ) + OneBotNoticeGroupMessageEventImpl(raw, event, bot) + + else -> OneBotDefaultGroupMessageEventImpl(raw, event, bot) } // 好友私聊消息、成员临时会话 is PrivateMessageEvent -> when (event.subType) { - PrivateMessageEvent.SUB_TYPE_FRIEND -> OneBotFriendMessageEventImpl( - raw, - event, - bot - ) + PrivateMessageEvent.SUB_TYPE_FRIEND -> + OneBotFriendMessageEventImpl(raw, event, bot) - PrivateMessageEvent.SUB_TYPE_GROUP -> OneBotGroupPrivateMessageEventImpl( - raw, - event, - bot - ) + PrivateMessageEvent.SUB_TYPE_GROUP -> + OneBotGroupPrivateMessageEventImpl(raw, event, bot) - else -> OneBotDefaultPrivateMessageEventImpl( - raw, - event, - bot - ) + else -> OneBotDefaultPrivateMessageEventImpl(raw, event, bot) } //endregion //region 元事件 - is LifecycleEvent -> OneBotLifecycleEventImpl( - raw, - event, - bot, - ) - - is HeartbeatEvent -> OneBotHeartbeatEventImpl( - raw, - event, - bot, - ) + is LifecycleEvent -> OneBotLifecycleEventImpl(raw, event, bot,) + is HeartbeatEvent -> OneBotHeartbeatEventImpl(raw, event, bot,) //endregion //region 申请事件 - is FriendRequestEvent -> OneBotFriendRequestEventImpl( - raw, - event, - bot - ) - - is GroupRequestEvent -> OneBotGroupRequestEventImpl( - raw, - event, - bot - ) - // 其余未知的申请事件扔到 unsupported + is FriendRequestEvent -> OneBotFriendRequestEventImpl(raw, event, bot) + is GroupRequestEvent -> OneBotGroupRequestEventImpl(raw, event, bot) //endregion //region notice events @@ -677,12 +638,22 @@ internal fun OneBotBotImpl.resolveRawEventToEvent(raw: String, event: OBRawEvent is GroupDecreaseEvent -> OneBotGroupMemberDecreaseEventImpl(raw, event, bot) is GroupRecallEvent -> OneBotGroupRecallEventImpl(raw, event, bot) is GroupUploadEvent -> OneBotGroupUploadEventImpl(raw, event, bot) - is NotifyEvent -> OneBotNotifyEventImpl(raw, event, bot) - - //endregion + is NotifyEvent -> when (event.subType) { + NotifyEvent.SUB_TYPE_HONOR -> OneBotHonorEventImpl(raw, event, bot) + NotifyEvent.SUB_TYPE_LUCKY_KING -> OneBotLuckyKingEventImpl(raw, event, bot) + NotifyEvent.SUB_TYPE_POKE -> when { + event.selfId.value == event.targetId?.value -> + OneBotBotSelfPokeEventImpl(raw, event, bot) + + else -> OneBotMemberPokeEventImpl(raw, event, bot) + } + // Unsupported + else -> unsupported() + } + //endregion is UnknownEvent -> OneBotUnknownEvent(raw, event) - else -> OneBotUnsupportedEvent(raw, event) + else -> unsupported() } } diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotNotifyEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotNotifyEventImpl.kt index 1774975..34581d2 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotNotifyEventImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotNotifyEventImpl.kt @@ -26,6 +26,10 @@ import love.forte.simbot.component.onebot.v11.core.api.GetGroupMemberInfoApi import love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImpl import love.forte.simbot.component.onebot.v11.core.bot.requestDataBy import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString +import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotBotSelfPokeEvent +import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotHonorEvent +import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotLuckyKingEvent +import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotMemberPokeEvent import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotNotifyEvent import love.forte.simbot.component.onebot.v11.event.notice.NotifyEvent @@ -34,7 +38,7 @@ import love.forte.simbot.component.onebot.v11.event.notice.NotifyEvent * * @author ForteScarlet */ -internal class OneBotNotifyEventImpl( +internal abstract class OneBotNotifyEventImpl( override val sourceEventRaw: String?, override val sourceEvent: NotifyEvent, override val bot: OneBotBotImpl @@ -56,7 +60,44 @@ internal class OneBotNotifyEventImpl( userId = sourceEvent.userId ).requestDataBy(bot).toMember(bot) } +} + +internal class OneBotHonorEventImpl( + sourceEventRaw: String?, + sourceEvent: NotifyEvent, + bot: OneBotBotImpl +) : OneBotNotifyEventImpl(sourceEventRaw, sourceEvent, bot), + OneBotHonorEvent { + override fun toString(): String = + eventToString("OneBotHonorEvent") +} + +internal class OneBotLuckyKingEventImpl( + sourceEventRaw: String?, + sourceEvent: NotifyEvent, + bot: OneBotBotImpl +) : OneBotNotifyEventImpl(sourceEventRaw, sourceEvent, bot), + OneBotLuckyKingEvent { + override fun toString(): String = + eventToString("OneBotLuckyKingEvent") +} + +internal class OneBotMemberPokeEventImpl( + sourceEventRaw: String?, + sourceEvent: NotifyEvent, + bot: OneBotBotImpl +) : OneBotNotifyEventImpl(sourceEventRaw, sourceEvent, bot), + OneBotMemberPokeEvent { + override fun toString(): String = + eventToString("OneBotMemberPokeEvent") +} +internal class OneBotBotSelfPokeEventImpl( + sourceEventRaw: String?, + sourceEvent: NotifyEvent, + bot: OneBotBotImpl +) : OneBotNotifyEventImpl(sourceEventRaw, sourceEvent, bot), + OneBotBotSelfPokeEvent { override fun toString(): String = - eventToString("OneBotNotifyEvent") + eventToString("OneBotBotSelfPokeEvent") } diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent.kt index 92638a2..05c0f46 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent.kt @@ -26,9 +26,12 @@ import love.forte.simbot.suspendrunner.STP /** - * 群成员荣誉变更事件 + * 群成员荣誉变更事件、红包人气王事件或戳一戳事件。 * * @see NotifyEvent + * @see OneBotHonorEvent + * @see OneBotLuckyKingEvent + * @see OneBotPokeEvent * @author ForteScarlet */ public interface OneBotNotifyEvent : OneBotNoticeEvent, MemberEvent { @@ -39,7 +42,7 @@ public interface OneBotNotifyEvent : OneBotNoticeEvent, MemberEvent { * * @see NotifyEvent.honorType */ - public val honorType: String + public val honorType: String? get() = sourceEvent.honorType /** @@ -71,3 +74,51 @@ public interface OneBotNotifyEvent : OneBotNoticeEvent, MemberEvent { override suspend fun content(): OneBotMember } + +/** + * 群成员荣誉变更事件 + */ +public interface OneBotHonorEvent : OneBotNotifyEvent { + /** + * 荣誉类型. + * + * @see NotifyEvent.honorType + */ + override val honorType: String + get() = sourceEvent.honorType!! +} + +/** + * 群红包运气王事件 + */ +public interface OneBotLuckyKingEvent : OneBotNotifyEvent { + /** + * 人气王用户ID + */ + public val targetId: LongID + get() = sourceEvent.targetId!! +} + +/** + * 群戳一戳事件 + * + * @see OneBotMemberPokeEvent + * @see OneBotBotSelfPokeEvent + */ +public interface OneBotPokeEvent : OneBotNotifyEvent { + /** + * 被戳的用户ID + */ + public val targetId: LongID + get() = sourceEvent.targetId!! +} + +/** + * 群里Bot以外的群成员被戳一戳事件 + */ +public interface OneBotMemberPokeEvent : OneBotPokeEvent + +/** + * 群里Bot被戳一戳事件,即 [targetId] == [selfId]。 + */ +public interface OneBotBotSelfPokeEvent : OneBotPokeEvent diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/notice/NotifyEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/notice/NotifyEvent.kt index 98185f5..7ee0efa 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/notice/NotifyEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/notice/NotifyEvent.kt @@ -25,14 +25,21 @@ import love.forte.simbot.common.id.LongID import love.forte.simbot.component.onebot.v11.event.ExpectEventType /** - * [群成员荣誉变更](https://github.com/botuniverse/onebot-11/blob/master/event/notice.md#群成员荣誉变更) + * [群成员荣誉变更](https://github.com/botuniverse/onebot-11/blob/master/event/notice.md#群成员荣誉变更)、 + * [群红包运气王](https://github.com/botuniverse/onebot-11/blob/master/event/notice.md#群红包运气王)、 + * [群内戳一戳](https://github.com/botuniverse/onebot-11/blob/master/event/notice.md#群内戳一戳)。 + * + * 其中,红包和戳一戳的 [subType] 分别为 `lucky_king` 和 `poke` * * @property subType 提示类型。 - * 可能的值: `honor` + * 可能的值: `honor`, `lucky_king`, `poke` * @property groupId 群号。 * @property honorType 荣誉类型,分别表示龙王、群聊之火、快乐源泉。 - * 可能的值: `talkative`、`performer`、`emotion` + * 可能的值: `talkative`、`performer`、`emotion`。 + * 当 [subType] 为 `honor` 时有值。 * @property userId 成员 QQ 号。 + * @property targetId 当 [subType] 为 `lucky_king` 时代表人气王用户ID, + * 为 `poke` 时代表被戳的人的ID,否则为 `null`。 */ @ExpectEventType( postType = NoticeEvent.POST_TYPE, @@ -52,7 +59,27 @@ public data class NotifyEvent( @SerialName("group_id") public val groupId: LongID, @SerialName("honor_type") - public val honorType: String, + public val honorType: String? = null, @SerialName("user_id") public val userId: LongID, -) : NoticeEvent + @SerialName("target_id") + public val targetId: LongID? = null +) : NoticeEvent { + public companion object { + /** + * @see NotifyEvent.subType + */ + public const val SUB_TYPE_HONOR: String = "honor" + + /** + * @see NotifyEvent.subType + */ + public const val SUB_TYPE_POKE: String = "poke" + + /** + * @see NotifyEvent.subType + */ + public const val SUB_TYPE_LUCKY_KING: String = "lucky_king" + } + +} From 40d7af9a2f76a9b8edcd7867c006cc92d5f86634 Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Sun, 9 Jun 2024 00:36:34 +0800 Subject: [PATCH 05/13] apply detekt and add .editorconfig file --- .editorconfig | 1235 +++++++++++++++++ .../v11/core/bot/internal/OneBotBotImpl.kt | 3 +- 2 files changed, 1236 insertions(+), 2 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..dcbb430 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,1235 @@ +[*] +charset = utf-8 +end_of_line = crlf +indent_size = 4 +indent_style = space +insert_final_newline = true +max_line_length = 120 +tab_width = 4 +ij_continuation_indent_size = 4 +ij_formatter_off_tag = @formatter:off +ij_formatter_on_tag = @formatter:on +ij_formatter_tags_enabled = true +ij_smart_tabs = false +ij_visual_guides = +ij_wrap_on_typing = false + +[*.conf] +indent_size = 2 +tab_width = 2 +ij_continuation_indent_size = 2 +ij_hocon_keep_blank_lines_before_right_brace = 2 +ij_hocon_keep_indents_on_empty_lines = false +ij_hocon_keep_line_breaks = true +ij_hocon_space_after_colon = true +ij_hocon_space_after_comma = true +ij_hocon_space_before_colon = true +ij_hocon_space_before_comma = false +ij_hocon_spaces_within_braces = false +ij_hocon_spaces_within_brackets = false +ij_hocon_spaces_within_method_call_parentheses = false + +[*.css] +ij_css_align_closing_brace_with_properties = false +ij_css_blank_lines_around_nested_selector = 1 +ij_css_blank_lines_between_blocks = 1 +ij_css_block_comment_add_space = false +ij_css_brace_placement = end_of_line +ij_css_enforce_quotes_on_format = false +ij_css_hex_color_long_format = false +ij_css_hex_color_lower_case = false +ij_css_hex_color_short_format = false +ij_css_hex_color_upper_case = false +ij_css_keep_blank_lines_in_code = 2 +ij_css_keep_indents_on_empty_lines = false +ij_css_keep_single_line_blocks = false +ij_css_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow +ij_css_space_after_colon = true +ij_css_space_before_opening_brace = true +ij_css_use_double_quotes = true +ij_css_value_alignment = do_not_align + +[*.csv] +indent_style = tab +ij_csv_keep_indents_on_empty_lines = true +ij_csv_wrap_long_lines = false + +[*.feature] +indent_size = 2 +ij_gherkin_keep_indents_on_empty_lines = false + +[*.less] +indent_size = 2 +ij_less_align_closing_brace_with_properties = false +ij_less_blank_lines_around_nested_selector = 1 +ij_less_blank_lines_between_blocks = 1 +ij_less_block_comment_add_space = false +ij_less_brace_placement = 0 +ij_less_enforce_quotes_on_format = false +ij_less_hex_color_long_format = false +ij_less_hex_color_lower_case = false +ij_less_hex_color_short_format = false +ij_less_hex_color_upper_case = false +ij_less_keep_blank_lines_in_code = 2 +ij_less_keep_indents_on_empty_lines = false +ij_less_keep_single_line_blocks = false +ij_less_line_comment_add_space = false +ij_less_line_comment_at_first_column = false +ij_less_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow +ij_less_space_after_colon = true +ij_less_space_before_opening_brace = true +ij_less_use_double_quotes = true +ij_less_value_alignment = 0 + +[*.proto] +indent_size = 2 +tab_width = 2 +ij_continuation_indent_size = 4 +ij_protobuf_keep_blank_lines_in_code = 2 +ij_protobuf_keep_indents_on_empty_lines = false +ij_protobuf_keep_line_breaks = true +ij_protobuf_space_after_comma = true +ij_protobuf_space_before_comma = false +ij_protobuf_spaces_around_assignment_operators = true +ij_protobuf_spaces_within_braces = false +ij_protobuf_spaces_within_brackets = false + +[*.sass] +indent_size = 2 +ij_sass_align_closing_brace_with_properties = false +ij_sass_blank_lines_around_nested_selector = 1 +ij_sass_blank_lines_between_blocks = 1 +ij_sass_brace_placement = 0 +ij_sass_enforce_quotes_on_format = false +ij_sass_hex_color_long_format = false +ij_sass_hex_color_lower_case = false +ij_sass_hex_color_short_format = false +ij_sass_hex_color_upper_case = false +ij_sass_keep_blank_lines_in_code = 2 +ij_sass_keep_indents_on_empty_lines = false +ij_sass_keep_single_line_blocks = false +ij_sass_line_comment_add_space = false +ij_sass_line_comment_at_first_column = false +ij_sass_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow +ij_sass_space_after_colon = true +ij_sass_space_before_opening_brace = true +ij_sass_use_double_quotes = true +ij_sass_value_alignment = 0 + +[*.scss] +indent_size = 2 +ij_scss_align_closing_brace_with_properties = false +ij_scss_blank_lines_around_nested_selector = 1 +ij_scss_blank_lines_between_blocks = 1 +ij_scss_block_comment_add_space = false +ij_scss_brace_placement = 0 +ij_scss_enforce_quotes_on_format = false +ij_scss_hex_color_long_format = false +ij_scss_hex_color_lower_case = false +ij_scss_hex_color_short_format = false +ij_scss_hex_color_upper_case = false +ij_scss_keep_blank_lines_in_code = 2 +ij_scss_keep_indents_on_empty_lines = false +ij_scss_keep_single_line_blocks = false +ij_scss_line_comment_add_space = false +ij_scss_line_comment_at_first_column = false +ij_scss_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow +ij_scss_space_after_colon = true +ij_scss_space_before_opening_brace = true +ij_scss_use_double_quotes = true +ij_scss_value_alignment = 0 + +[*.vue] +indent_size = 2 +tab_width = 2 +ij_continuation_indent_size = 4 +ij_vue_indent_children_of_top_level = template +ij_vue_interpolation_new_line_after_start_delimiter = true +ij_vue_interpolation_new_line_before_end_delimiter = true +ij_vue_interpolation_wrap = off +ij_vue_keep_indents_on_empty_lines = false +ij_vue_spaces_within_interpolation_expressions = true + +[.editorconfig] +ij_editorconfig_align_group_field_declarations = false +ij_editorconfig_space_after_colon = false +ij_editorconfig_space_after_comma = true +ij_editorconfig_space_before_colon = false +ij_editorconfig_space_before_comma = false +ij_editorconfig_spaces_around_assignment_operators = true + +[machete] +indent_style = tab +ij_git-machete_keep_blank_lines_in_code = 1 +ij_git-machete_keep_indents_on_empty_lines = false + +[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.pom,*.rng,*.tld,*.wadl,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}] +ij_xml_align_attributes = true +ij_xml_align_text = false +ij_xml_attribute_wrap = normal +ij_xml_block_comment_add_space = false +ij_xml_block_comment_at_first_column = true +ij_xml_keep_blank_lines = 2 +ij_xml_keep_indents_on_empty_lines = false +ij_xml_keep_line_breaks = true +ij_xml_keep_line_breaks_in_text = true +ij_xml_keep_whitespaces = false +ij_xml_keep_whitespaces_around_cdata = preserve +ij_xml_keep_whitespaces_inside_cdata = false +ij_xml_line_comment_at_first_column = true +ij_xml_space_after_tag_name = false +ij_xml_space_around_equals_in_attribute = false +ij_xml_space_inside_empty_tag = false +ij_xml_text_wrap = normal +ij_xml_use_custom_settings = false + +[{*.ats,*.cts,*.mts,*.ts}] +ij_continuation_indent_size = 4 +ij_typescript_align_imports = false +ij_typescript_align_multiline_array_initializer_expression = false +ij_typescript_align_multiline_binary_operation = false +ij_typescript_align_multiline_chained_methods = false +ij_typescript_align_multiline_extends_list = false +ij_typescript_align_multiline_for = true +ij_typescript_align_multiline_parameters = true +ij_typescript_align_multiline_parameters_in_calls = false +ij_typescript_align_multiline_ternary_operation = false +ij_typescript_align_object_properties = 0 +ij_typescript_align_union_types = false +ij_typescript_align_var_statements = 0 +ij_typescript_array_initializer_new_line_after_left_brace = false +ij_typescript_array_initializer_right_brace_on_new_line = false +ij_typescript_array_initializer_wrap = off +ij_typescript_assignment_wrap = off +ij_typescript_binary_operation_sign_on_next_line = false +ij_typescript_binary_operation_wrap = off +ij_typescript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/** +ij_typescript_blank_lines_after_imports = 1 +ij_typescript_blank_lines_around_class = 1 +ij_typescript_blank_lines_around_field = 0 +ij_typescript_blank_lines_around_field_in_interface = 0 +ij_typescript_blank_lines_around_function = 1 +ij_typescript_blank_lines_around_method = 1 +ij_typescript_blank_lines_around_method_in_interface = 1 +ij_typescript_block_brace_style = end_of_line +ij_typescript_block_comment_add_space = false +ij_typescript_block_comment_at_first_column = true +ij_typescript_call_parameters_new_line_after_left_paren = false +ij_typescript_call_parameters_right_paren_on_new_line = false +ij_typescript_call_parameters_wrap = off +ij_typescript_catch_on_new_line = false +ij_typescript_chained_call_dot_on_new_line = true +ij_typescript_class_brace_style = end_of_line +ij_typescript_comma_on_new_line = false +ij_typescript_do_while_brace_force = never +ij_typescript_else_on_new_line = false +ij_typescript_enforce_trailing_comma = keep +ij_typescript_enum_constants_wrap = on_every_item +ij_typescript_extends_keyword_wrap = off +ij_typescript_extends_list_wrap = off +ij_typescript_field_prefix = _ +ij_typescript_file_name_style = relaxed +ij_typescript_finally_on_new_line = false +ij_typescript_for_brace_force = never +ij_typescript_for_statement_new_line_after_left_paren = false +ij_typescript_for_statement_right_paren_on_new_line = false +ij_typescript_for_statement_wrap = off +ij_typescript_force_quote_style = false +ij_typescript_force_semicolon_style = false +ij_typescript_function_expression_brace_style = end_of_line +ij_typescript_if_brace_force = never +ij_typescript_import_merge_members = global +ij_typescript_import_prefer_absolute_path = global +ij_typescript_import_sort_members = true +ij_typescript_import_sort_module_name = false +ij_typescript_import_use_node_resolution = true +ij_typescript_imports_wrap = on_every_item +ij_typescript_indent_case_from_switch = true +ij_typescript_indent_chained_calls = true +ij_typescript_indent_package_children = 0 +ij_typescript_jsdoc_include_types = false +ij_typescript_jsx_attribute_value = braces +ij_typescript_keep_blank_lines_in_code = 2 +ij_typescript_keep_first_column_comment = true +ij_typescript_keep_indents_on_empty_lines = false +ij_typescript_keep_line_breaks = true +ij_typescript_keep_simple_blocks_in_one_line = false +ij_typescript_keep_simple_methods_in_one_line = false +ij_typescript_line_comment_add_space = true +ij_typescript_line_comment_at_first_column = false +ij_typescript_method_brace_style = end_of_line +ij_typescript_method_call_chain_wrap = off +ij_typescript_method_parameters_new_line_after_left_paren = false +ij_typescript_method_parameters_right_paren_on_new_line = false +ij_typescript_method_parameters_wrap = off +ij_typescript_object_literal_wrap = on_every_item +ij_typescript_object_types_wrap = on_every_item +ij_typescript_parentheses_expression_new_line_after_left_paren = false +ij_typescript_parentheses_expression_right_paren_on_new_line = false +ij_typescript_place_assignment_sign_on_next_line = false +ij_typescript_prefer_as_type_cast = false +ij_typescript_prefer_explicit_types_function_expression_returns = false +ij_typescript_prefer_explicit_types_function_returns = false +ij_typescript_prefer_explicit_types_vars_fields = false +ij_typescript_prefer_parameters_wrap = false +ij_typescript_property_prefix = +ij_typescript_reformat_c_style_comments = false +ij_typescript_space_after_colon = true +ij_typescript_space_after_comma = true +ij_typescript_space_after_dots_in_rest_parameter = false +ij_typescript_space_after_generator_mult = true +ij_typescript_space_after_property_colon = true +ij_typescript_space_after_quest = true +ij_typescript_space_after_type_colon = true +ij_typescript_space_after_unary_not = false +ij_typescript_space_before_async_arrow_lparen = true +ij_typescript_space_before_catch_keyword = true +ij_typescript_space_before_catch_left_brace = true +ij_typescript_space_before_catch_parentheses = true +ij_typescript_space_before_class_lbrace = true +ij_typescript_space_before_class_left_brace = true +ij_typescript_space_before_colon = true +ij_typescript_space_before_comma = false +ij_typescript_space_before_do_left_brace = true +ij_typescript_space_before_else_keyword = true +ij_typescript_space_before_else_left_brace = true +ij_typescript_space_before_finally_keyword = true +ij_typescript_space_before_finally_left_brace = true +ij_typescript_space_before_for_left_brace = true +ij_typescript_space_before_for_parentheses = true +ij_typescript_space_before_for_semicolon = false +ij_typescript_space_before_function_left_parenth = true +ij_typescript_space_before_generator_mult = false +ij_typescript_space_before_if_left_brace = true +ij_typescript_space_before_if_parentheses = true +ij_typescript_space_before_method_call_parentheses = false +ij_typescript_space_before_method_left_brace = true +ij_typescript_space_before_method_parentheses = false +ij_typescript_space_before_property_colon = false +ij_typescript_space_before_quest = true +ij_typescript_space_before_switch_left_brace = true +ij_typescript_space_before_switch_parentheses = true +ij_typescript_space_before_try_left_brace = true +ij_typescript_space_before_type_colon = false +ij_typescript_space_before_unary_not = false +ij_typescript_space_before_while_keyword = true +ij_typescript_space_before_while_left_brace = true +ij_typescript_space_before_while_parentheses = true +ij_typescript_spaces_around_additive_operators = true +ij_typescript_spaces_around_arrow_function_operator = true +ij_typescript_spaces_around_assignment_operators = true +ij_typescript_spaces_around_bitwise_operators = true +ij_typescript_spaces_around_equality_operators = true +ij_typescript_spaces_around_logical_operators = true +ij_typescript_spaces_around_multiplicative_operators = true +ij_typescript_spaces_around_relational_operators = true +ij_typescript_spaces_around_shift_operators = true +ij_typescript_spaces_around_unary_operator = false +ij_typescript_spaces_within_array_initializer_brackets = false +ij_typescript_spaces_within_brackets = false +ij_typescript_spaces_within_catch_parentheses = false +ij_typescript_spaces_within_for_parentheses = false +ij_typescript_spaces_within_if_parentheses = false +ij_typescript_spaces_within_imports = false +ij_typescript_spaces_within_interpolation_expressions = false +ij_typescript_spaces_within_method_call_parentheses = false +ij_typescript_spaces_within_method_parentheses = false +ij_typescript_spaces_within_object_literal_braces = false +ij_typescript_spaces_within_object_type_braces = true +ij_typescript_spaces_within_parentheses = false +ij_typescript_spaces_within_switch_parentheses = false +ij_typescript_spaces_within_type_assertion = false +ij_typescript_spaces_within_union_types = true +ij_typescript_spaces_within_while_parentheses = false +ij_typescript_special_else_if_treatment = true +ij_typescript_ternary_operation_signs_on_next_line = false +ij_typescript_ternary_operation_wrap = off +ij_typescript_union_types_wrap = on_every_item +ij_typescript_use_chained_calls_group_indents = false +ij_typescript_use_double_quotes = true +ij_typescript_use_explicit_js_extension = auto +ij_typescript_use_path_mapping = always +ij_typescript_use_public_modifier = false +ij_typescript_use_semicolon_after_statement = true +ij_typescript_var_declaration_wrap = normal +ij_typescript_while_brace_force = never +ij_typescript_while_on_new_line = false +ij_typescript_wrap_comments = false + +[{*.bash,*.sh,*.zsh}] +indent_size = 2 +tab_width = 2 +ij_shell_binary_ops_start_line = false +ij_shell_keep_column_alignment_padding = false +ij_shell_minify_program = false +ij_shell_redirect_followed_by_space = false +ij_shell_switch_cases_indented = false +ij_shell_use_unix_line_separator = true + +[{*.bot,*.cast,*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config}] +indent_size = 2 +ij_json_array_wrapping = split_into_lines +ij_json_keep_blank_lines_in_code = 0 +ij_json_keep_indents_on_empty_lines = false +ij_json_keep_line_breaks = true +ij_json_keep_trailing_comma = false +ij_json_object_wrapping = split_into_lines +ij_json_property_alignment = do_not_align +ij_json_space_after_colon = true +ij_json_space_after_comma = true +ij_json_space_before_colon = false +ij_json_space_before_comma = false +ij_json_spaces_within_braces = false +ij_json_spaces_within_brackets = false +ij_json_wrap_long_lines = false + +[{*.cjs,*.js}] +ij_continuation_indent_size = 4 +ij_javascript_align_imports = false +ij_javascript_align_multiline_array_initializer_expression = false +ij_javascript_align_multiline_binary_operation = false +ij_javascript_align_multiline_chained_methods = false +ij_javascript_align_multiline_extends_list = false +ij_javascript_align_multiline_for = true +ij_javascript_align_multiline_parameters = true +ij_javascript_align_multiline_parameters_in_calls = false +ij_javascript_align_multiline_ternary_operation = false +ij_javascript_align_object_properties = 0 +ij_javascript_align_union_types = false +ij_javascript_align_var_statements = 0 +ij_javascript_array_initializer_new_line_after_left_brace = false +ij_javascript_array_initializer_right_brace_on_new_line = false +ij_javascript_array_initializer_wrap = off +ij_javascript_assignment_wrap = off +ij_javascript_binary_operation_sign_on_next_line = false +ij_javascript_binary_operation_wrap = off +ij_javascript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/** +ij_javascript_blank_lines_after_imports = 1 +ij_javascript_blank_lines_around_class = 1 +ij_javascript_blank_lines_around_field = 0 +ij_javascript_blank_lines_around_function = 1 +ij_javascript_blank_lines_around_method = 1 +ij_javascript_block_brace_style = end_of_line +ij_javascript_block_comment_add_space = false +ij_javascript_block_comment_at_first_column = true +ij_javascript_call_parameters_new_line_after_left_paren = false +ij_javascript_call_parameters_right_paren_on_new_line = false +ij_javascript_call_parameters_wrap = off +ij_javascript_catch_on_new_line = false +ij_javascript_chained_call_dot_on_new_line = true +ij_javascript_class_brace_style = end_of_line +ij_javascript_comma_on_new_line = false +ij_javascript_do_while_brace_force = never +ij_javascript_else_on_new_line = false +ij_javascript_enforce_trailing_comma = keep +ij_javascript_extends_keyword_wrap = off +ij_javascript_extends_list_wrap = off +ij_javascript_field_prefix = _ +ij_javascript_file_name_style = relaxed +ij_javascript_finally_on_new_line = false +ij_javascript_for_brace_force = never +ij_javascript_for_statement_new_line_after_left_paren = false +ij_javascript_for_statement_right_paren_on_new_line = false +ij_javascript_for_statement_wrap = off +ij_javascript_force_quote_style = false +ij_javascript_force_semicolon_style = false +ij_javascript_function_expression_brace_style = end_of_line +ij_javascript_if_brace_force = never +ij_javascript_import_merge_members = global +ij_javascript_import_prefer_absolute_path = global +ij_javascript_import_sort_members = true +ij_javascript_import_sort_module_name = false +ij_javascript_import_use_node_resolution = true +ij_javascript_imports_wrap = on_every_item +ij_javascript_indent_case_from_switch = true +ij_javascript_indent_chained_calls = true +ij_javascript_indent_package_children = 0 +ij_javascript_jsx_attribute_value = braces +ij_javascript_keep_blank_lines_in_code = 2 +ij_javascript_keep_first_column_comment = true +ij_javascript_keep_indents_on_empty_lines = false +ij_javascript_keep_line_breaks = true +ij_javascript_keep_simple_blocks_in_one_line = false +ij_javascript_keep_simple_methods_in_one_line = false +ij_javascript_line_comment_add_space = true +ij_javascript_line_comment_at_first_column = false +ij_javascript_method_brace_style = end_of_line +ij_javascript_method_call_chain_wrap = off +ij_javascript_method_parameters_new_line_after_left_paren = false +ij_javascript_method_parameters_right_paren_on_new_line = false +ij_javascript_method_parameters_wrap = off +ij_javascript_object_literal_wrap = on_every_item +ij_javascript_object_types_wrap = on_every_item +ij_javascript_parentheses_expression_new_line_after_left_paren = false +ij_javascript_parentheses_expression_right_paren_on_new_line = false +ij_javascript_place_assignment_sign_on_next_line = false +ij_javascript_prefer_as_type_cast = false +ij_javascript_prefer_explicit_types_function_expression_returns = false +ij_javascript_prefer_explicit_types_function_returns = false +ij_javascript_prefer_explicit_types_vars_fields = false +ij_javascript_prefer_parameters_wrap = false +ij_javascript_property_prefix = +ij_javascript_reformat_c_style_comments = false +ij_javascript_space_after_colon = true +ij_javascript_space_after_comma = true +ij_javascript_space_after_dots_in_rest_parameter = false +ij_javascript_space_after_generator_mult = true +ij_javascript_space_after_property_colon = true +ij_javascript_space_after_quest = true +ij_javascript_space_after_type_colon = true +ij_javascript_space_after_unary_not = false +ij_javascript_space_before_async_arrow_lparen = true +ij_javascript_space_before_catch_keyword = true +ij_javascript_space_before_catch_left_brace = true +ij_javascript_space_before_catch_parentheses = true +ij_javascript_space_before_class_lbrace = true +ij_javascript_space_before_class_left_brace = true +ij_javascript_space_before_colon = true +ij_javascript_space_before_comma = false +ij_javascript_space_before_do_left_brace = true +ij_javascript_space_before_else_keyword = true +ij_javascript_space_before_else_left_brace = true +ij_javascript_space_before_finally_keyword = true +ij_javascript_space_before_finally_left_brace = true +ij_javascript_space_before_for_left_brace = true +ij_javascript_space_before_for_parentheses = true +ij_javascript_space_before_for_semicolon = false +ij_javascript_space_before_function_left_parenth = true +ij_javascript_space_before_generator_mult = false +ij_javascript_space_before_if_left_brace = true +ij_javascript_space_before_if_parentheses = true +ij_javascript_space_before_method_call_parentheses = false +ij_javascript_space_before_method_left_brace = true +ij_javascript_space_before_method_parentheses = false +ij_javascript_space_before_property_colon = false +ij_javascript_space_before_quest = true +ij_javascript_space_before_switch_left_brace = true +ij_javascript_space_before_switch_parentheses = true +ij_javascript_space_before_try_left_brace = true +ij_javascript_space_before_type_colon = false +ij_javascript_space_before_unary_not = false +ij_javascript_space_before_while_keyword = true +ij_javascript_space_before_while_left_brace = true +ij_javascript_space_before_while_parentheses = true +ij_javascript_spaces_around_additive_operators = true +ij_javascript_spaces_around_arrow_function_operator = true +ij_javascript_spaces_around_assignment_operators = true +ij_javascript_spaces_around_bitwise_operators = true +ij_javascript_spaces_around_equality_operators = true +ij_javascript_spaces_around_logical_operators = true +ij_javascript_spaces_around_multiplicative_operators = true +ij_javascript_spaces_around_relational_operators = true +ij_javascript_spaces_around_shift_operators = true +ij_javascript_spaces_around_unary_operator = false +ij_javascript_spaces_within_array_initializer_brackets = false +ij_javascript_spaces_within_brackets = false +ij_javascript_spaces_within_catch_parentheses = false +ij_javascript_spaces_within_for_parentheses = false +ij_javascript_spaces_within_if_parentheses = false +ij_javascript_spaces_within_imports = false +ij_javascript_spaces_within_interpolation_expressions = false +ij_javascript_spaces_within_method_call_parentheses = false +ij_javascript_spaces_within_method_parentheses = false +ij_javascript_spaces_within_object_literal_braces = false +ij_javascript_spaces_within_object_type_braces = true +ij_javascript_spaces_within_parentheses = false +ij_javascript_spaces_within_switch_parentheses = false +ij_javascript_spaces_within_type_assertion = false +ij_javascript_spaces_within_union_types = true +ij_javascript_spaces_within_while_parentheses = false +ij_javascript_special_else_if_treatment = true +ij_javascript_ternary_operation_signs_on_next_line = false +ij_javascript_ternary_operation_wrap = off +ij_javascript_union_types_wrap = on_every_item +ij_javascript_use_chained_calls_group_indents = false +ij_javascript_use_double_quotes = true +ij_javascript_use_explicit_js_extension = auto +ij_javascript_use_path_mapping = always +ij_javascript_use_public_modifier = false +ij_javascript_use_semicolon_after_statement = true +ij_javascript_var_declaration_wrap = normal +ij_javascript_while_brace_force = never +ij_javascript_while_on_new_line = false +ij_javascript_wrap_comments = false + +[{*.factories,*.properties,spring.handlers,spring.schemas}] +ij_properties_align_group_field_declarations = false +ij_properties_keep_blank_lines = false +ij_properties_key_value_delimiter = equals +ij_properties_spaces_around_key_value_delimiter = false + +[{*.ft,*.vm,*.vsl}] +ij_vtl_keep_indents_on_empty_lines = false + +[{*.gant,*.groovy,*.gy}] +ij_groovy_align_group_field_declarations = false +ij_groovy_align_multiline_array_initializer_expression = false +ij_groovy_align_multiline_assignment = false +ij_groovy_align_multiline_binary_operation = false +ij_groovy_align_multiline_chained_methods = false +ij_groovy_align_multiline_extends_list = false +ij_groovy_align_multiline_for = true +ij_groovy_align_multiline_list_or_map = true +ij_groovy_align_multiline_method_parentheses = false +ij_groovy_align_multiline_parameters = true +ij_groovy_align_multiline_parameters_in_calls = false +ij_groovy_align_multiline_resources = true +ij_groovy_align_multiline_ternary_operation = false +ij_groovy_align_multiline_throws_list = false +ij_groovy_align_named_args_in_map = true +ij_groovy_align_throws_keyword = false +ij_groovy_array_initializer_new_line_after_left_brace = false +ij_groovy_array_initializer_right_brace_on_new_line = false +ij_groovy_array_initializer_wrap = off +ij_groovy_assert_statement_wrap = off +ij_groovy_assignment_wrap = off +ij_groovy_binary_operation_wrap = off +ij_groovy_blank_lines_after_class_header = 0 +ij_groovy_blank_lines_after_imports = 1 +ij_groovy_blank_lines_after_package = 1 +ij_groovy_blank_lines_around_class = 1 +ij_groovy_blank_lines_around_field = 0 +ij_groovy_blank_lines_around_field_in_interface = 0 +ij_groovy_blank_lines_around_method = 1 +ij_groovy_blank_lines_around_method_in_interface = 1 +ij_groovy_blank_lines_before_imports = 1 +ij_groovy_blank_lines_before_method_body = 0 +ij_groovy_blank_lines_before_package = 0 +ij_groovy_block_brace_style = end_of_line +ij_groovy_block_comment_add_space = false +ij_groovy_block_comment_at_first_column = true +ij_groovy_call_parameters_new_line_after_left_paren = false +ij_groovy_call_parameters_right_paren_on_new_line = false +ij_groovy_call_parameters_wrap = off +ij_groovy_catch_on_new_line = false +ij_groovy_class_annotation_wrap = split_into_lines +ij_groovy_class_brace_style = end_of_line +ij_groovy_class_count_to_use_import_on_demand = 5 +ij_groovy_do_while_brace_force = never +ij_groovy_else_on_new_line = false +ij_groovy_enable_groovydoc_formatting = true +ij_groovy_enum_constants_wrap = off +ij_groovy_extends_keyword_wrap = off +ij_groovy_extends_list_wrap = off +ij_groovy_field_annotation_wrap = split_into_lines +ij_groovy_finally_on_new_line = false +ij_groovy_for_brace_force = never +ij_groovy_for_statement_new_line_after_left_paren = false +ij_groovy_for_statement_right_paren_on_new_line = false +ij_groovy_for_statement_wrap = off +ij_groovy_ginq_general_clause_wrap_policy = 2 +ij_groovy_ginq_having_wrap_policy = 1 +ij_groovy_ginq_indent_having_clause = true +ij_groovy_ginq_indent_on_clause = true +ij_groovy_ginq_on_wrap_policy = 1 +ij_groovy_ginq_space_after_keyword = true +ij_groovy_if_brace_force = never +ij_groovy_import_annotation_wrap = 2 +ij_groovy_imports_layout = *,|,javax.**,java.**,|,$* +ij_groovy_indent_case_from_switch = true +ij_groovy_indent_label_blocks = true +ij_groovy_insert_inner_class_imports = false +ij_groovy_keep_blank_lines_before_right_brace = 2 +ij_groovy_keep_blank_lines_in_code = 2 +ij_groovy_keep_blank_lines_in_declarations = 2 +ij_groovy_keep_control_statement_in_one_line = true +ij_groovy_keep_first_column_comment = true +ij_groovy_keep_indents_on_empty_lines = false +ij_groovy_keep_line_breaks = true +ij_groovy_keep_multiple_expressions_in_one_line = false +ij_groovy_keep_simple_blocks_in_one_line = false +ij_groovy_keep_simple_classes_in_one_line = true +ij_groovy_keep_simple_lambdas_in_one_line = true +ij_groovy_keep_simple_methods_in_one_line = true +ij_groovy_label_indent_absolute = false +ij_groovy_label_indent_size = 0 +ij_groovy_lambda_brace_style = end_of_line +ij_groovy_layout_static_imports_separately = true +ij_groovy_line_comment_add_space = false +ij_groovy_line_comment_add_space_on_reformat = false +ij_groovy_line_comment_at_first_column = true +ij_groovy_method_annotation_wrap = split_into_lines +ij_groovy_method_brace_style = end_of_line +ij_groovy_method_call_chain_wrap = off +ij_groovy_method_parameters_new_line_after_left_paren = false +ij_groovy_method_parameters_right_paren_on_new_line = false +ij_groovy_method_parameters_wrap = off +ij_groovy_modifier_list_wrap = false +ij_groovy_names_count_to_use_import_on_demand = 3 +ij_groovy_packages_to_use_import_on_demand = java.awt.*,javax.swing.* +ij_groovy_parameter_annotation_wrap = off +ij_groovy_parentheses_expression_new_line_after_left_paren = false +ij_groovy_parentheses_expression_right_paren_on_new_line = false +ij_groovy_prefer_parameters_wrap = false +ij_groovy_resource_list_new_line_after_left_paren = false +ij_groovy_resource_list_right_paren_on_new_line = false +ij_groovy_resource_list_wrap = off +ij_groovy_space_after_assert_separator = true +ij_groovy_space_after_colon = true +ij_groovy_space_after_comma = true +ij_groovy_space_after_comma_in_type_arguments = true +ij_groovy_space_after_for_semicolon = true +ij_groovy_space_after_quest = true +ij_groovy_space_after_type_cast = true +ij_groovy_space_before_annotation_parameter_list = false +ij_groovy_space_before_array_initializer_left_brace = false +ij_groovy_space_before_assert_separator = false +ij_groovy_space_before_catch_keyword = true +ij_groovy_space_before_catch_left_brace = true +ij_groovy_space_before_catch_parentheses = true +ij_groovy_space_before_class_left_brace = true +ij_groovy_space_before_closure_left_brace = true +ij_groovy_space_before_colon = true +ij_groovy_space_before_comma = false +ij_groovy_space_before_do_left_brace = true +ij_groovy_space_before_else_keyword = true +ij_groovy_space_before_else_left_brace = true +ij_groovy_space_before_finally_keyword = true +ij_groovy_space_before_finally_left_brace = true +ij_groovy_space_before_for_left_brace = true +ij_groovy_space_before_for_parentheses = true +ij_groovy_space_before_for_semicolon = false +ij_groovy_space_before_if_left_brace = true +ij_groovy_space_before_if_parentheses = true +ij_groovy_space_before_method_call_parentheses = false +ij_groovy_space_before_method_left_brace = true +ij_groovy_space_before_method_parentheses = false +ij_groovy_space_before_quest = true +ij_groovy_space_before_record_parentheses = false +ij_groovy_space_before_switch_left_brace = true +ij_groovy_space_before_switch_parentheses = true +ij_groovy_space_before_synchronized_left_brace = true +ij_groovy_space_before_synchronized_parentheses = true +ij_groovy_space_before_try_left_brace = true +ij_groovy_space_before_try_parentheses = true +ij_groovy_space_before_while_keyword = true +ij_groovy_space_before_while_left_brace = true +ij_groovy_space_before_while_parentheses = true +ij_groovy_space_in_named_argument = true +ij_groovy_space_in_named_argument_before_colon = false +ij_groovy_space_within_empty_array_initializer_braces = false +ij_groovy_space_within_empty_method_call_parentheses = false +ij_groovy_spaces_around_additive_operators = true +ij_groovy_spaces_around_assignment_operators = true +ij_groovy_spaces_around_bitwise_operators = true +ij_groovy_spaces_around_equality_operators = true +ij_groovy_spaces_around_lambda_arrow = true +ij_groovy_spaces_around_logical_operators = true +ij_groovy_spaces_around_multiplicative_operators = true +ij_groovy_spaces_around_regex_operators = true +ij_groovy_spaces_around_relational_operators = true +ij_groovy_spaces_around_shift_operators = true +ij_groovy_spaces_within_annotation_parentheses = false +ij_groovy_spaces_within_array_initializer_braces = false +ij_groovy_spaces_within_braces = true +ij_groovy_spaces_within_brackets = false +ij_groovy_spaces_within_cast_parentheses = false +ij_groovy_spaces_within_catch_parentheses = false +ij_groovy_spaces_within_for_parentheses = false +ij_groovy_spaces_within_gstring_injection_braces = false +ij_groovy_spaces_within_if_parentheses = false +ij_groovy_spaces_within_list_or_map = false +ij_groovy_spaces_within_method_call_parentheses = false +ij_groovy_spaces_within_method_parentheses = false +ij_groovy_spaces_within_parentheses = false +ij_groovy_spaces_within_switch_parentheses = false +ij_groovy_spaces_within_synchronized_parentheses = false +ij_groovy_spaces_within_try_parentheses = false +ij_groovy_spaces_within_tuple_expression = false +ij_groovy_spaces_within_while_parentheses = false +ij_groovy_special_else_if_treatment = true +ij_groovy_ternary_operation_wrap = off +ij_groovy_throws_keyword_wrap = off +ij_groovy_throws_list_wrap = off +ij_groovy_use_flying_geese_braces = false +ij_groovy_use_fq_class_names = false +ij_groovy_use_fq_class_names_in_javadoc = true +ij_groovy_use_relative_indents = false +ij_groovy_use_single_class_imports = true +ij_groovy_variable_annotation_wrap = off +ij_groovy_while_brace_force = never +ij_groovy_while_on_new_line = false +ij_groovy_wrap_chain_calls_after_dot = false +ij_groovy_wrap_long_lines = false + +[{*.gradle.kts,*.kt,*.kts,*.main.kts,*.space.kts}] +ij_kotlin_align_in_columns_case_branch = false +ij_kotlin_align_multiline_binary_operation = false +ij_kotlin_align_multiline_extends_list = false +ij_kotlin_align_multiline_method_parentheses = false +ij_kotlin_align_multiline_parameters = true +ij_kotlin_align_multiline_parameters_in_calls = false +ij_kotlin_allow_trailing_comma = false +ij_kotlin_allow_trailing_comma_on_call_site = false +ij_kotlin_assignment_wrap = normal +ij_kotlin_blank_lines_after_class_header = 0 +ij_kotlin_blank_lines_around_block_when_branches = 0 +ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1 +ij_kotlin_block_comment_add_space = false +ij_kotlin_block_comment_at_first_column = true +ij_kotlin_call_parameters_new_line_after_left_paren = true +ij_kotlin_call_parameters_right_paren_on_new_line = true +ij_kotlin_call_parameters_wrap = on_every_item +ij_kotlin_catch_on_new_line = false +ij_kotlin_class_annotation_wrap = split_into_lines +ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL +ij_kotlin_continuation_indent_for_chained_calls = false +ij_kotlin_continuation_indent_for_expression_bodies = false +ij_kotlin_continuation_indent_in_argument_lists = false +ij_kotlin_continuation_indent_in_elvis = false +ij_kotlin_continuation_indent_in_if_conditions = false +ij_kotlin_continuation_indent_in_parameter_lists = false +ij_kotlin_continuation_indent_in_supertype_lists = false +ij_kotlin_else_on_new_line = false +ij_kotlin_enum_constants_wrap = off +ij_kotlin_extends_list_wrap = normal +ij_kotlin_field_annotation_wrap = split_into_lines +ij_kotlin_finally_on_new_line = false +ij_kotlin_if_rparen_on_new_line = true +ij_kotlin_import_nested_classes = false +ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^ +ij_kotlin_insert_whitespaces_in_simple_one_line_method = true +ij_kotlin_keep_blank_lines_before_right_brace = 2 +ij_kotlin_keep_blank_lines_in_code = 2 +ij_kotlin_keep_blank_lines_in_declarations = 2 +ij_kotlin_keep_first_column_comment = true +ij_kotlin_keep_indents_on_empty_lines = false +ij_kotlin_keep_line_breaks = true +ij_kotlin_lbrace_on_next_line = false +ij_kotlin_line_break_after_multiline_when_entry = true +ij_kotlin_line_comment_add_space = true +ij_kotlin_line_comment_add_space_on_reformat = false +ij_kotlin_line_comment_at_first_column = false +ij_kotlin_method_annotation_wrap = split_into_lines +ij_kotlin_method_call_chain_wrap = normal +ij_kotlin_method_parameters_new_line_after_left_paren = true +ij_kotlin_method_parameters_right_paren_on_new_line = true +ij_kotlin_method_parameters_wrap = on_every_item +ij_kotlin_name_count_to_use_star_import = 5 +ij_kotlin_name_count_to_use_star_import_for_members = 3 +ij_kotlin_packages_to_use_import_on_demand = java.util.*,kotlinx.android.synthetic.**,io.ktor.** +ij_kotlin_parameter_annotation_wrap = off +ij_kotlin_space_after_comma = true +ij_kotlin_space_after_extend_colon = true +ij_kotlin_space_after_type_colon = true +ij_kotlin_space_before_catch_parentheses = true +ij_kotlin_space_before_comma = false +ij_kotlin_space_before_extend_colon = true +ij_kotlin_space_before_for_parentheses = true +ij_kotlin_space_before_if_parentheses = true +ij_kotlin_space_before_lambda_arrow = true +ij_kotlin_space_before_type_colon = false +ij_kotlin_space_before_when_parentheses = true +ij_kotlin_space_before_while_parentheses = true +ij_kotlin_spaces_around_additive_operators = true +ij_kotlin_spaces_around_assignment_operators = true +ij_kotlin_spaces_around_equality_operators = true +ij_kotlin_spaces_around_function_type_arrow = true +ij_kotlin_spaces_around_logical_operators = true +ij_kotlin_spaces_around_multiplicative_operators = true +ij_kotlin_spaces_around_range = false +ij_kotlin_spaces_around_relational_operators = true +ij_kotlin_spaces_around_unary_operator = false +ij_kotlin_spaces_around_when_arrow = true +ij_kotlin_use_custom_formatting_for_modifiers = true +ij_kotlin_variable_annotation_wrap = off +ij_kotlin_while_on_new_line = false +ij_kotlin_wrap_elvis_expressions = 1 +ij_kotlin_wrap_expression_body_functions = 1 +ij_kotlin_wrap_first_method_in_call_chain = false + +[{*.htm,*.html,*.ng,*.sht,*.shtm,*.shtml}] +ij_html_add_new_line_before_tags = body,div,p,form,h1,h2,h3 +ij_html_align_attributes = true +ij_html_align_text = false +ij_html_attribute_wrap = normal +ij_html_block_comment_add_space = false +ij_html_block_comment_at_first_column = true +ij_html_do_not_align_children_of_min_lines = 0 +ij_html_do_not_break_if_inline_tags = title,h1,h2,h3,h4,h5,h6,p +ij_html_do_not_indent_children_of_tags = html,body,thead,tbody,tfoot +ij_html_enforce_quotes = false +ij_html_inline_tags = a,abbr,acronym,b,basefont,bdo,big,br,cite,cite,code,dfn,em,font,i,img,input,kbd,label,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var +ij_html_keep_blank_lines = 2 +ij_html_keep_indents_on_empty_lines = false +ij_html_keep_line_breaks = true +ij_html_keep_line_breaks_in_text = true +ij_html_keep_whitespaces = false +ij_html_keep_whitespaces_inside = span,pre,textarea +ij_html_line_comment_at_first_column = true +ij_html_new_line_after_last_attribute = never +ij_html_new_line_before_first_attribute = never +ij_html_quote_style = double +ij_html_remove_new_line_before_tags = br +ij_html_space_after_tag_name = false +ij_html_space_around_equality_in_attribute = false +ij_html_space_inside_empty_tag = false +ij_html_text_wrap = normal + +[{*.http,*.rest}] +indent_size = 0 +ij_continuation_indent_size = 4 +ij_http-request_call_parameters_wrap = normal +ij_http-request_method_parameters_wrap = split_into_lines +ij_http-request_space_before_comma = true +ij_http-request_spaces_around_assignment_operators = true + +[{*.java,*.jvav}] +ij_java_align_consecutive_assignments = false +ij_java_align_consecutive_variable_declarations = false +ij_java_align_group_field_declarations = false +ij_java_align_multiline_annotation_parameters = false +ij_java_align_multiline_array_initializer_expression = false +ij_java_align_multiline_assignment = false +ij_java_align_multiline_binary_operation = true +ij_java_align_multiline_chained_methods = false +ij_java_align_multiline_deconstruction_list_components = true +ij_java_align_multiline_extends_list = false +ij_java_align_multiline_for = true +ij_java_align_multiline_method_parentheses = false +ij_java_align_multiline_parameters = true +ij_java_align_multiline_parameters_in_calls = false +ij_java_align_multiline_parenthesized_expression = false +ij_java_align_multiline_records = true +ij_java_align_multiline_resources = true +ij_java_align_multiline_ternary_operation = false +ij_java_align_multiline_text_blocks = false +ij_java_align_multiline_throws_list = false +ij_java_align_subsequent_simple_methods = false +ij_java_align_throws_keyword = false +ij_java_align_types_in_multi_catch = true +ij_java_annotation_parameter_wrap = off +ij_java_array_initializer_new_line_after_left_brace = false +ij_java_array_initializer_right_brace_on_new_line = false +ij_java_array_initializer_wrap = off +ij_java_assert_statement_colon_on_next_line = false +ij_java_assert_statement_wrap = off +ij_java_assignment_wrap = off +ij_java_binary_operation_sign_on_next_line = false +ij_java_binary_operation_wrap = off +ij_java_blank_lines_after_anonymous_class_header = 0 +ij_java_blank_lines_after_class_header = 0 +ij_java_blank_lines_after_imports = 1 +ij_java_blank_lines_after_package = 1 +ij_java_blank_lines_around_class = 1 +ij_java_blank_lines_around_field = 0 +ij_java_blank_lines_around_field_in_interface = 0 +ij_java_blank_lines_around_initializer = 1 +ij_java_blank_lines_around_method = 1 +ij_java_blank_lines_around_method_in_interface = 1 +ij_java_blank_lines_before_class_end = 0 +ij_java_blank_lines_before_imports = 1 +ij_java_blank_lines_before_method_body = 0 +ij_java_blank_lines_before_package = 0 +ij_java_block_brace_style = end_of_line +ij_java_block_comment_add_space = false +ij_java_block_comment_at_first_column = true +ij_java_builder_methods = +ij_java_call_parameters_new_line_after_left_paren = false +ij_java_call_parameters_right_paren_on_new_line = false +ij_java_call_parameters_wrap = off +ij_java_case_statement_on_separate_line = true +ij_java_catch_on_new_line = false +ij_java_class_annotation_wrap = split_into_lines +ij_java_class_brace_style = end_of_line +ij_java_class_count_to_use_import_on_demand = 5 +ij_java_class_names_in_javadoc = 1 +ij_java_deconstruction_list_wrap = normal +ij_java_do_not_indent_top_level_class_members = false +ij_java_do_not_wrap_after_single_annotation = false +ij_java_do_not_wrap_after_single_annotation_in_parameter = false +ij_java_do_while_brace_force = never +ij_java_doc_add_blank_line_after_description = true +ij_java_doc_add_blank_line_after_param_comments = false +ij_java_doc_add_blank_line_after_return = false +ij_java_doc_add_p_tag_on_empty_lines = true +ij_java_doc_align_exception_comments = true +ij_java_doc_align_param_comments = true +ij_java_doc_do_not_wrap_if_one_line = false +ij_java_doc_enable_formatting = true +ij_java_doc_enable_leading_asterisks = true +ij_java_doc_indent_on_continuation = false +ij_java_doc_keep_empty_lines = true +ij_java_doc_keep_empty_parameter_tag = true +ij_java_doc_keep_empty_return_tag = true +ij_java_doc_keep_empty_throws_tag = true +ij_java_doc_keep_invalid_tags = true +ij_java_doc_param_description_on_new_line = false +ij_java_doc_preserve_line_breaks = false +ij_java_doc_use_throws_not_exception_tag = true +ij_java_else_on_new_line = false +ij_java_entity_dd_prefix = +ij_java_entity_dd_suffix = EJB +ij_java_entity_eb_prefix = +ij_java_entity_eb_suffix = Bean +ij_java_entity_hi_prefix = +ij_java_entity_hi_suffix = Home +ij_java_entity_lhi_prefix = Local +ij_java_entity_lhi_suffix = Home +ij_java_entity_li_prefix = Local +ij_java_entity_li_suffix = +ij_java_entity_pk_class = java.lang.String +ij_java_entity_ri_prefix = +ij_java_entity_ri_suffix = +ij_java_entity_vo_prefix = +ij_java_entity_vo_suffix = VO +ij_java_enum_constants_wrap = off +ij_java_extends_keyword_wrap = off +ij_java_extends_list_wrap = off +ij_java_field_annotation_wrap = split_into_lines +ij_java_field_name_prefix = +ij_java_field_name_suffix = +ij_java_filter_class_prefix = +ij_java_filter_class_suffix = +ij_java_filter_dd_prefix = +ij_java_filter_dd_suffix = +ij_java_finally_on_new_line = false +ij_java_for_brace_force = never +ij_java_for_statement_new_line_after_left_paren = false +ij_java_for_statement_right_paren_on_new_line = false +ij_java_for_statement_wrap = off +ij_java_generate_final_locals = false +ij_java_generate_final_parameters = false +ij_java_if_brace_force = never +ij_java_imports_layout = *,|,javax.**,java.**,|,$* +ij_java_indent_case_from_switch = true +ij_java_insert_inner_class_imports = false +ij_java_insert_override_annotation = true +ij_java_keep_blank_lines_before_right_brace = 2 +ij_java_keep_blank_lines_between_package_declaration_and_header = 2 +ij_java_keep_blank_lines_in_code = 2 +ij_java_keep_blank_lines_in_declarations = 2 +ij_java_keep_builder_methods_indents = false +ij_java_keep_control_statement_in_one_line = true +ij_java_keep_first_column_comment = true +ij_java_keep_indents_on_empty_lines = false +ij_java_keep_line_breaks = true +ij_java_keep_multiple_expressions_in_one_line = false +ij_java_keep_simple_blocks_in_one_line = false +ij_java_keep_simple_classes_in_one_line = false +ij_java_keep_simple_lambdas_in_one_line = false +ij_java_keep_simple_methods_in_one_line = false +ij_java_label_indent_absolute = false +ij_java_label_indent_size = 0 +ij_java_lambda_brace_style = end_of_line +ij_java_layout_static_imports_separately = true +ij_java_line_comment_add_space = false +ij_java_line_comment_add_space_on_reformat = false +ij_java_line_comment_at_first_column = true +ij_java_listener_class_prefix = +ij_java_listener_class_suffix = +ij_java_local_variable_name_prefix = +ij_java_local_variable_name_suffix = +ij_java_message_dd_prefix = +ij_java_message_dd_suffix = EJB +ij_java_message_eb_prefix = +ij_java_message_eb_suffix = Bean +ij_java_method_annotation_wrap = split_into_lines +ij_java_method_brace_style = end_of_line +ij_java_method_call_chain_wrap = off +ij_java_method_parameters_new_line_after_left_paren = false +ij_java_method_parameters_right_paren_on_new_line = false +ij_java_method_parameters_wrap = off +ij_java_modifier_list_wrap = false +ij_java_multi_catch_types_wrap = normal +ij_java_names_count_to_use_import_on_demand = 3 +ij_java_new_line_after_lparen_in_annotation = false +ij_java_new_line_after_lparen_in_deconstruction_pattern = true +ij_java_new_line_after_lparen_in_record_header = false +ij_java_packages_to_use_import_on_demand = java.awt.*,javax.swing.* +ij_java_parameter_annotation_wrap = off +ij_java_parameter_name_prefix = +ij_java_parameter_name_suffix = +ij_java_parentheses_expression_new_line_after_left_paren = false +ij_java_parentheses_expression_right_paren_on_new_line = false +ij_java_place_assignment_sign_on_next_line = false +ij_java_prefer_longer_names = true +ij_java_prefer_parameters_wrap = false +ij_java_record_components_wrap = normal +ij_java_repeat_annotations = +ij_java_repeat_synchronized = true +ij_java_replace_instanceof_and_cast = false +ij_java_replace_null_check = true +ij_java_replace_sum_lambda_with_method_ref = true +ij_java_resource_list_new_line_after_left_paren = false +ij_java_resource_list_right_paren_on_new_line = false +ij_java_resource_list_wrap = off +ij_java_rparen_on_new_line_in_annotation = false +ij_java_rparen_on_new_line_in_deconstruction_pattern = true +ij_java_rparen_on_new_line_in_record_header = false +ij_java_servlet_class_prefix = +ij_java_servlet_class_suffix = +ij_java_servlet_dd_prefix = +ij_java_servlet_dd_suffix = +ij_java_session_dd_prefix = +ij_java_session_dd_suffix = EJB +ij_java_session_eb_prefix = +ij_java_session_eb_suffix = Bean +ij_java_session_hi_prefix = +ij_java_session_hi_suffix = Home +ij_java_session_lhi_prefix = Local +ij_java_session_lhi_suffix = Home +ij_java_session_li_prefix = Local +ij_java_session_li_suffix = +ij_java_session_ri_prefix = +ij_java_session_ri_suffix = +ij_java_session_si_prefix = +ij_java_session_si_suffix = Service +ij_java_space_after_closing_angle_bracket_in_type_argument = false +ij_java_space_after_colon = true +ij_java_space_after_comma = true +ij_java_space_after_comma_in_type_arguments = true +ij_java_space_after_for_semicolon = true +ij_java_space_after_quest = true +ij_java_space_after_type_cast = true +ij_java_space_before_annotation_array_initializer_left_brace = false +ij_java_space_before_annotation_parameter_list = false +ij_java_space_before_array_initializer_left_brace = false +ij_java_space_before_catch_keyword = true +ij_java_space_before_catch_left_brace = true +ij_java_space_before_catch_parentheses = true +ij_java_space_before_class_left_brace = true +ij_java_space_before_colon = true +ij_java_space_before_colon_in_foreach = true +ij_java_space_before_comma = false +ij_java_space_before_deconstruction_list = false +ij_java_space_before_do_left_brace = true +ij_java_space_before_else_keyword = true +ij_java_space_before_else_left_brace = true +ij_java_space_before_finally_keyword = true +ij_java_space_before_finally_left_brace = true +ij_java_space_before_for_left_brace = true +ij_java_space_before_for_parentheses = true +ij_java_space_before_for_semicolon = false +ij_java_space_before_if_left_brace = true +ij_java_space_before_if_parentheses = true +ij_java_space_before_method_call_parentheses = false +ij_java_space_before_method_left_brace = true +ij_java_space_before_method_parentheses = false +ij_java_space_before_opening_angle_bracket_in_type_parameter = false +ij_java_space_before_quest = true +ij_java_space_before_switch_left_brace = true +ij_java_space_before_switch_parentheses = true +ij_java_space_before_synchronized_left_brace = true +ij_java_space_before_synchronized_parentheses = true +ij_java_space_before_try_left_brace = true +ij_java_space_before_try_parentheses = true +ij_java_space_before_type_parameter_list = false +ij_java_space_before_while_keyword = true +ij_java_space_before_while_left_brace = true +ij_java_space_before_while_parentheses = true +ij_java_space_inside_one_line_enum_braces = false +ij_java_space_within_empty_array_initializer_braces = false +ij_java_space_within_empty_method_call_parentheses = false +ij_java_space_within_empty_method_parentheses = false +ij_java_spaces_around_additive_operators = true +ij_java_spaces_around_annotation_eq = true +ij_java_spaces_around_assignment_operators = true +ij_java_spaces_around_bitwise_operators = true +ij_java_spaces_around_equality_operators = true +ij_java_spaces_around_lambda_arrow = true +ij_java_spaces_around_logical_operators = true +ij_java_spaces_around_method_ref_dbl_colon = false +ij_java_spaces_around_multiplicative_operators = true +ij_java_spaces_around_relational_operators = true +ij_java_spaces_around_shift_operators = true +ij_java_spaces_around_type_bounds_in_type_parameters = true +ij_java_spaces_around_unary_operator = false +ij_java_spaces_within_angle_brackets = false +ij_java_spaces_within_annotation_parentheses = false +ij_java_spaces_within_array_initializer_braces = false +ij_java_spaces_within_braces = false +ij_java_spaces_within_brackets = false +ij_java_spaces_within_cast_parentheses = false +ij_java_spaces_within_catch_parentheses = false +ij_java_spaces_within_deconstruction_list = false +ij_java_spaces_within_for_parentheses = false +ij_java_spaces_within_if_parentheses = false +ij_java_spaces_within_method_call_parentheses = false +ij_java_spaces_within_method_parentheses = false +ij_java_spaces_within_parentheses = false +ij_java_spaces_within_record_header = false +ij_java_spaces_within_switch_parentheses = false +ij_java_spaces_within_synchronized_parentheses = false +ij_java_spaces_within_try_parentheses = false +ij_java_spaces_within_while_parentheses = false +ij_java_special_else_if_treatment = true +ij_java_static_field_name_prefix = +ij_java_static_field_name_suffix = +ij_java_subclass_name_prefix = +ij_java_subclass_name_suffix = Impl +ij_java_ternary_operation_signs_on_next_line = false +ij_java_ternary_operation_wrap = off +ij_java_test_name_prefix = +ij_java_test_name_suffix = Test +ij_java_throws_keyword_wrap = off +ij_java_throws_list_wrap = off +ij_java_use_external_annotations = false +ij_java_use_fq_class_names = false +ij_java_use_relative_indents = false +ij_java_use_single_class_imports = true +ij_java_variable_annotation_wrap = off +ij_java_visibility = public +ij_java_while_brace_force = never +ij_java_while_on_new_line = false +ij_java_wrap_comments = false +ij_java_wrap_first_method_in_call_chain = false +ij_java_wrap_long_lines = false + +[{*.jsf,*.jsp,*.jspf,*.tag,*.tagf,*.xjsp}] +ij_jsp_jsp_prefer_comma_separated_import_list = false +ij_jsp_keep_indents_on_empty_lines = false + +[{*.jspx,*.tagx}] +ij_jspx_keep_indents_on_empty_lines = false + +[{*.markdown,*.md,*.mdtmp,*.rmt}] +ij_markdown_force_one_space_after_blockquote_symbol = true +ij_markdown_force_one_space_after_header_symbol = true +ij_markdown_force_one_space_after_list_bullet = true +ij_markdown_force_one_space_between_words = true +ij_markdown_format_tables = true +ij_markdown_insert_quote_arrows_on_wrap = true +ij_markdown_keep_indents_on_empty_lines = false +ij_markdown_keep_line_breaks_inside_text_blocks = true +ij_markdown_max_lines_around_block_elements = 1 +ij_markdown_max_lines_around_header = 1 +ij_markdown_max_lines_between_paragraphs = 1 +ij_markdown_min_lines_around_block_elements = 1 +ij_markdown_min_lines_around_header = 1 +ij_markdown_min_lines_between_paragraphs = 1 +ij_markdown_wrap_text_if_long = true +ij_markdown_wrap_text_inside_blockquotes = true + +[{*.pb,*.textproto}] +indent_size = 2 +tab_width = 2 +ij_continuation_indent_size = 4 +ij_prototext_keep_blank_lines_in_code = 2 +ij_prototext_keep_indents_on_empty_lines = false +ij_prototext_keep_line_breaks = true +ij_prototext_space_after_colon = true +ij_prototext_space_after_comma = true +ij_prototext_space_before_colon = false +ij_prototext_space_before_comma = false +ij_prototext_spaces_within_braces = true +ij_prototext_spaces_within_brackets = false + +[{*.qute.htm,*.qute.html,*.qute.json,*.qute.txt,*.qute.yaml,*.qute.yml}] +ij_qute_keep_indents_on_empty_lines = false + +[{*.toml,Cargo.lock,Cargo.toml.orig,Gopkg.lock,Pipfile,poetry.lock}] +ij_toml_keep_indents_on_empty_lines = false + +[{*.yaml,*.yml}] +indent_size = 2 +ij_yaml_align_values_properties = do_not_align +ij_yaml_autoinsert_sequence_marker = true +ij_yaml_block_mapping_on_new_line = false +ij_yaml_indent_sequence_value = true +ij_yaml_keep_indents_on_empty_lines = false +ij_yaml_keep_line_breaks = true +ij_yaml_sequence_on_new_line = false +ij_yaml_space_before_colon = false +ij_yaml_spaces_within_braces = true +ij_yaml_spaces_within_brackets = true diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt index 0dee792..e2568b1 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt @@ -98,7 +98,6 @@ import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotG import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotHonorEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotLuckyKingEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotMemberPokeEventImpl -import love.forte.simbot.component.onebot.v11.core.event.internal.notice.OneBotNotifyEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.request.OneBotFriendRequestEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.request.OneBotGroupRequestEventImpl import love.forte.simbot.component.onebot.v11.core.event.internal.stage.OneBotBotStartedEventImpl @@ -477,7 +476,7 @@ internal class OneBotBotImpl( resolveRawEvent(eventRaw) }.getOrElse { e -> val exMsg = "Failed to resolve raw event $eventRaw, " + - "session and bot will be closed exceptionally" + "session and bot will be closed exceptionally" val ex = IllegalStateException( exMsg, From 80bb52441c2e644c1e22c28884ae0516b9bdb9c7 Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Sun, 9 Jun 2024 00:50:58 +0800 Subject: [PATCH 06/13] fix test and replace all `@InternalSimbotAPI` to `@InternalOneBotAPI` --- .../simbot/component/onebot/common/OneBot.kt | 4 +-- .../onebot/v11/common/utils/AvatarUtil.kt | 6 ++--- .../onebot/v11/core/api/OneBotApiRequests.kt | 4 +-- .../bot/OneBotBotSerializableConfiguration.kt | 6 ++--- .../component/onebot/v11/event/Event.kt | 6 ++--- .../build.gradle.kts | 9 +++++++ .../v11/message/MessageElementResolvers.kt | 27 +++++-------------- .../message/ListElementSerializationTests.kt | 2 -- .../src/jvmMain/java/module-info.java | 1 + 9 files changed, 29 insertions(+), 36 deletions(-) diff --git a/simbot-component-onebot-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/common/OneBot.kt b/simbot-component-onebot-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/common/OneBot.kt index 3f68bc8..fac2f7c 100644 --- a/simbot-component-onebot-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/common/OneBot.kt +++ b/simbot-component-onebot-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/common/OneBot.kt @@ -17,12 +17,12 @@ package love.forte.simbot.component.onebot.common -import love.forte.simbot.annotations.InternalSimbotAPI +import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI /** * An OneBot object. */ -@InternalSimbotAPI +@InternalOneBotAPI public object OneBot // TODO 一些Opt注解放在这个模块? diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/common/utils/AvatarUtil.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/common/utils/AvatarUtil.kt index 9deb65c..1132b31 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/common/utils/AvatarUtil.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/common/utils/AvatarUtil.kt @@ -19,7 +19,7 @@ package love.forte.simbot.component.onebot.v11.common.utils -import love.forte.simbot.annotations.InternalSimbotAPI +import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI import kotlin.jvm.JvmName /** @@ -27,7 +27,7 @@ import kotlin.jvm.JvmName * * @param id QQ号 */ -@InternalSimbotAPI +@InternalOneBotAPI public fun qqAvatar640(id: String): String = "https://q1.qlogo.cn/g?b=qq&nk=$id&s=640" @@ -36,6 +36,6 @@ public fun qqAvatar640(id: String): String = * * @param id QQ号 */ -@InternalSimbotAPI +@InternalOneBotAPI public fun qqAvatar100(id: String): String = "https://q1.qlogo.cn/g?b=qq&nk=$id&s=100" diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/api/OneBotApiRequests.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/api/OneBotApiRequests.kt index 8c931f8..015eb75 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/api/OneBotApiRequests.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/api/OneBotApiRequests.kt @@ -28,8 +28,8 @@ import io.ktor.client.statement.* import io.ktor.http.* import io.ktor.http.content.* import io.ktor.utils.io.charsets.* -import love.forte.simbot.annotations.InternalSimbotAPI import love.forte.simbot.common.serialization.guessSerializer +import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI import love.forte.simbot.component.onebot.v11.core.OneBot11 import love.forte.simbot.logger.Logger import love.forte.simbot.logger.LoggerFactory @@ -41,7 +41,7 @@ import kotlin.jvm.JvmSynthetic /** * 用于在对 [OneBotApi] 发起请求时或得到想用后输出相关日志日志收集器。 */ -@InternalSimbotAPI +@InternalOneBotAPI public val ApiLogger: Logger = LoggerFactory.getLogger("love.forte.simbot.component.onebot.v11.core.api.API") /** diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBotSerializableConfiguration.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBotSerializableConfiguration.kt index 0dc74be..646699a 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBotSerializableConfiguration.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBotSerializableConfiguration.kt @@ -17,11 +17,11 @@ package love.forte.simbot.component.onebot.v11.core.bot -import io.ktor.http.Url +import io.ktor.http.* import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import love.forte.simbot.annotations.InternalSimbotAPI import love.forte.simbot.bot.SerializableBotConfiguration +import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI import love.forte.simbot.component.onebot.v11.core.component.OneBot11Component @@ -33,7 +33,7 @@ import love.forte.simbot.component.onebot.v11.core.component.OneBot11Component * * @author ForteScarlet */ -@InternalSimbotAPI +@InternalOneBotAPI @Serializable @SerialName(OneBot11Component.ID_VALUE) public data class OneBotBotSerializableConfiguration( diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/Event.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/Event.kt index 3731709..e403407 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/Event.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/Event.kt @@ -17,8 +17,8 @@ package love.forte.simbot.component.onebot.v11.event -import love.forte.simbot.annotations.InternalSimbotAPI import love.forte.simbot.common.id.LongID +import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI /** @@ -98,7 +98,7 @@ public interface Event { * */ @Retention(AnnotationRetention.SOURCE) -@InternalSimbotAPI +@InternalOneBotAPI public annotation class ExpectEventType(val postType: String, val subType: String) /** @@ -109,5 +109,5 @@ public annotation class ExpectEventType(val postType: String, val subType: Strin * @suppress 用于项目内部代码生成器 */ @Retention(AnnotationRetention.SOURCE) -@InternalSimbotAPI +@InternalOneBotAPI public annotation class ExpectEventSubTypeProperty(val value: String, val postType: String, val name: String) diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-message/build.gradle.kts b/simbot-component-onebot-v11/simbot-component-onebot-v11-message/build.gradle.kts index c1cf926..6074747 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-message/build.gradle.kts +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-message/build.gradle.kts @@ -21,6 +21,7 @@ import love.forte.gradle.common.kotlin.multiplatform.applyTier1 import love.forte.gradle.common.kotlin.multiplatform.applyTier2 import love.forte.gradle.common.kotlin.multiplatform.applyTier3 import org.jetbrains.dokka.gradle.DokkaTaskPartial +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi plugins { kotlin("multiplatform") @@ -38,6 +39,13 @@ kotlin { explicitApi() applyDefaultHierarchyTemplate() + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerOptions { + optIn.addAll( + "love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI" + ) + } + configKotlinJvm() js(IR) { @@ -50,6 +58,7 @@ kotlin { sourceSets { commonMain.dependencies { + implementation(project(":simbot-component-onebot-common")) implementation(libs.simbot.api) implementation(libs.simbot.common.annotations) api(libs.kotlinx.coroutines.core) diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-message/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/message/MessageElementResolvers.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-message/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/message/MessageElementResolvers.kt index 6812a96..e343486 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-message/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/message/MessageElementResolvers.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-message/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/message/MessageElementResolvers.kt @@ -20,27 +20,12 @@ package love.forte.simbot.component.onebot.v11.message import kotlinx.coroutines.suspendCancellableCoroutine -import love.forte.simbot.annotations.InternalSimbotAPI import love.forte.simbot.common.id.StringID.Companion.ID import love.forte.simbot.common.id.literal -import love.forte.simbot.component.onebot.v11.message.segment.OneBotAt -import love.forte.simbot.component.onebot.v11.message.segment.OneBotFace -import love.forte.simbot.component.onebot.v11.message.segment.OneBotImage -import love.forte.simbot.component.onebot.v11.message.segment.OneBotMessageSegment -import love.forte.simbot.component.onebot.v11.message.segment.OneBotMessageSegmentElement -import love.forte.simbot.component.onebot.v11.message.segment.OneBotText -import love.forte.simbot.component.onebot.v11.message.segment.toElement -import love.forte.simbot.message.At -import love.forte.simbot.message.AtAll -import love.forte.simbot.message.Face -import love.forte.simbot.message.Image -import love.forte.simbot.message.Message -import love.forte.simbot.message.Messages -import love.forte.simbot.message.OfflineImage +import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI +import love.forte.simbot.component.onebot.v11.message.segment.* +import love.forte.simbot.message.* import love.forte.simbot.message.OfflineImageResolver.Companion.resolve -import love.forte.simbot.message.OfflineImageValueResolver -import love.forte.simbot.message.RemoteImage -import love.forte.simbot.message.Text import love.forte.simbot.resource.Resource import love.forte.simbot.resource.toResource import love.forte.simbot.resource.toStringResource @@ -57,7 +42,7 @@ import kotlin.jvm.JvmName * | [OneBotFace] | [Face] | * | 其他 | 使用 [toElement] 转化 | */ -@InternalSimbotAPI +@InternalOneBotAPI public fun OneBotMessageSegment.resolveToMessageElement(): Message.Element { return when (this) { is OneBotAt -> if (isAll) AtAll else At(data.qq.ID) @@ -71,7 +56,7 @@ public fun OneBotMessageSegment.resolveToMessageElement(): Message.Element { * * @see resolveToOneBotSegment */ -@InternalSimbotAPI +@InternalOneBotAPI public suspend fun Message.resolveToOneBotSegmentList(): List { return when (this) { is Message.Element -> resolveToOneBotSegment() @@ -85,7 +70,7 @@ public suspend fun Message.resolveToOneBotSegmentList(): List Date: Sun, 9 Jun 2024 03:47:09 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E6=9B=B4=E6=96=B0simbot=E6=A0=B8?= =?UTF-8?q?=E5=BF=83=E5=BA=93=E5=88=B04.0.0-RC3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish-release.yml | 4 +-- .github/workflows/publish-snapshot.yml | 2 +- buildSrc/build.gradle.kts | 8 +---- .../simbot-onebot-nexus-publish.gradle.kts | 15 +++++++--- gradle/libs.versions.toml | 30 ++----------------- 5 files changed, 17 insertions(+), 42 deletions(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 0d11ba7..15423d3 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -49,7 +49,7 @@ jobs: gradle-version: 8.5 arguments: | publishToSonatype - closeAndReleaseStagingRepository + closeAndReleaseStagingRepositories --info --warning-mode all -x test @@ -109,7 +109,7 @@ jobs: gradle-version: 8.5 arguments: | publishToSonatype - closeAndReleaseStagingRepository + closeAndReleaseStagingRepositories --info --warning-mode all -x test diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index c09153a..043cc83 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -61,7 +61,7 @@ jobs: arguments: | test publishToSonatype - closeAndReleaseStagingRepository + closeAndReleaseStagingRepositories --info --warning-mode all -Porg.gradle.jvmargs="-Xmx8g -Xms2g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8" diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 0cb8496..443f0da 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -34,7 +34,7 @@ dependencies { implementation(libs.bundles.dokka) // see https://github.com/gradle-nexus/publish-plugin - implementation("io.github.gradle-nexus:publish-plugin:1.1.0") + implementation("io.github.gradle-nexus:publish-plugin:2.0.0") // simbot suspend transform gradle common implementation(libs.simbot.gradle) @@ -45,9 +45,3 @@ dependencies { // gradle common implementation(libs.bundles.gradle.common) } - -//tasks.withType { -// kotlinOptions { -// languageVersion = "2.0" -// } -//} diff --git a/buildSrc/src/main/kotlin/simbot-onebot-nexus-publish.gradle.kts b/buildSrc/src/main/kotlin/simbot-onebot-nexus-publish.gradle.kts index 278dbe3..7db80ee 100644 --- a/buildSrc/src/main/kotlin/simbot-onebot-nexus-publish.gradle.kts +++ b/buildSrc/src/main/kotlin/simbot-onebot-nexus-publish.gradle.kts @@ -17,7 +17,7 @@ import love.forte.gradle.common.core.project.setup import love.forte.gradle.common.core.repository.Repositories -import love.forte.gradle.common.publication.configure.nexusPublishConfig +import java.time.Duration plugins { id("io.github.gradle-nexus.publish-plugin") @@ -31,10 +31,17 @@ if (userInfo == null) { logger.warn("sonatype.username or sonatype.password is null, cannot config nexus publishing.") } -nexusPublishConfig { - projectDetail = P.ComponentOneBot +nexusPublishing { + packageGroup.set(P.ComponentOneBot.group) + repositoryDescription.set(P.ComponentOneBot.description) useStaging = project.provider { !project.version.toString().endsWith("SNAPSHOT", ignoreCase = true) } - repositoriesConfig = { + + transitionCheckOptions { + maxRetries = 1000 + delayBetween = Duration.ofSeconds(2) + } + + repositories { sonatype { snapshotRepositoryUrl.set(uri(Repositories.Snapshot.URL)) username.set(userInfo?.username) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 71e3cf0..84fa631 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,19 +2,16 @@ kotlin = "2.0.0" kotlinx-coroutines = "1.8.1" kotlinx-serialization = "1.6.3" -kotlinx-datetime = "0.5.0" dokka = "1.9.20" -okio = "3.3.0" ktor = "2.3.8" openjdk-jmh = "1.35" log4j = "2.20.0" -reactor = "3.6.2" # simbot -simbot = "4.0.0-RC2" +simbot = "4.0.0-RC3" suspendTransform = "0.8.0-beta1" gradleCommon = "0.3.0" # ksp -ksp = "2.0.0-1.0.21" +ksp = "2.0.0-1.0.22" # https://square.github.io/kotlinpoet/ kotlinPoet = "1.16.0" # https://mockk.io/ @@ -43,33 +40,16 @@ jetbrains-annotations = "org.jetbrains:annotations:24.1.0" # kotlinx-coroutines kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } -kotlinx-coroutines-jdk8 = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-jdk8", version.ref = "kotlinx-coroutines" } -kotlinx-coroutines-reactive = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-reactive", version.ref = "kotlinx-coroutines" } -kotlinx-coroutines-reactor = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-reactor", version.ref = "kotlinx-coroutines" } -kotlinx-coroutines-rx2 = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-rx2", version.ref = "kotlinx-coroutines" } -kotlinx-coroutines-rx3 = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-rx3", version.ref = "kotlinx-coroutines" } -kotlinx-coroutines-guava = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-guava", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-slf4j = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-slf4j", version.ref = "kotlinx-coroutines" } -kotlinx-coroutines-play-services = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-play-services", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-debug = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-debug", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } # kotlinx-serialization kotlinx-serialization-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core", version.ref = "kotlinx-serialization" } kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serialization" } -kotlinx-serialization-hocon = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-hocon", version.ref = "kotlinx-serialization" } -kotlinx-serialization-protobuf = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-protobuf", version.ref = "kotlinx-serialization" } -kotlinx-serialization-cbor = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-cbor", version.ref = "kotlinx-serialization" } -kotlinx-serialization-properties = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-properties", version.ref = "kotlinx-serialization" } -charleskorn-kaml = "com.charleskorn.kaml:kaml:0.49.0" - -# kotlinx-datetime -kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinx-datetime" } # ktor ktor-serialization-kotlinxJson = { group = "io.ktor", name = "ktor-serialization-kotlinx-json", version.ref = "ktor" } -ktor-server-contentNegotiation = { group = "io.ktor", name = "ktor-server-content-negotiation", version.ref = "ktor" } -ktor-server-netty = { group = "io.ktor", name = "ktor-server-netty", version.ref = "ktor" } ktor-client-contentNegotiation = { group = "io.ktor", name = "ktor-client-content-negotiation", version.ref = "ktor" } ktor-client-serialization = { group = "io.ktor", name = "ktor-client-serialization", version.ref = "ktor" } @@ -90,9 +70,6 @@ ktor-client-winhttp = { group = "io.ktor", name = "ktor-client-winhttp", version # see https://ktor.io/docs/http-client-engines.html#darwin ktor-client-darwin = { group = "io.ktor", name = "ktor-client-darwin", version.ref = "ktor" } -# nodejsn -##kotlinx-odejs = "" - # log4j log4j-api = { group = "org.apache.logging.log4j", name = "log4j-api", version.ref = "log4j" } log4j-core = { group = "org.apache.logging.log4j", name = "log4j-core", version.ref = "log4j" } @@ -108,9 +85,6 @@ ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = kotlinPoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinPoet" } kotlinPoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlinPoet" } -# reactor -reactor-core = { group = "io.projectreactor", name = "reactor-core", version.ref = "reactor" } - # dokka dokka-plugin = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version.ref = "dokka" } dokka-base = { group = "org.jetbrains.dokka", name = "dokka-base", version.ref = "dokka" } From 1a56c9f1717ad850e050524fa9c4e2ac00bfe0d6 Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Sun, 9 Jun 2024 13:11:20 +0800 Subject: [PATCH 08/13] update gradle common version --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 84fa631..910de0f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,7 @@ log4j = "2.20.0" # simbot simbot = "4.0.0-RC3" suspendTransform = "0.8.0-beta1" -gradleCommon = "0.3.0" +gradleCommon = "0.4.0" # ksp ksp = "2.0.0-1.0.22" # https://square.github.io/kotlinpoet/ From 96cf616536ff73020ef7b13e75a96b3b9f601994 Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Sun, 9 Jun 2024 13:45:47 +0800 Subject: [PATCH 09/13] Update README and doc --- README.md | 60 ++++++++++------ Writerside/topics/Event.md | 68 +++++++++++++++++-- .../event/message/OneBotGroupMessageEvent.kt | 4 ++ .../message/OneBotPrivateMessageEvent.kt | 2 + .../core/event/request/OneBotRequestEvent.kt | 4 ++ 5 files changed, 112 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 7694f1a..f08cb67 100644 --- a/README.md +++ b/README.md @@ -286,27 +286,45 @@ public class MyApp { ## 事件监听 -目前可监听到的**组件事件**: - -- `OneBotMessageEvent` 消息事件 - - `OneBotGroupMessageEvent` 群消息事件 - - `OneBotNormalGroupMessageEvent` 普通群消息事件 - - `OneBotAnonymousGroupMessageEvent` 匿名群消息事件 - - `OneBotNoticeGroupMessageEvent` 群系统通知消息事件 - - `OneBotPrivateMessageEvent` 私聊消息事件 - - `OneBotFriendMessageEvent` 好友私聊消息事件 - - `OneBotGroupPrivateMessageEvent` 群成员临时会话私聊事件 -- `OneBotMetaEvent` 元事件 - - `OneBotLifecycleEvent` 生命周期事件 - - `OneBotHeartbeatEvent` 心跳事件 -- `OneBotRequestEvent` 请求事件 - - `OneBotFriendRequestEvent` 好友添加请求事件 - - `OneBotGroupRequestEvent` 群添加请求事件 -- `OneBotUnknownEvent` 未知事件 -- `OneBotUnsupportedEvent` 未支持事件 -- `OneBotBotStageEvent` 组件内Bot阶段事件 - - `OneBotBotRegisteredEvent` Bot被注册了事件 - - `OneBotBotStartedEvent` Bot被(首次)启动了事件 +简单列举一下原始事件与可能对应的组件事件之间的关系。 + +| 原始事件 | 组件事件 | +|-----------------------------------------------|----------------------------------------| +| `MetaEvent` | `OneBotMetaEvent` | +| > `LifecycleEvent` | > `OneBotLifecycleEvent` | +| > `HeartbeatEvent` | > `OneBotHeartbeatEvent` | +| `MessageEvent` | `OneBotMessageEvent` | +| > `GroupMessageEvent` | > `OneBotGroupMessageEvent` | +| > `GroupMessageEvent` | > > `OneBotNormalGroupMessageEvent` | +| > `GroupMessageEvent` | > > `OneBotAnonymousGroupMessageEvent` | +| > `GroupMessageEvent` | > > `OneBotNoticeGroupMessageEvent` | +| > `PrivateMessageEvent` | > `OneBotPrivateMessageEvent` | +| > `PrivateMessageEvent` | > > `OneBotFriendMessageEvent` | +| > `PrivateMessageEvent` | > > `OneBotGroupPrivateMessageEvent` | +| `RequestEvent` | `OneBotRequestEvent` | +| > `FriendRequestEvent` | > `OneBotFriendRequestEvent` | +| > `GroupRequestEvent` | > `OneBotGroupRequestEvent` | +| `NoticeEvent` | `OneBotNoticeEvent` | +| > `FriendAddEvent` | > `OneBotFriendAddEvent` | +| > `FriendRecallEvent` | > `OneBotFriendRecallEvent` | +| > `GroupAdminEvent` | > `OneBotGroupAdminEvent` | +| > `GroupBanEvent` | > `OneBotGroupBanEvent` | +| > `GroupIncreaseEvent` 或 `GroupDecreaseEvent` | > `OneBotGroupChangeEvent` | +| > `GroupIncreaseEvent` | > > `OneBotGroupMemberIncreaseEvent` | +| > `GroupDecreaseEvent` | > > `OneBotGroupMemberDecreaseEvent` | +| > `GroupRecallEvent` | > `OneBotGroupRecallEvent` | +| > `GroupUploadEvent` | > `OneBotGroupUploadEvent` | +| > `NotifyEvent` | > `OneBotNotifyEvent` | +| > `NotifyEvent` | > > `OneBotHonorEvent` | +| > `NotifyEvent` | > > `OneBotLuckyKingEvent` | +| > `NotifyEvent` | > > `OneBotPokeEvent` | +| > `NotifyEvent` | > > > `OneBotMemberPokeEvent` | +| > `NotifyEvent` | > > > `OneBotBotSelfPokeEvent` | +| `UnknownEvent` | > `UnknownEvent` | +| 无 | `OneBotBotStageEvent` | +| 无 | > `OneBotBotRegisteredEvent` | +| 无 | > `OneBotBotStartedEvent` | +| 任意未支持事件 | `OneBotUnsupportedEvent` | 其中,可以通过 `OneBotUnsupportedEvent` 和 `OneBotUnknownEvent` 来间接地监听那些尚未提供组件事件类型的原始事件。 diff --git a/Writerside/topics/Event.md b/Writerside/topics/Event.md index 1b5dea0..7ba5ee1 100644 --- a/Writerside/topics/Event.md +++ b/Writerside/topics/Event.md @@ -42,7 +42,7 @@ 一个特殊的事件类型。 它是当遇到无法被上述这些类型所解析时使用的兜底类型, -它不可序列化,除 `time`、`selfId`、`postType` +它不可序列化,除 `time`、`selfId`、`postType` 之外直接提供 `raw` 属性(也就是原始的JSON字符串)。 @@ -53,8 +53,6 @@ 组件实现是基于simbot标准API中定义的事件类型、对上述**原始事件**的包装, 并提供相对应的功能性API实现。 -### 消息事件 - 与消息相关的事件。 @@ -114,7 +112,26 @@ - + +通知相关的事件。 + +好友已添加事件 +好友消息撤回事件 +管理员变动事件 +群禁言事件 +群成员变动事件 +群成员添加事件 +群成员离开事件 +群消息撤回事件 +群文件上传事件 +群荣耀事件、红包人气王事件或戳一戳事件 +群荣耀事件 +红包人气王事件 +戳一戳事件 +戳一戳(普通群成员被戳)事件 +戳一戳(Bot被戳)事件 + + 与OneBot协议本身无关的Bot的阶段事件。 @@ -129,7 +146,6 @@ - ### 未知事件 `OneBotUnknownEvent` @@ -144,3 +160,45 @@ 但是尚未提供对应的**组件事件**实现的事件类型时用来兜底的类型。 这些原始事件类型会被统一装入此事件中。 + +## 事件关系 + +简单列举一下原始事件与可能对应的组件事件之间的关系。 + +| 原始事件 | 组件事件 | +|-----------------------------------------------|----------------------------------------| +| `MetaEvent` | `OneBotMetaEvent` | +| > `LifecycleEvent` | > `OneBotLifecycleEvent` | +| > `HeartbeatEvent` | > `OneBotHeartbeatEvent` | +| `MessageEvent` | `OneBotMessageEvent` | +| > `GroupMessageEvent` | > `OneBotGroupMessageEvent` | +| > `GroupMessageEvent` | > > `OneBotNormalGroupMessageEvent` | +| > `GroupMessageEvent` | > > `OneBotAnonymousGroupMessageEvent` | +| > `GroupMessageEvent` | > > `OneBotNoticeGroupMessageEvent` | +| > `PrivateMessageEvent` | > `OneBotPrivateMessageEvent` | +| > `PrivateMessageEvent` | > > `OneBotFriendMessageEvent` | +| > `PrivateMessageEvent` | > > `OneBotGroupPrivateMessageEvent` | +| `RequestEvent` | `OneBotRequestEvent` | +| > `FriendRequestEvent` | > `OneBotFriendRequestEvent` | +| > `GroupRequestEvent` | > `OneBotGroupRequestEvent` | +| `NoticeEvent` | `OneBotNoticeEvent` | +| > `FriendAddEvent` | > `OneBotFriendAddEvent` | +| > `FriendRecallEvent` | > `OneBotFriendRecallEvent` | +| > `GroupAdminEvent` | > `OneBotGroupAdminEvent` | +| > `GroupBanEvent` | > `OneBotGroupBanEvent` | +| > `GroupIncreaseEvent` 或 `GroupDecreaseEvent` | > `OneBotGroupChangeEvent` | +| > `GroupIncreaseEvent` | > > `OneBotGroupMemberIncreaseEvent` | +| > `GroupDecreaseEvent` | > > `OneBotGroupMemberDecreaseEvent` | +| > `GroupRecallEvent` | > `OneBotGroupRecallEvent` | +| > `GroupUploadEvent` | > `OneBotGroupUploadEvent` | +| > `NotifyEvent` | > `OneBotNotifyEvent` | +| > `NotifyEvent` | > > `OneBotHonorEvent` | +| > `NotifyEvent` | > > `OneBotLuckyKingEvent` | +| > `NotifyEvent` | > > `OneBotPokeEvent` | +| > `NotifyEvent` | > > > `OneBotMemberPokeEvent` | +| > `NotifyEvent` | > > > `OneBotBotSelfPokeEvent` | +| `UnknownEvent` | > `UnknownEvent` | +| 无 | `OneBotBotStageEvent` | +| 无 | > `OneBotBotRegisteredEvent` | +| 无 | > `OneBotBotStartedEvent` | +| 任意未支持事件 | `OneBotUnsupportedEvent` | diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotGroupMessageEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotGroupMessageEvent.kt index a205b8f..97b063d 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotGroupMessageEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotGroupMessageEvent.kt @@ -32,6 +32,10 @@ import love.forte.simbot.suspendrunner.STP * * @see GroupMessageEvent * + * @see OneBotNormalGroupMessageEvent + * @see OneBotAnonymousGroupMessageEvent + * @see OneBotNoticeGroupMessageEvent + * * @author ForteScarlet */ @STP diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotPrivateMessageEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotPrivateMessageEvent.kt index d0a9570..d4e0c6d 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotPrivateMessageEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/message/OneBotPrivateMessageEvent.kt @@ -30,6 +30,8 @@ import love.forte.simbot.suspendrunner.STP * [私聊消息事件](https://github.com/botuniverse/onebot-11/blob/master/event/message.md#私聊消息) * * @see PrivateMessageEvent + * @see OneBotFriendMessageEvent + * @see OneBotGroupPrivateMessageEvent * * @author ForteScarlet */ diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/request/OneBotRequestEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/request/OneBotRequestEvent.kt index cd74d9f..d821a8d 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/request/OneBotRequestEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/request/OneBotRequestEvent.kt @@ -33,6 +33,10 @@ public typealias OBSourceRequestEvent = love.forte.simbot.component.onebot.v11.e * OneBot组件中的 [事件请求][love.forte.simbot.component.onebot.v11.event.request.RequestEvent] * 的组件事件类型。 * + * @see love.forte.simbot.component.onebot.v11.event.request.RequestEvent + * @see OneBotFriendRequestEvent + * @see OneBotGroupRequestEvent + * * @author ForteScarlet */ public interface OneBotRequestEvent : OneBotBotEvent, RequestEvent { From 8450e3425c95b52fca1b52b948ff363a16203f37 Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Sun, 9 Jun 2024 14:05:36 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8E=20GroupRelati?= =?UTF-8?q?on=20=E4=B8=AD=E7=9B=B4=E6=8E=A5=E8=8E=B7=E5=8F=96=20member=20?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simbot/component/onebot/common/OneBot.kt | 2 -- .../onebot/v11/core/bot/OneBotBot.kt | 17 +++++++++++++-- .../v11/core/bot/internal/OneBotBotImpl.kt | 14 ++++++++----- .../message/OneBotPrivateMessageEventImpl.kt | 2 +- .../notice/OneBotGroupAdminEventImpl.kt | 19 ++++++++--------- .../notice/OneBotGroupBanEventImpl.kt | 19 ++++++++--------- .../notice/OneBotGroupChangeEventImpl.kt | 19 +++++++++-------- .../internal/notice/OneBotNotifyEventImpl.kt | 21 +++++++------------ .../src/jvmMain/java/module-info.java | 1 + 9 files changed, 62 insertions(+), 52 deletions(-) diff --git a/simbot-component-onebot-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/common/OneBot.kt b/simbot-component-onebot-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/common/OneBot.kt index fac2f7c..45988ff 100644 --- a/simbot-component-onebot-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/common/OneBot.kt +++ b/simbot-component-onebot-common/src/commonMain/kotlin/love/forte/simbot/component/onebot/common/OneBot.kt @@ -24,5 +24,3 @@ import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI */ @InternalOneBotAPI public object OneBot - -// TODO 一些Opt注解放在这个模块? diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBot.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBot.kt index 6393aa1..beeca5f 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBot.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBot.kt @@ -17,8 +17,8 @@ package love.forte.simbot.component.onebot.v11.core.bot -import io.ktor.client.HttpClient -import io.ktor.http.Url +import io.ktor.client.* +import io.ktor.http.* import kotlinx.coroutines.flow.count import kotlinx.coroutines.flow.firstOrNull import love.forte.simbot.bot.Bot @@ -30,6 +30,7 @@ import love.forte.simbot.common.id.ID import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI import love.forte.simbot.component.onebot.v11.core.actor.OneBotFriend import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup +import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember import love.forte.simbot.component.onebot.v11.core.api.GetLoginInfoApi import love.forte.simbot.component.onebot.v11.core.api.GetLoginInfoResult import love.forte.simbot.suspendrunner.ST @@ -227,4 +228,16 @@ public interface OneBotBotGroupRelation : GroupRelation { @JvmSynthetic override suspend fun groupCount(): Int = groups.asFlow().count() + + /** + * 根据ID查询某个群中的某个成员。 + */ + @ST( + blockingBaseName = "getMember", + blockingSuffix = "", + asyncBaseName = "getMember", + reserveBaseName = "getMember" + ) + public suspend fun member(groupId: ID, memberId: ID): OneBotMember? + } diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt index e2568b1..f8016b1 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt @@ -61,13 +61,11 @@ import love.forte.simbot.common.id.StringID.Companion.ID import love.forte.simbot.component.onebot.v11.core.OneBot11 import love.forte.simbot.component.onebot.v11.core.actor.OneBotFriend import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup +import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember import love.forte.simbot.component.onebot.v11.core.actor.internal.toFriend import love.forte.simbot.component.onebot.v11.core.actor.internal.toGroup -import love.forte.simbot.component.onebot.v11.core.api.GetFriendListApi -import love.forte.simbot.component.onebot.v11.core.api.GetGroupInfoApi -import love.forte.simbot.component.onebot.v11.core.api.GetGroupListApi -import love.forte.simbot.component.onebot.v11.core.api.GetLoginInfoApi -import love.forte.simbot.component.onebot.v11.core.api.GetLoginInfoResult +import love.forte.simbot.component.onebot.v11.core.actor.internal.toMember +import love.forte.simbot.component.onebot.v11.core.api.* import love.forte.simbot.component.onebot.v11.core.bot.OneBotBot import love.forte.simbot.component.onebot.v11.core.bot.OneBotBotConfiguration import love.forte.simbot.component.onebot.v11.core.bot.OneBotBotFriendRelation @@ -576,6 +574,12 @@ internal class OneBotBotImpl( // TODO owner? ) } + + override suspend fun member(groupId: ID, memberId: ID): OneBotMember { + // TODO 如何检测不存在? + return GetGroupMemberInfoApi.create(groupId, userId) + .requestDataBy(this@OneBotBotImpl).toMember(this@OneBotBotImpl) + } } override fun toString(): String = diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/message/OneBotPrivateMessageEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/message/OneBotPrivateMessageEventImpl.kt index 8f45441..9c1e9e6 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/message/OneBotPrivateMessageEventImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/message/OneBotPrivateMessageEventImpl.kt @@ -113,7 +113,7 @@ internal class OneBotGroupPrivateMessageEventImpl( override suspend fun source(): OneBotGroup { // TODO 额,怎么知道群号? // 无法得知群号 - throw UnsupportedOperationException("Don't know how to get the group number from PrivateMessageEvent") + throw UnsupportedOperationException("The way to get the group number from PrivateMessageEvent is unknown.") } override fun toString(): String = diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupAdminEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupAdminEventImpl.kt index 0a4a889..6846538 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupAdminEventImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupAdminEventImpl.kt @@ -21,10 +21,7 @@ import love.forte.simbot.common.id.ID import love.forte.simbot.common.id.StringID.Companion.ID import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember -import love.forte.simbot.component.onebot.v11.core.actor.internal.toMember -import love.forte.simbot.component.onebot.v11.core.api.GetGroupMemberInfoApi -import love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImpl -import love.forte.simbot.component.onebot.v11.core.bot.requestDataBy +import love.forte.simbot.component.onebot.v11.core.bot.OneBotBot import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotGroupAdminEvent import love.forte.simbot.component.onebot.v11.event.notice.GroupAdminEvent @@ -32,7 +29,7 @@ import love.forte.simbot.component.onebot.v11.event.notice.GroupAdminEvent internal class OneBotGroupAdminEventImpl( override val sourceEventRaw: String?, override val sourceEvent: GroupAdminEvent, - override val bot: OneBotBotImpl + override val bot: OneBotBot ) : OneBotGroupAdminEvent { override val id: ID get() = with(sourceEvent) { @@ -40,16 +37,18 @@ internal class OneBotGroupAdminEventImpl( }.ID override suspend fun content(): OneBotMember { - // TODO 换成 groupRelation - return GetGroupMemberInfoApi.create( + return bot.groupRelation.member( groupId = sourceEvent.groupId, - userId = sourceEvent.userId - ).requestDataBy(bot).toMember(bot) + memberId = sourceEvent.userId + ) ?: error( + "Member with id ${sourceEvent.userId} " + + "in Group ${sourceEvent.groupId} is not found" + ) } override suspend fun source(): OneBotGroup { return bot.groupRelation.group(sourceEvent.groupId) - ?: error("Group with id ${sourceEvent.groupId} not found") + ?: error("Group with id ${sourceEvent.groupId} is not found") } override fun toString(): String = diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupBanEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupBanEventImpl.kt index cd2ec5e..5f34368 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupBanEventImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupBanEventImpl.kt @@ -21,10 +21,7 @@ import love.forte.simbot.common.id.ID import love.forte.simbot.common.id.StringID.Companion.ID import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember -import love.forte.simbot.component.onebot.v11.core.actor.internal.toMember -import love.forte.simbot.component.onebot.v11.core.api.GetGroupMemberInfoApi -import love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImpl -import love.forte.simbot.component.onebot.v11.core.bot.requestDataBy +import love.forte.simbot.component.onebot.v11.core.bot.OneBotBot import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotGroupBanEvent import love.forte.simbot.component.onebot.v11.event.notice.GroupBanEvent @@ -37,7 +34,7 @@ import love.forte.simbot.component.onebot.v11.event.notice.GroupBanEvent internal class OneBotGroupBanEventImpl( override val sourceEventRaw: String?, override val sourceEvent: GroupBanEvent, - override val bot: OneBotBotImpl + override val bot: OneBotBot ) : OneBotGroupBanEvent { override val id: ID get() = with(sourceEvent) { @@ -45,16 +42,18 @@ internal class OneBotGroupBanEventImpl( }.ID override suspend fun content(): OneBotMember { - // TODO 换成 groupRelation - return GetGroupMemberInfoApi.create( + return bot.groupRelation.member( groupId = sourceEvent.groupId, - userId = sourceEvent.userId - ).requestDataBy(bot).toMember(bot) + memberId = sourceEvent.userId + ) ?: error( + "Member with id ${sourceEvent.userId} " + + "in Group ${sourceEvent.groupId} is not found" + ) } override suspend fun source(): OneBotGroup { return bot.groupRelation.group(sourceEvent.groupId) - ?: error("Group with id ${sourceEvent.groupId} not found") + ?: error("Group with id ${sourceEvent.groupId} is not found") } override fun toString(): String = diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupChangeEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupChangeEventImpl.kt index 88d7ebd..0168377 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupChangeEventImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotGroupChangeEventImpl.kt @@ -21,10 +21,8 @@ import love.forte.simbot.common.id.ID import love.forte.simbot.common.id.StringID.Companion.ID import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember -import love.forte.simbot.component.onebot.v11.core.actor.internal.toMember -import love.forte.simbot.component.onebot.v11.core.api.GetGroupMemberInfoApi +import love.forte.simbot.component.onebot.v11.core.bot.OneBotBot import love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImpl -import love.forte.simbot.component.onebot.v11.core.bot.requestDataBy import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotGroupChangeEvent import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotGroupMemberDecreaseEvent @@ -45,26 +43,29 @@ internal abstract class OneBotGroupChangeEventImpl : OneBotGroupChangeEvent { override suspend fun content(): OneBotGroup { return bot.groupRelation.group(groupId) - ?: error("Group with id $groupId not found") + ?: error("Group with id $groupId is not found") } } internal class OneBotGroupMemberIncreaseEventImpl( override val sourceEventRaw: String?, override val sourceEvent: GroupIncreaseEvent, - override val bot: OneBotBotImpl + override val bot: OneBotBot ) : OneBotGroupChangeEventImpl(), OneBotGroupMemberIncreaseEvent { override suspend fun member(): OneBotMember { - // TODO 换成 groupRelation - return GetGroupMemberInfoApi.create( + return bot.groupRelation.member( groupId = sourceEvent.groupId, - userId = sourceEvent.userId - ).requestDataBy(bot).toMember(bot) + memberId = sourceEvent.userId + ) ?: error( + "Member with id ${sourceEvent.userId} " + + "in Group ${sourceEvent.groupId} is not found" + ) } override fun toString(): String = eventToString("OneBotGroupMemberIncreaseEvent") } + internal class OneBotGroupMemberDecreaseEventImpl( override val sourceEventRaw: String?, override val sourceEvent: GroupDecreaseEvent, diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotNotifyEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotNotifyEventImpl.kt index 34581d2..c612968 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotNotifyEventImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotNotifyEventImpl.kt @@ -21,16 +21,9 @@ import love.forte.simbot.common.id.ID import love.forte.simbot.common.id.StringID.Companion.ID import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember -import love.forte.simbot.component.onebot.v11.core.actor.internal.toMember -import love.forte.simbot.component.onebot.v11.core.api.GetGroupMemberInfoApi import love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImpl -import love.forte.simbot.component.onebot.v11.core.bot.requestDataBy import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString -import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotBotSelfPokeEvent -import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotHonorEvent -import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotLuckyKingEvent -import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotMemberPokeEvent -import love.forte.simbot.component.onebot.v11.core.event.notice.OneBotNotifyEvent +import love.forte.simbot.component.onebot.v11.core.event.notice.* import love.forte.simbot.component.onebot.v11.event.notice.NotifyEvent @@ -50,15 +43,17 @@ internal abstract class OneBotNotifyEventImpl( override suspend fun source(): OneBotGroup { return bot.groupRelation.group(groupId) - ?: error("Group with id $groupId not found") + ?: error("Group with id $groupId is not found") } override suspend fun content(): OneBotMember { - // TODO 换成 groupRelation - return GetGroupMemberInfoApi.create( + return bot.groupRelation.member( groupId = sourceEvent.groupId, - userId = sourceEvent.userId - ).requestDataBy(bot).toMember(bot) + memberId = sourceEvent.userId + ) ?: error( + "Member with id ${sourceEvent.userId} " + + "in Group ${sourceEvent.groupId} is not found" + ) } } diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmMain/java/module-info.java b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmMain/java/module-info.java index e79d1fa..b30846b 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmMain/java/module-info.java +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmMain/java/module-info.java @@ -37,6 +37,7 @@ exports love.forte.simbot.component.onebot.v11.core.event.meta; exports love.forte.simbot.component.onebot.v11.core.event.notice; exports love.forte.simbot.component.onebot.v11.core.event.request; + exports love.forte.simbot.component.onebot.v11.core.event.stage; exports love.forte.simbot.component.onebot.v11.core.utils; provides ComponentFactoryProvider with OneBot11ComponentFactoryProvider; From 301c9a1351c1a52b904661aa97062620e8712bed Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Sun, 9 Jun 2024 14:36:39 +0800 Subject: [PATCH 11/13] =?UTF-8?q?OneBotRequestEvent=20=E7=9A=84=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E4=B8=8E=E6=8B=92=E7=BB=9D=E6=94=AF=E6=8C=81=E5=8F=AF?= =?UTF-8?q?=E9=80=89=E7=9A=84=E9=A2=9D=E5=A4=96=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/OneBotRequestEventImpl.kt | 56 +++++++++-- .../core/event/request/OneBotRequestEvent.kt | 94 +++++++++++++++++++ 2 files changed, 140 insertions(+), 10 deletions(-) diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/request/OneBotRequestEventImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/request/OneBotRequestEventImpl.kt index 843f71b..8283b4e 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/request/OneBotRequestEventImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/request/OneBotRequestEventImpl.kt @@ -17,6 +17,8 @@ package love.forte.simbot.component.onebot.v11.core.event.internal.request +import love.forte.simbot.ability.AcceptOption +import love.forte.simbot.ability.RejectOption import love.forte.simbot.common.id.ID import love.forte.simbot.common.id.UUID import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup @@ -29,9 +31,7 @@ import love.forte.simbot.component.onebot.v11.core.bot.OneBotBot import love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImpl import love.forte.simbot.component.onebot.v11.core.bot.requestDataBy import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString -import love.forte.simbot.component.onebot.v11.core.event.request.OneBotFriendRequestEvent -import love.forte.simbot.component.onebot.v11.core.event.request.OneBotGroupRequestEvent -import love.forte.simbot.component.onebot.v11.core.event.request.OneBotRequestEvent +import love.forte.simbot.component.onebot.v11.core.event.request.* import love.forte.simbot.component.onebot.v11.event.request.FriendRequestEvent import love.forte.simbot.component.onebot.v11.event.request.GroupRequestEvent @@ -40,14 +40,23 @@ internal abstract class OneBotRequestEventImpl : OneBotRequestEvent { override val id: ID = UUID.random() override suspend fun accept() { - doSetRequest(true) + doAccept(emptyArray()) + } + + override suspend fun accept(vararg options: AcceptOption) { + doAccept(options) } override suspend fun reject() { - doSetRequest(false) + doReject(emptyArray()) } - protected abstract suspend fun doSetRequest(approve: Boolean) + override suspend fun reject(vararg options: RejectOption) { + doReject(options) + } + + protected abstract suspend fun doAccept(options: Array) + protected abstract suspend fun doReject(options: Array) } internal class OneBotFriendRequestEventImpl( @@ -55,10 +64,23 @@ internal class OneBotFriendRequestEventImpl( override val sourceEvent: FriendRequestEvent, override val bot: OneBotBot, ) : OneBotRequestEventImpl(), OneBotFriendRequestEvent { - override suspend fun doSetRequest(approve: Boolean) { + override suspend fun doAccept(options: Array) { + val remark: String? = ( + options.firstOrNull { it is OneBotFriendRequestAcceptOption.Remark } + as? OneBotFriendRequestAcceptOption.Remark + )?.remark + SetFriendAddRequestApi.create( flag = sourceEvent.flag, - approve = approve, + approve = true, + remark = remark + ).requestDataBy(bot) + } + + override suspend fun doReject(options: Array) { + SetFriendAddRequestApi.create( + flag = sourceEvent.flag, + approve = false, ).requestDataBy(bot) } @@ -71,11 +93,25 @@ internal class OneBotGroupRequestEventImpl( override val sourceEvent: GroupRequestEvent, override val bot: OneBotBotImpl, ) : OneBotRequestEventImpl(), OneBotGroupRequestEvent { - override suspend fun doSetRequest(approve: Boolean) { + override suspend fun doAccept(options: Array) { + SetGroupAddRequestApi.create( + flag = sourceEvent.flag, + subType = sourceEvent.subType, + approve = true + ).requestDataBy(bot) + } + + override suspend fun doReject(options: Array) { + val reason = ( + options.firstOrNull { it is OneBotGroupRequestRejectOption.Reason } + as? OneBotGroupRequestRejectOption.Reason + )?.reason + SetGroupAddRequestApi.create( flag = sourceEvent.flag, subType = sourceEvent.subType, - approve = approve + approve = false, + reason = reason ).requestDataBy(bot) } diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/request/OneBotRequestEvent.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/request/OneBotRequestEvent.kt index d821a8d..7ccb58f 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/request/OneBotRequestEvent.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/request/OneBotRequestEvent.kt @@ -17,6 +17,8 @@ package love.forte.simbot.component.onebot.v11.core.event.request +import love.forte.simbot.ability.AcceptOption +import love.forte.simbot.ability.RejectOption import love.forte.simbot.common.id.LongID import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup import love.forte.simbot.component.onebot.v11.core.actor.OneBotStranger @@ -26,6 +28,8 @@ import love.forte.simbot.component.onebot.v11.event.request.GroupRequestEvent import love.forte.simbot.event.OrganizationJoinRequestEvent import love.forte.simbot.event.RequestEvent import love.forte.simbot.suspendrunner.STP +import kotlin.jvm.JvmStatic +import kotlin.jvm.JvmSynthetic public typealias OBSourceRequestEvent = love.forte.simbot.component.onebot.v11.event.request.RequestEvent @@ -41,6 +45,30 @@ public typealias OBSourceRequestEvent = love.forte.simbot.component.onebot.v11.e */ public interface OneBotRequestEvent : OneBotBotEvent, RequestEvent { override val sourceEvent: OBSourceRequestEvent + + /** + * 接受请求 + */ + @JvmSynthetic + override suspend fun accept() + + /** + * 接受请求 + */ + @JvmSynthetic + override suspend fun accept(vararg options: AcceptOption) + + /** + * 拒绝请求 + */ + @JvmSynthetic + override suspend fun reject() + + /** + * 拒绝请求 + */ + @JvmSynthetic + override suspend fun reject(vararg options: RejectOption) } /** @@ -79,8 +107,41 @@ public interface OneBotFriendRequestEvent : OneBotRequestEvent { */ public val requesterId: LongID get() = sourceEvent.userId + + /** + * 接受申请。 + * + * @param options 好友申请中可使用的额外属性, + * 支持 [OneBotFriendRequestAcceptOption] 下的类型。 + * + * @see OneBotFriendRequestAcceptOption + */ + @JvmSynthetic + override suspend fun accept(vararg options: AcceptOption) +} + + +/** + * 可使用于 [OneBotFriendRequestEvent.accept] 中的额外属性 [AcceptOption] 实现。 + */ +public sealed class OneBotFriendRequestAcceptOption : AcceptOption { + /** + * 接受申请后为其设置一个备注 + */ + public data class Remark(val remark: String) : OneBotFriendRequestAcceptOption() + + + public companion object { + /** + * 接受申请后为其设置一个备注 + * @see Remark + */ + @JvmStatic + public fun remark(remark: String): Remark = Remark(remark) + } } + /** * 群添加申请事件 * @see GroupRequestEvent @@ -135,4 +196,37 @@ public interface OneBotGroupRequestEvent : OneBotRequestEvent, OrganizationJoinR */ @STP override suspend fun requester(): OneBotStranger + + /** + * 拒绝申请。 + * + * @param options 拒绝时可提供的额外选项。 + * 支持使用 [OneBotGroupRequestRejectOption] 下的类型。 + * + * @see OneBotGroupRequestRejectOption + */ + @JvmSynthetic + override suspend fun reject(vararg options: RejectOption) + +} + + +/** + * 可使用于 [OneBotGroupRequestEvent.reject] 中的额外属性 [RejectOption] 实现。 + */ +public sealed class OneBotGroupRequestRejectOption : RejectOption { + /** + * 拒绝的理由 + */ + public data class Reason(val reason: String) : OneBotGroupRequestRejectOption() + + public companion object { + /** + * 拒绝的理由 + * + * @see Reason + */ + @JvmStatic + public fun reason(reason: String): Reason = Reason(reason) + } } From 26048228f88b4473fb5c83296635491a3a626b9d Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Sun, 9 Jun 2024 14:59:50 +0800 Subject: [PATCH 12/13] update README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f08cb67..306d6bf 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ Simple Robot OneBot 组件是一个将 ## 快速开始 +> [!warning] > 手册施工完成之前,此处临时提供快速开始。手册施工完成后会删除。 > [!note] @@ -64,10 +65,10 @@ Simple Robot OneBot 组件是一个将 ### Ktor 客户端引擎 -OneBot组件默认使用 [Ktor](https://ktor.io/) +首先,OneBot组件使用 [Ktor](https://ktor.io/) 作为HTTP客户端与WS客户端,但是默认情况下依赖中不会有任何具体的引擎实现。 -你需要根据你的使用平台前往 [Ktor client Engines](https://ktor.io/docs/client-engines.html#limitations) +因此你需要根据你的使用平台前往 [Ktor client Engines](https://ktor.io/docs/client-engines.html#limitations) 选择一个合适的引擎使用。 > [!tip] From e2976995dbd0cb2487bd39d84523ed889d7b825b Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Sun, 9 Jun 2024 15:01:10 +0800 Subject: [PATCH 13/13] release: v0.1.0 --- .changelog/v0.0.1.md | 53 ----------------------------- .changelog/v0.0.2.md | 52 ---------------------------- .changelog/v0.0.4.md | 7 ---- .changelog/{v0.0.3.md => v0.1.0.md} | 5 ++- buildSrc/src/main/kotlin/P.kt | 2 +- 5 files changed, 5 insertions(+), 114 deletions(-) delete mode 100644 .changelog/v0.0.1.md delete mode 100644 .changelog/v0.0.2.md delete mode 100644 .changelog/v0.0.4.md rename .changelog/{v0.0.3.md => v0.1.0.md} (61%) diff --git a/.changelog/v0.0.1.md b/.changelog/v0.0.1.md deleted file mode 100644 index 357764b..0000000 --- a/.changelog/v0.0.1.md +++ /dev/null @@ -1,53 +0,0 @@ -> 对应核心版本: [**v4.0.0-RC2**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.0.0-RC2) - -> [!warning] -> 当前版本处于 `0.x` 的早期版本,可能存在各种问题。 - -我们欢迎并期望着您的的[反馈](https://github.com/simple-robot/simbot-component-onebot/issues) -或[协助](https://github.com/simple-robot/simbot-component-onebot/pulls), -感谢您的贡献与支持! - -也欢迎您为我们献上一颗 `star`,这是对我们最大的鼓励与认可! - -## 事件监听 - -目前可监听到的**组件事件**: - -- `OneBotMessageEvent` - - `OneBotGroupMessageEvent` - - `OneBotNormalGroupMessageEvent` - - `OneBotAnonymousGroupMessageEvent` - - `OneBotNoticeGroupMessageEvent` - - `OneBotPrivateMessageEvent` - - `OneBotFriendMessageEvent` - - `OneBotGroupPrivateMessageEvent` -- `OneBotUnknownEvent` -- `OneBotUnsupportedEvent` - -其中,可以通过 `OneBotUnsupportedEvent` 和 `OneBotUnknownEvent` -来间接地监听那些尚未提供组件事件类型的原始事件。 - -OB11协议中的事件类型均有实现。 - -## 已知隐患 - -**1: 根据来源的不同,部分 actor 的实现中部分属性或API可能无法获取到值。** - -例如在群成员的临时会话私聊事件 `OneBotGroupPrivateMessageEvent` 中, -无法根据事件信息获取到这个成员所属的群,因此 `event.source()` 会抛出异常。 - -**2: API的反序列化如果存在缺失字段则可能没有用于填充的默认值** - -API的响应结果如果存在部分属性的缺失,可能会出现异常。 - -**3: 查询相关的API无法明确‘未找到’** - -协议中没有约定当一个目标‘未找到’的时候的结果(例如查询id为 `123` 的群成员), -不明确到底是响应了 404 还是有某个 `retcode`。 - -因此目前当“未找到”的情况出现时, -会抛出API的响应异常而不是得到预期的 `null`。 - -**4: 暂无文档和手册** - -字面意思。还没来得及写,但是有[API文档](https://docs.simbot.forte.love)。 diff --git a/.changelog/v0.0.2.md b/.changelog/v0.0.2.md deleted file mode 100644 index 8505fc9..0000000 --- a/.changelog/v0.0.2.md +++ /dev/null @@ -1,52 +0,0 @@ -> 对应核心版本: [**v4.0.0-RC2**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.0.0-RC2) - -> [!warning] -> 当前版本处于 `0.x` 的早期版本,可能存在各种问题。 - -我们欢迎并期望着您的的[反馈](https://github.com/simple-robot/simbot-component-onebot/issues)或[协助](https://github.com/simple-robot/simbot-component-onebot/pulls), -感谢您的贡献与支持! - -也欢迎您为我们献上一颗 `star`,这是对我们最大的鼓励与认可! - -## 事件监听 - -目前可监听到的**组件事件**: - -- `OneBotMessageEvent` - - `OneBotGroupMessageEvent` - - `OneBotNormalGroupMessageEvent` - - `OneBotAnonymousGroupMessageEvent` - - `OneBotNoticeGroupMessageEvent` - - `OneBotPrivateMessageEvent` - - `OneBotFriendMessageEvent` - - `OneBotGroupPrivateMessageEvent` -- `OneBotUnknownEvent` -- `OneBotUnsupportedEvent` - -其中,可以通过 `OneBotUnsupportedEvent` 和 `OneBotUnknownEvent` -来间接地监听那些尚未提供组件事件类型的原始事件。 - -OB11协议中的事件类型均有实现。 - -## 已知隐患 - -**1: 根据来源的不同,部分 actor 的实现中部分属性或API可能无法获取到值。** - -例如在群成员的临时会话私聊事件 `OneBotGroupPrivateMessageEvent` 中, -无法根据事件信息获取到这个成员所属的群,因此 `event.source()` 会抛出异常。 - -**2: API的反序列化如果存在缺失字段则可能没有用于填充的默认值** - -API的响应结果如果存在部分属性的缺失,可能会出现异常。 - -**3: 查询相关的API无法明确‘未找到’** - -协议中没有约定当一个目标‘未找到’的时候的结果(例如查询id为 `123` 的群成员), -不明确到底是响应了 404 还是有某个 `retcode`。 - -因此目前当“未找到”的情况出现时, -会抛出API的响应异常而不是得到预期的 `null`。 - -**4: 暂无文档和手册** - -字面意思。还没来得及写,但是有[API文档](https://docs.simbot.forte.love)。 diff --git a/.changelog/v0.0.4.md b/.changelog/v0.0.4.md deleted file mode 100644 index fabebef..0000000 --- a/.changelog/v0.0.4.md +++ /dev/null @@ -1,7 +0,0 @@ -> 对应核心版本: [**v4.0.0-RC2**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.0.0-RC2) - - -我们欢迎并期望着您的的[反馈](https://github.com/simple-robot/simbot-component-onebot/issues)或[协助](https://github.com/simple-robot/simbot-component-onebot/pulls), -感谢您的贡献与支持! - -也欢迎您为我们献上一颗 `star`,这是对我们最大的鼓励与认可! diff --git a/.changelog/v0.0.3.md b/.changelog/v0.1.0.md similarity index 61% rename from .changelog/v0.0.3.md rename to .changelog/v0.1.0.md index fabebef..7d036cb 100644 --- a/.changelog/v0.0.3.md +++ b/.changelog/v0.1.0.md @@ -1,7 +1,10 @@ -> 对应核心版本: [**v4.0.0-RC2**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.0.0-RC2) +> 对应核心版本: [**v4.0.0-RC3**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.0.0-RC3) 我们欢迎并期望着您的的[反馈](https://github.com/simple-robot/simbot-component-onebot/issues)或[协助](https://github.com/simple-robot/simbot-component-onebot/pulls), 感谢您的贡献与支持! 也欢迎您为我们献上一颗 `star`,这是对我们最大的鼓励与认可! + +> [!note] +> 目前组件事件类型已经基本全部定义、封装完毕。 diff --git a/buildSrc/src/main/kotlin/P.kt b/buildSrc/src/main/kotlin/P.kt index 60153e6..3000091 100644 --- a/buildSrc/src/main/kotlin/P.kt +++ b/buildSrc/src/main/kotlin/P.kt @@ -41,7 +41,7 @@ object P { override val homepage: String get() = HOMEPAGE - private val baseVersion = v(0, 0, 4) + private val baseVersion = v(0, 1, 0) val snapshotVersion = baseVersion - Version.SNAPSHOT override val version = if (isSnapshot()) snapshotVersion else baseVersion