diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 43188700..834671db 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -98,4 +98,5 @@ jobs: title: 'update: mirai-api-http ${{ steps.tag.outputs.tag }}' branch: create-pull-request/mah-update-version delete-branch: true + path: ./mirai-repo-mirror base: master diff --git a/CHANGELOG.md b/CHANGELOG.md index b8457eec..7e5ea45a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,12 @@ # 更新日志 -## \[2.9.0\] - 2023-3-2 +## \[2.9.1\] - 2023-3-2 ### 修复 + websocket 异常断开时连接无法释放 ++ ForwardMessage 的 `display` 字段中属性可空 @ProgramRipper ### 新增 diff --git a/docs/api/EventType.md b/docs/api/EventType.md index 907b4cdc..c54e7bbd 100644 --- a/docs/api/EventType.md +++ b/docs/api/EventType.md @@ -145,6 +145,49 @@ +### 添加好友 + +```json5 +{ + "type": "FriendAddEvent", + "friend": { + "id": 123123, + "nickname": "nick", + "remark": "remark" + }, + "stranger": true +} +``` + +| 名字 | 类型 | 说明 | +|----------| ------ |-------------------------------------------------------------------------------| +| id | Long | 好友 QQ 号码 | +| nickname | String | 好友昵称(值不确定) | +| remark | String | 好友备注 | +| stranger | String | 是否为陌生人添加,若为 `true` 对应为 `StrangerRelationChangeEvent.Friended` 的 mirai 事件,否则为 `FriendAddEvent` | + + +### 好友删除 + +```json5 +{ + "type": "FriendDeleteEvent", + "friend": { + "id": 123123, + "nickname": "nick", + "remark": "remark" + } +} +``` + +| 名字 | 类型 | 说明 | +| ---------------- | ------ | --------------------------------------------- | +| id | Long | 好友 QQ 号码 | +| nickname | String | 好友昵称(值不确定) | +| remark | String | 好友备注 | + + + ## 群事件 diff --git a/gradle.properties b/gradle.properties index 037ce682..344ec453 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ kotlin.incremental.multiplatform=true org.gradle.parallel=true # build -httpVersion=2.9.0 +httpVersion=2.9.1 # kotlin kotlinVersion=1.8.10 diff --git a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/convertor/event.kt b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/convertor/event.kt index 60cecbac..85c4e57d 100644 --- a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/convertor/event.kt +++ b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/convertor/event.kt @@ -132,6 +132,9 @@ internal suspend fun BotEvent.convertBotEvent() = when (this) { member = if (sender.user != null && sender.user is Member) { MemberDTO(sender.user as Member) } else { null }, args = args.toDTO { it != UnknownMessageDTO } ) + is FriendAddEvent -> FriendAddEventDTO(QQDTO(friend), false) + is FriendDeleteEvent -> FriendDeleteEventDTO(QQDTO(friend)) + is StrangerRelationChangeEvent.Friended -> FriendAddEventDTO(QQDTO(friend), true) else -> { if(MahContextHolder.debug) { MahContextHolder.debugLog.debug { "Unknown event: ${this.javaClass.simpleName}" } diff --git a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/dto/event.kt b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/dto/event.kt index 54599800..3d6f7726 100644 --- a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/dto/event.kt +++ b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/dto/event.kt @@ -258,6 +258,19 @@ internal data class FriendInputStatusChangedEventDTO( val inputting: Boolean, ) : BotEventDTO() +@Serializable +@SerialName("FriendAddEvent") +internal data class FriendAddEventDTO( + val friend: QQDTO, + val stranger: Boolean +) : BotEventDTO() + +@Serializable +@SerialName("FriendDeleteEvent") +internal data class FriendDeleteEventDTO( + val friend: QQDTO +) : BotEventDTO() + @Serializable @SerialName("FriendNickChangedEvent") internal data class FriendNickChangedEventDTO( diff --git a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/dto/message.kt b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/dto/message.kt index 8156cdc6..72663609 100644 --- a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/dto/message.kt +++ b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/dto/message.kt @@ -345,7 +345,7 @@ internal data class MusicShareDTO( @Serializable @SerialName("Forward") internal data class ForwardMessageDTO( - val display: ForwardMessageDisplayDTO?, + val display: ForwardMessageDisplayDTO? = null, val nodeList: List, ) : MessageDTO() { @OptIn(ConsoleExperimentalApi::class) @@ -372,11 +372,11 @@ internal data class ForwardMessageDTO( @Serializable internal data class ForwardMessageDisplayDTO( - val brief: String?, - val preview: List?, - val source: String?, - val summary: String?, - val title: String?, + val brief: String? = null, + val preview: List? = null, + val source: String? = null, + val summary: String? = null, + val title: String? = null, ) : ForwardMessage.DisplayStrategy { override fun generateBrief(forward: RawForwardMessage) = brief ?: super.generateBrief(forward) override fun generatePreview(forward: RawForwardMessage) = preview ?: super.generatePreview(forward) diff --git a/mirai-api-http/src/main/resources/plugin.yml b/mirai-api-http/src/main/resources/plugin.yml index f9735f96..18912a5a 100644 --- a/mirai-api-http/src/main/resources/plugin.yml +++ b/mirai-api-http/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ id: net.mamoe.mirai-api-http name: mirai-api-http main: net.mamoe.mirai.api.http.HttpApiPluginBase -version: 2.9.0 +version: 2.9.1 author: ryoii info: Mirai HTTP API Server Plugin \ No newline at end of file