mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-10 06:57:05 +08:00
Add bot argument to PushReqResponse and filter in ConfigPushProcessorImpl
This commit is contained in:
parent
d14ed0cecd
commit
a77b52e7d3
@ -32,7 +32,7 @@ internal class ConfigPushProcessorImpl(
|
||||
private val logger: MiraiLogger,
|
||||
) : ConfigPushProcessor {
|
||||
override suspend fun syncConfigPush(network: NetworkHandler) {
|
||||
if (nextEventOrNull<ConfigPushSvc.PushReq.PushReqResponse>(60_000) == null) {
|
||||
if (nextEventOrNull<ConfigPushSvc.PushReq.PushReqResponse>(60_000) { it.bot == network.context.bot } == null) {
|
||||
val bdhSyncer = network.context[BdhSessionSyncer]
|
||||
if (!bdhSyncer.hasSession) {
|
||||
val e = IllegalStateException("Timeout waiting for ConfigPush.")
|
||||
|
@ -50,26 +50,29 @@ internal class ConfigPushSvc {
|
||||
) {
|
||||
override val canBeCached: Boolean get() = false
|
||||
|
||||
sealed class PushReqResponse(val struct: PushReqJceStruct) : Packet, Event, AbstractEvent(), Packet.NoEventLog {
|
||||
class Unknown(struct: PushReqJceStruct) : PushReqResponse(struct) {
|
||||
sealed class PushReqResponse(
|
||||
val struct: PushReqJceStruct,
|
||||
val bot: QQAndroidBot,
|
||||
) : Packet, Event, AbstractEvent(), Packet.NoEventLog {
|
||||
class Unknown(struct: PushReqJceStruct, bot: QQAndroidBot) : PushReqResponse(struct, bot) {
|
||||
override fun toString(): String {
|
||||
return "ConfigPushSvc.PushReq.PushReqResponse.Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
class LogAction(struct: PushReqJceStruct) : PushReqResponse(struct) {
|
||||
class LogAction(struct: PushReqJceStruct, bot: QQAndroidBot) : PushReqResponse(struct, bot) {
|
||||
override fun toString(): String {
|
||||
return "ConfigPushSvc.PushReq.PushReqResponse.LogAction"
|
||||
}
|
||||
}
|
||||
|
||||
class ServerListPush(struct: PushReqJceStruct) : PushReqResponse(struct) {
|
||||
class ServerListPush(struct: PushReqJceStruct, bot: QQAndroidBot) : PushReqResponse(struct, bot) {
|
||||
override fun toString(): String {
|
||||
return "ConfigPushSvc.PushReq.PushReqResponse.ServerListPush"
|
||||
}
|
||||
}
|
||||
|
||||
class ConfigPush(struct: PushReqJceStruct) : PushReqResponse(struct) {
|
||||
class ConfigPush(struct: PushReqJceStruct, bot: QQAndroidBot) : PushReqResponse(struct, bot) {
|
||||
override fun toString(): String {
|
||||
return "ConfigPushSvc.PushReq.PushReqResponse.ConfigPush"
|
||||
}
|
||||
@ -81,10 +84,10 @@ internal class ConfigPushSvc {
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot, sequenceId: Int): PushReqResponse {
|
||||
val pushReq = readUniPacket(PushReqJceStruct.serializer(), "PushReq")
|
||||
return when (pushReq.type) {
|
||||
1 -> PushReqResponse.ServerListPush(pushReq)
|
||||
2 -> PushReqResponse.ConfigPush(pushReq)
|
||||
3 -> PushReqResponse.LogAction(pushReq)
|
||||
else -> PushReqResponse.Unknown(pushReq)
|
||||
1 -> PushReqResponse.ServerListPush(pushReq, bot)
|
||||
2 -> PushReqResponse.ConfigPush(pushReq, bot)
|
||||
3 -> PushReqResponse.LogAction(pushReq, bot)
|
||||
else -> PushReqResponse.Unknown(pushReq, bot)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user