diff --git a/mirai-core-api/src/commonMain/kotlin/Bot.kt b/mirai-core-api/src/commonMain/kotlin/Bot.kt index 6626de376b..f38ce4b3d3 100644 --- a/mirai-core-api/src/commonMain/kotlin/Bot.kt +++ b/mirai-core-api/src/commonMain/kotlin/Bot.kt @@ -19,7 +19,6 @@ import net.mamoe.mirai.contact.friendgroup.FriendGroups import net.mamoe.mirai.data.RequestEventData import net.mamoe.mirai.event.EventChannel import net.mamoe.mirai.event.events.BotEvent -import net.mamoe.mirai.event.events.NewFriendRequestEvent import net.mamoe.mirai.message.action.BotNudge import net.mamoe.mirai.message.action.MemberNudge import net.mamoe.mirai.network.LoginFailedException @@ -173,13 +172,12 @@ public interface Bot : CoroutineScope, ContactOrBot, UserOrBot { public override fun nudge(): BotNudge = BotNudge(this) /** - * 获取未处理的好友请求,作为事件返回 + * 获取未处理的好友请求 * - * @param broadcast 是否广播该事件,默认为不广播 - * @see NewFriendRequestEvent + * @see RequestEventData.NewFriendRequest * @since 2.16 */ - public suspend fun getNewFriendRequestList(broadcast: Boolean = false): List + public suspend fun getNewFriendRequestList(broadcast: Boolean = false): List /** * 关闭这个 [Bot], 立即取消 [Bot] 的 [SupervisorJob], 取消与这个 [Bot] 相关的所有有协程联系的任务. diff --git a/mirai-core-mock/src/internal/MockBotImpl.kt b/mirai-core-mock/src/internal/MockBotImpl.kt index 41efb3d483..e04be930ed 100644 --- a/mirai-core-mock/src/internal/MockBotImpl.kt +++ b/mirai-core-mock/src/internal/MockBotImpl.kt @@ -20,6 +20,7 @@ import net.mamoe.mirai.contact.ContactList import net.mamoe.mirai.contact.ContactOrBot import net.mamoe.mirai.contact.MemberPermission import net.mamoe.mirai.contact.friendgroup.FriendGroups +import net.mamoe.mirai.data.RequestEventData import net.mamoe.mirai.event.EventChannel import net.mamoe.mirai.event.GlobalEventChannel import net.mamoe.mirai.event.broadcast @@ -120,7 +121,7 @@ internal class MockBotImpl( } } - override suspend fun getNewFriendRequestList(broadcast: Boolean): List { + override suspend fun getNewFriendRequestList(broadcast: Boolean): List { return listOf() } diff --git a/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt b/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt index 87a135fbe2..e3d3444793 100644 --- a/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt +++ b/mirai-core/src/commonMain/kotlin/QQAndroidBot.kt @@ -322,17 +322,8 @@ internal open class QQAndroidBot constructor( ) // We can move the factory to configuration but this is not necessary for now. } - override suspend fun getNewFriendRequestList(broadcast: Boolean): List { - return Mirai.getNewFriendRequestList(this).map { data -> - NewFriendRequestEvent( - this, - data.eventId, - data.message, - data.requester, - data.fromGroupId, - data.requesterNick - ).also { if (broadcast) it.broadcast() } - } + override suspend fun getNewFriendRequestList(broadcast: Boolean): List { + return Mirai.getNewFriendRequestList(this) } } diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/NewContact.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/NewContact.kt index 7e99ed55e3..ca18455b17 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/NewContact.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/NewContact.kt @@ -149,21 +149,9 @@ internal class NewContact { override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Packet { val resp = readBytes().loadAs(Structmsg.RspSystemMsgNew.serializer()) - - return readBytes().loadAs(Structmsg.RspSystemMsgNew.serializer()).run { - groupmsgs/*.filter { - it.msgTime >= bot.syncController.latestMsgNewGroupTime - }*/.map { struct -> - /*if (!bot.syncController.syncNewGroup(struct.msgSeq, struct.msgTime)) { // duplicate - return@mapNotNull null - }*/ - bot.processPacketThroughPipeline(struct, buildTypeSafeMap { set(SYSTEM_MSG_TYPE, 1) }) - }.toPacket()/*.also { - bot.syncController.run { - latestMsgNewGroupTime = max(latestMsgNewGroupTime, groupmsgs.maxOfOrNull { it.msgTime } ?: 0) - } - }*/ - } + return resp.groupmsgs.map { struct -> + bot.processPacketThroughPipeline(struct, buildTypeSafeMap { set(SYSTEM_MSG_TYPE, 1) }) + }.toPacket() } internal object Action : OutgoingPacketFactory("ProfileService.Pb.ReqSystemMsgAction.Group") {