Skip to content

Commit

Permalink
[core] change sig
Browse files Browse the repository at this point in the history
  • Loading branch information
StageGuard committed Sep 3, 2023
1 parent a01035a commit fcb38d7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 32 deletions.
8 changes: 3 additions & 5 deletions mirai-core-api/src/commonMain/kotlin/Bot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<NewFriendRequestEvent>
public suspend fun getNewFriendRequestList(broadcast: Boolean = false): List<RequestEventData.NewFriendRequest>

/**
* 关闭这个 [Bot], 立即取消 [Bot] 的 [SupervisorJob], 取消与这个 [Bot] 相关的所有有协程联系的任务.
Expand Down
3 changes: 2 additions & 1 deletion mirai-core-mock/src/internal/MockBotImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -120,7 +121,7 @@ internal class MockBotImpl(
}
}

override suspend fun getNewFriendRequestList(broadcast: Boolean): List<NewFriendRequestEvent> {
override suspend fun getNewFriendRequestList(broadcast: Boolean): List<RequestEventData.NewFriendRequest> {
return listOf()
}

Expand Down
13 changes: 2 additions & 11 deletions mirai-core/src/commonMain/kotlin/QQAndroidBot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<NewFriendRequestEvent> {
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<RequestEventData.NewFriendRequest> {
return Mirai.getNewFriendRequestList(this)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Nothing?>("ProfileService.Pb.ReqSystemMsgAction.Group") {
Expand Down

0 comments on commit fcb38d7

Please sign in to comment.