Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/internal/dto/message.kt
  • Loading branch information
ryoii committed Nov 27, 2023
2 parents 277fc6a + ca213c1 commit 8e93916
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# 更新日志


## \[2.9.0\] - 2023-3-2
## \[2.9.1\] - 2023-3-2

### 修复

+ websocket 异常断开时连接无法释放
+ ForwardMessage 的 `display` 字段中属性可空 @ProgramRipper

### 新增

Expand Down
43 changes: 43 additions & 0 deletions docs/api/EventType.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | 好友备注 |




## 群事件

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ForwardMessageNode>,
) : MessageDTO() {
@OptIn(ConsoleExperimentalApi::class)
Expand All @@ -372,11 +372,11 @@ internal data class ForwardMessageDTO(

@Serializable
internal data class ForwardMessageDisplayDTO(
val brief: String?,
val preview: List<String>?,
val source: String?,
val summary: String?,
val title: String?,
val brief: String? = null,
val preview: List<String>? = 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)
Expand Down
2 changes: 1 addition & 1 deletion mirai-api-http/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8e93916

Please sign in to comment.