Skip to content

Commit dd6c44d

Browse files
authored
Merge pull request #100 from simple-robot/dev/main
Release: v1.4.0
2 parents d2da4a5 + 2475e44 commit dd6c44d

File tree

8 files changed

+100
-38
lines changed

8 files changed

+100
-38
lines changed

.changelog/v1.4.0.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
> 对应核心版本: [**v4.6.0**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.6.0)
2+
3+
4+
我们欢迎并期望着您的的[反馈](https://github.com/simple-robot/simbot-component-onebot/issues)[协助](https://github.com/simple-robot/simbot-component-onebot/pulls)
5+
感谢您的贡献与支持!
6+
7+
也欢迎您为我们献上一颗 `star`,这是对我们最大的鼓励与认可!

buildSrc/src/main/kotlin/P.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ object P {
3737
override val description: String get() = DESCRIPTION
3838
override val homepage: String get() = HOMEPAGE
3939

40-
const val VERSION = "1.3.0"
41-
const val NEXT_VERSION = "1.3.1"
40+
const val VERSION = "1.4.0"
41+
const val NEXT_VERSION = "1.4.1"
4242

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

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

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,7 +2320,7 @@ public abstract interface class love/forte/simbot/component/onebot/v11/core/even
23202320
public abstract fun getSourceEvent ()Llove/forte/simbot/component/onebot/v11/event/meta/RawMetaEvent;
23212321
}
23222322

2323-
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotBotSelfPokeEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotPokeEvent {
2323+
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotBotSelfPokeEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupNotifyEvent, love/forte/simbot/component/onebot/v11/core/event/notice/OneBotPokeEvent {
23242324
}
23252325

23262326
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotFriendAddEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNoticeEvent {
@@ -2448,6 +2448,23 @@ public abstract interface class love/forte/simbot/component/onebot/v11/core/even
24482448
public abstract synthetic fun member (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
24492449
}
24502450

2451+
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupNotifyEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent, love/forte/simbot/event/MemberEvent {
2452+
public abstract synthetic fun content (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
2453+
public synthetic fun getContent ()Ljava/lang/Object;
2454+
public fun getContent ()Llove/forte/simbot/component/onebot/v11/core/actor/OneBotMember;
2455+
public synthetic fun getContent ()Llove/forte/simbot/definition/Actor;
2456+
public synthetic fun getContent ()Llove/forte/simbot/definition/Member;
2457+
public fun getContentAsync ()Ljava/util/concurrent/CompletableFuture;
2458+
public fun getContentReserve ()Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
2459+
public abstract fun getGroupId ()Llove/forte/simbot/common/id/LongID;
2460+
public synthetic fun getSource ()Ljava/lang/Object;
2461+
public fun getSource ()Llove/forte/simbot/component/onebot/v11/core/actor/OneBotGroup;
2462+
public synthetic fun getSource ()Llove/forte/simbot/definition/Organization;
2463+
public fun getSourceAsync ()Ljava/util/concurrent/CompletableFuture;
2464+
public fun getSourceReserve ()Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
2465+
public abstract synthetic fun source (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
2466+
}
2467+
24512468
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupRecallEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNoticeEvent, love/forte/simbot/event/ChatGroupEvent {
24522469
public abstract synthetic fun content (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
24532470
public fun getAuthorId ()Llove/forte/simbot/common/id/LongID;
@@ -2481,45 +2498,35 @@ public abstract interface class love/forte/simbot/component/onebot/v11/core/even
24812498
public fun getUserId ()Llove/forte/simbot/common/id/LongID;
24822499
}
24832500

2484-
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotHonorEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent {
2501+
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotHonorEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupNotifyEvent {
24852502
public fun getHonorType ()Ljava/lang/String;
24862503
}
24872504

2488-
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotLuckyKingEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent {
2505+
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotLuckyKingEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupNotifyEvent {
24892506
public fun getTargetId ()Llove/forte/simbot/common/id/LongID;
24902507
}
24912508

2492-
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotMemberPokeEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotPokeEvent {
2509+
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotMemberPokeEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotGroupNotifyEvent, love/forte/simbot/component/onebot/v11/core/event/notice/OneBotPokeEvent {
24932510
}
24942511

24952512
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNoticeEvent : love/forte/simbot/component/onebot/v11/core/event/OneBotBotEvent {
24962513
public abstract fun getSourceEvent ()Llove/forte/simbot/component/onebot/v11/event/notice/RawNoticeEvent;
24972514
}
24982515

2499-
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNoticeEvent, love/forte/simbot/event/MemberEvent {
2500-
public abstract synthetic fun content (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
2501-
public synthetic fun getContent ()Ljava/lang/Object;
2502-
public fun getContent ()Llove/forte/simbot/component/onebot/v11/core/actor/OneBotMember;
2503-
public synthetic fun getContent ()Llove/forte/simbot/definition/Actor;
2504-
public synthetic fun getContent ()Llove/forte/simbot/definition/Member;
2505-
public fun getContentAsync ()Ljava/util/concurrent/CompletableFuture;
2506-
public fun getContentReserve ()Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
2516+
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNoticeEvent {
25072517
public fun getGroupId ()Llove/forte/simbot/common/id/LongID;
25082518
public fun getHonorType ()Ljava/lang/String;
2509-
public synthetic fun getSource ()Ljava/lang/Object;
2510-
public fun getSource ()Llove/forte/simbot/component/onebot/v11/core/actor/OneBotGroup;
2511-
public synthetic fun getSource ()Llove/forte/simbot/definition/Organization;
2512-
public fun getSourceAsync ()Ljava/util/concurrent/CompletableFuture;
25132519
public abstract fun getSourceEvent ()Llove/forte/simbot/component/onebot/v11/event/notice/RawNotifyEvent;
2514-
public fun getSourceReserve ()Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
25152520
public fun getUserId ()Llove/forte/simbot/common/id/LongID;
2516-
public abstract synthetic fun source (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
25172521
}
25182522

25192523
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotPokeEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent {
25202524
public fun getTargetId ()Llove/forte/simbot/common/id/LongID;
25212525
}
25222526

2527+
public abstract interface class love/forte/simbot/component/onebot/v11/core/event/notice/OneBotPrivatePokeEvent : love/forte/simbot/component/onebot/v11/core/event/notice/OneBotPokeEvent {
2528+
}
2529+
25232530
public abstract class love/forte/simbot/component/onebot/v11/core/event/request/OneBotFriendRequestAcceptOption : love/forte/simbot/ability/AcceptOption {
25242531
public static final field Companion Llove/forte/simbot/component/onebot/v11/core/event/request/OneBotFriendRequestAcceptOption$Companion;
25252532
public static final fun remark (Ljava/lang/String;)Llove/forte/simbot/component/onebot/v11/core/event/request/OneBotFriendRequestAcceptOption$Remark;

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import kotlin.jvm.JvmInline
2929
/**
3030
* 可以用于执行 [OneBotApi] 的执行器接口描述。
3131
*
32+
* _应仅由内部实现,第三方实现不保证稳定。_
33+
*
3234
* @since 1.1.0
3335
*
3436
* @author ForteScarlet
@@ -41,7 +43,6 @@ public interface OneBotApiExecutable {
4143
*
4244
* @since 1.1.0
4345
*
44-
* @throws OneBotApiResponseNotSuccessException 如果响应状态码不是 2xx (参考 [HttpStatusCode.isSuccess])
4546
* @see OneBotApi.request
4647
*/
4748
@ST
@@ -90,11 +91,14 @@ public interface OneBotApiExecutable {
9091
}
9192

9293
/**
93-
* 在 [OneBotApiExecutable] 的基础上提供更多作用域API。
94+
* 在 [OneBotApiExecutable] 的基础上提供更多作用域API,
95+
* 允许在 Kotlin 中使用DSL的风格请求API。
9496
*
9597
* @since 1.1.0
9698
*
9799
* @see OneBotApiExecutable
100+
* @see withExecutableScope
101+
* @see inExecutableScope
98102
*/
99103
@JvmInline
100104
public value class OneBotApiExecutableScope(private val executable: OneBotApiExecutable) {

simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ internal fun OneBotBotImpl.resolveRawEventToEvent(raw: String, event: OBRawEvent
764764
RawNotifyEvent.SUB_TYPE_HONOR -> OneBotHonorEventImpl(raw, event, bot)
765765
RawNotifyEvent.SUB_TYPE_LUCKY_KING -> OneBotLuckyKingEventImpl(raw, event, bot)
766766
RawNotifyEvent.SUB_TYPE_POKE -> when {
767+
event.groupId == null -> OneBotPrivatePokeEventImpl(raw, event, bot)
767768
event.selfId.value == event.targetId?.value ->
768769
OneBotBotSelfPokeEventImpl(raw, event, bot)
769770

simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/notice/OneBotNotifyEventImpl.kt

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package love.forte.simbot.component.onebot.v11.core.event.internal.notice
1919

2020
import love.forte.simbot.common.id.ID
21+
import love.forte.simbot.common.id.LongID
2122
import love.forte.simbot.common.id.StringID.Companion.ID
2223
import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup
2324
import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember
@@ -40,15 +41,26 @@ internal abstract class OneBotNotifyEventImpl(
4041
get() = with(sourceEvent) {
4142
"$postType-$noticeType-$subType-$groupId-$userId-$time"
4243
}.ID
44+
}
4345

46+
/**
47+
*
48+
* @author ForteScarlet
49+
*/
50+
internal abstract class OneBotGroupNotifyEventImpl(
51+
override val sourceEventRaw: String?,
52+
override val groupId: LongID,
53+
override val sourceEvent: RawNotifyEvent,
54+
override val bot: OneBotBotImpl
55+
) : OneBotGroupNotifyEvent, OneBotNotifyEventImpl(sourceEventRaw, sourceEvent, bot) {
4456
override suspend fun source(): OneBotGroup {
4557
return bot.groupRelation.group(groupId)
4658
?: error("Group with id $groupId is not found")
4759
}
4860

4961
override suspend fun content(): OneBotMember {
5062
return bot.groupRelation.member(
51-
groupId = sourceEvent.groupId,
63+
groupId = groupId,
5264
memberId = sourceEvent.userId
5365
) ?: error(
5466
"Member with id ${sourceEvent.userId} " +
@@ -61,7 +73,7 @@ internal class OneBotHonorEventImpl(
6173
sourceEventRaw: String?,
6274
sourceEvent: RawNotifyEvent,
6375
bot: OneBotBotImpl
64-
) : OneBotNotifyEventImpl(sourceEventRaw, sourceEvent, bot),
76+
) : OneBotGroupNotifyEventImpl(sourceEventRaw, sourceEvent.groupId!!, sourceEvent, bot),
6577
OneBotHonorEvent {
6678
override fun toString(): String =
6779
eventToString("OneBotHonorEvent")
@@ -71,7 +83,7 @@ internal class OneBotLuckyKingEventImpl(
7183
sourceEventRaw: String?,
7284
sourceEvent: RawNotifyEvent,
7385
bot: OneBotBotImpl
74-
) : OneBotNotifyEventImpl(sourceEventRaw, sourceEvent, bot),
86+
) : OneBotGroupNotifyEventImpl(sourceEventRaw, sourceEvent.groupId!!, sourceEvent, bot),
7587
OneBotLuckyKingEvent {
7688
override fun toString(): String =
7789
eventToString("OneBotLuckyKingEvent")
@@ -81,7 +93,7 @@ internal class OneBotMemberPokeEventImpl(
8193
sourceEventRaw: String?,
8294
sourceEvent: RawNotifyEvent,
8395
bot: OneBotBotImpl
84-
) : OneBotNotifyEventImpl(sourceEventRaw, sourceEvent, bot),
96+
) : OneBotGroupNotifyEventImpl(sourceEventRaw, sourceEvent.groupId!!, sourceEvent, bot),
8597
OneBotMemberPokeEvent {
8698
override fun toString(): String =
8799
eventToString("OneBotMemberPokeEvent")
@@ -91,8 +103,18 @@ internal class OneBotBotSelfPokeEventImpl(
91103
sourceEventRaw: String?,
92104
sourceEvent: RawNotifyEvent,
93105
bot: OneBotBotImpl
94-
) : OneBotNotifyEventImpl(sourceEventRaw, sourceEvent, bot),
106+
) : OneBotGroupNotifyEventImpl(sourceEventRaw, sourceEvent.groupId!!, sourceEvent, bot),
95107
OneBotBotSelfPokeEvent {
96108
override fun toString(): String =
97109
eventToString("OneBotBotSelfPokeEvent")
98110
}
111+
112+
internal class OneBotPrivatePokeEventImpl(
113+
sourceEventRaw: String?,
114+
sourceEvent: RawNotifyEvent,
115+
bot: OneBotBotImpl
116+
) : OneBotNotifyEventImpl(sourceEventRaw, sourceEvent, bot),
117+
OneBotPrivatePokeEvent {
118+
override fun toString(): String =
119+
eventToString("OneBotPrivatePokeEvent")
120+
}

simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/event/notice/OneBotNotifyEvent.kt

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import love.forte.simbot.suspendrunner.STP
3434
* @see OneBotPokeEvent
3535
* @author ForteScarlet
3636
*/
37-
public interface OneBotNotifyEvent : OneBotNoticeEvent, MemberEvent {
37+
public interface OneBotNotifyEvent : OneBotNoticeEvent {
3838
override val sourceEvent: RawNotifyEvent
3939

4040
/**
@@ -46,9 +46,9 @@ public interface OneBotNotifyEvent : OneBotNoticeEvent, MemberEvent {
4646
get() = sourceEvent.honorType
4747

4848
/**
49-
* 群号
49+
* 群号。如果是代表私聊相关的事件(例如私聊戳一戳)则为 `null`。
5050
*/
51-
public val groupId: LongID
51+
public val groupId: LongID?
5252
get() = sourceEvent.groupId
5353

5454
/**
@@ -57,6 +57,21 @@ public interface OneBotNotifyEvent : OneBotNoticeEvent, MemberEvent {
5757
public val userId: LongID
5858
get() = sourceEvent.userId
5959

60+
}
61+
62+
/**
63+
* 群成员荣誉变更事件、红包人气王事件或戳一戳事件。
64+
*
65+
* @see OneBotNotifyEvent
66+
*
67+
* @since 1.4.0
68+
*/
69+
public interface OneBotGroupNotifyEvent : OneBotNotifyEvent, MemberEvent {
70+
/**
71+
* 事件发送的群号
72+
*/
73+
override val groupId: LongID
74+
6075
/**
6176
* 群
6277
*
@@ -72,13 +87,12 @@ public interface OneBotNotifyEvent : OneBotNoticeEvent, MemberEvent {
7287
*/
7388
@STP
7489
override suspend fun content(): OneBotMember
75-
7690
}
7791

7892
/**
7993
* 群成员荣誉变更事件
8094
*/
81-
public interface OneBotHonorEvent : OneBotNotifyEvent {
95+
public interface OneBotHonorEvent : OneBotGroupNotifyEvent {
8296
/**
8397
* 荣誉类型.
8498
*
@@ -91,7 +105,7 @@ public interface OneBotHonorEvent : OneBotNotifyEvent {
91105
/**
92106
* 群红包运气王事件
93107
*/
94-
public interface OneBotLuckyKingEvent : OneBotNotifyEvent {
108+
public interface OneBotLuckyKingEvent : OneBotGroupNotifyEvent {
95109
/**
96110
* 人气王用户ID
97111
*/
@@ -100,7 +114,7 @@ public interface OneBotLuckyKingEvent : OneBotNotifyEvent {
100114
}
101115

102116
/**
103-
* 群戳一戳事件
117+
* 戳一戳事件
104118
*
105119
* @see OneBotMemberPokeEvent
106120
* @see OneBotBotSelfPokeEvent
@@ -116,9 +130,16 @@ public interface OneBotPokeEvent : OneBotNotifyEvent {
116130
/**
117131
* 群里Bot以外的群成员被戳一戳事件
118132
*/
119-
public interface OneBotMemberPokeEvent : OneBotPokeEvent
133+
public interface OneBotMemberPokeEvent : OneBotPokeEvent, OneBotGroupNotifyEvent
120134

121135
/**
122136
* 群里Bot被戳一戳事件,即 [targetId] == [selfId]。
123137
*/
124-
public interface OneBotBotSelfPokeEvent : OneBotPokeEvent
138+
public interface OneBotBotSelfPokeEvent : OneBotPokeEvent, OneBotGroupNotifyEvent
139+
140+
/**
141+
* 私聊里的戳一戳事件,[groupId] == `null`。
142+
*
143+
* @since 1.4.0
144+
*/
145+
public interface OneBotPrivatePokeEvent : OneBotPokeEvent

simbot-component-onebot-v11/simbot-component-onebot-v11-event/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/event/notice/RawNotifyEvent.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import love.forte.simbot.component.onebot.v11.event.ExpectEventType
3333
*
3434
* @property subType 提示类型。
3535
* 可能的值: `honor`, `lucky_king`, `poke`
36-
* @property groupId 群号。
36+
* @property groupId 群号。如果是代表私聊相关的事件(例如私聊戳一戳)则为 `null`。
3737
* @property honorType 荣誉类型,分别表示龙王、群聊之火、快乐源泉。
3838
* 可能的值: `talkative`、`performer`、`emotion`。
3939
* 当 [subType] 为 `honor` 时有值。
@@ -57,7 +57,7 @@ public data class RawNotifyEvent(
5757
@SerialName("sub_type")
5858
public val subType: String,
5959
@SerialName("group_id")
60-
public val groupId: LongID,
60+
public val groupId: LongID? = null,
6161
@SerialName("honor_type")
6262
public val honorType: String? = null,
6363
@SerialName("user_id")

0 commit comments

Comments
 (0)