Skip to content

Commit

Permalink
add friend relation change events
Browse files Browse the repository at this point in the history
  • Loading branch information
StageGuard authored and ryoii committed Oct 5, 2023
1 parent 5280f0d commit ca213c1
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -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}" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ca213c1

Please sign in to comment.