From c8159f1e2f409d51eea97dbebd08b6274210684d Mon Sep 17 00:00:00 2001 From: ProgramRipper Date: Sat, 18 Feb 2023 01:16:58 +0800 Subject: [PATCH 1/3] fix: make ForwardMessage.display optional --- .../mirai/api/http/adapter/internal/dto/message.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 155b8317..3fa72a97 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 @@ -193,17 +193,17 @@ internal data class MusicShareDTO( @Serializable @SerialName("Forward") internal data class ForwardMessageDTO( - val display: ForwardMessageDisplayDTO?, + val display: ForwardMessageDisplayDTO? = null, val nodeList: List, ) : MessageDTO() @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) @@ -242,4 +242,3 @@ object UnknownMessageDTO : MessageDTO() @Serializable sealed class MessageDTO : DTO - From 5280f0dc8b2a25380a06dcac6f37aa3683b9bf90 Mon Sep 17 00:00:00 2001 From: ryoii Date: Thu, 2 Mar 2023 18:00:08 +0800 Subject: [PATCH 2/3] Release 2.9.1 --- .github/workflows/publish.yml | 1 + CHANGELOG.md | 3 ++- gradle.properties | 2 +- mirai-api-http/src/main/resources/plugin.yml | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) 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/gradle.properties b/gradle.properties index e1722d31..f8b855e4 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.7.10 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 From ca213c19aaeacf108c9f3543513c9988b495f4f8 Mon Sep 17 00:00:00 2001 From: StageGuard <1355416608@qq.com> Date: Wed, 21 Jun 2023 19:13:14 +0800 Subject: [PATCH 3/3] add friend relation change events --- docs/api/EventType.md | 43 +++++++++++++++++++ .../http/adapter/internal/convertor/event.kt | 3 ++ .../api/http/adapter/internal/dto/event.kt | 13 ++++++ 3 files changed, 59 insertions(+) diff --git a/docs/api/EventType.md b/docs/api/EventType.md index 3046b65d..6ed271c2 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/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 e1f6a97a..4a193833 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 @@ -121,6 +121,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 1490725f..63a422de 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 @@ -268,6 +268,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(