Broadcast FriendAddEvent on acceptNewFriendRequest

This commit is contained in:
Him188 2021-01-17 17:18:11 +08:00
parent 45072c92d3
commit 3098a7d953
2 changed files with 7 additions and 5 deletions

View File

@ -21,6 +21,7 @@ import net.mamoe.mirai.contact.Group
import net.mamoe.mirai.contact.User
import net.mamoe.mirai.event.AbstractEvent
import net.mamoe.mirai.internal.network.Packet
import net.mamoe.mirai.utils.MiraiInternalApi
import java.util.concurrent.atomic.AtomicBoolean
@ -36,7 +37,7 @@ public data class FriendRemarkChangeEvent internal constructor(
/**
* 成功添加了一个新好友的事件
*/
public data class FriendAddEvent internal constructor(
public data class FriendAddEvent @MiraiInternalApi constructor(
/**
* 新好友. 已经添加到 [Bot.friends]
*/

View File

@ -21,10 +21,7 @@ import net.mamoe.mirai.*
import net.mamoe.mirai.contact.*
import net.mamoe.mirai.data.*
import net.mamoe.mirai.event.broadcast
import net.mamoe.mirai.event.events.BotInvitedJoinGroupRequestEvent
import net.mamoe.mirai.event.events.MemberJoinEvent
import net.mamoe.mirai.event.events.MemberJoinRequestEvent
import net.mamoe.mirai.event.events.NewFriendRequestEvent
import net.mamoe.mirai.event.events.*
import net.mamoe.mirai.internal.contact.*
import net.mamoe.mirai.internal.message.*
import net.mamoe.mirai.internal.network.highway.HighwayHelper
@ -137,6 +134,10 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
accept = true,
blackList = false
)
event.bot.getFriend(event.fromId)?.let { friend ->
FriendAddEvent(friend).broadcast()
}
}
override suspend fun rejectNewFriendRequest(event: NewFriendRequestEvent, blackList: Boolean) {