mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-06 00:50:13 +08:00
* try to fix #358 according to @Mar8s comment * Disable mirror * Cancel group coroutine when bot leave group and fire event separately * Re-add 0x82 and 0x83 * Revert else logic * Fix build Co-authored-by: Him188 <Him188@mamoe.net>
This commit is contained in:
parent
22112d222b
commit
2d0fa69899
@ -205,28 +205,41 @@ internal object OnlinePushPbPushTransMsg :
|
||||
A8 32 51 A1
|
||||
83 3E 03 3F A2 06 B4 B4 BD A8 D5 DF 00 30 39 32 46 45 30 36 31 41 33 37 36 43 44 35 37 35 37 39 45 37 32 34 44 37 37 30 36 46 39 39 43 35 35 33 33 31 34 44 32 44 46 35 45 42 43 31 31 36
|
||||
*/
|
||||
readUInt().toLong() // group, uin or code ?
|
||||
|
||||
discardExact(1)
|
||||
readUInt().toLong() // groupUin
|
||||
readByte().toInt() // follow type
|
||||
val target = readUInt().toLong()
|
||||
val type = readUByte().toInt()
|
||||
val operator = readUInt().toLong()
|
||||
val groupUin = content.fromUin
|
||||
|
||||
when (type) {
|
||||
0x82 -> bot.getGroupByUinOrNull(groupUin)?.let { group ->
|
||||
val member = group.getOrNull(target) as? MemberImpl ?: return null
|
||||
return MemberLeaveEvent.Quit(member.also {
|
||||
member.cancel(CancellationException("Leaved actively"))
|
||||
group.members.delegate.remove(member)
|
||||
})
|
||||
2, 0x82 -> bot.getGroupByUinOrNull(groupUin)?.let { group ->
|
||||
if (target == bot.id) {
|
||||
return BotLeaveEvent.Active(group).also {
|
||||
group.cancel(CancellationException("Leaved actively"))
|
||||
bot.groups.delegate.remove(group)
|
||||
}
|
||||
} else {
|
||||
val member = group.getOrNull(target) as? MemberImpl ?: return null
|
||||
return MemberLeaveEvent.Quit(member.also {
|
||||
member.cancel(CancellationException("Leaved actively"))
|
||||
group.members.delegate.remove(member)
|
||||
})
|
||||
}
|
||||
}
|
||||
0x83 -> bot.getGroupByUin(groupUin).let { group ->
|
||||
val member = group.getOrNull(target) as? MemberImpl ?: return null
|
||||
return MemberLeaveEvent.Kick(member.also {
|
||||
member.cancel(CancellationException("Leaved actively"))
|
||||
group.members.delegate.remove(member)
|
||||
}, group.members[operator])
|
||||
3, 0x83 -> bot.getGroupByUin(groupUin).let { group ->
|
||||
if (target == bot.id) {
|
||||
return BotLeaveEvent.Kick(group.members[operator]).also {
|
||||
group.cancel(CancellationException("Being kicked"))
|
||||
bot.groups.delegate.remove(group)
|
||||
}
|
||||
} else {
|
||||
val member = group.getOrNull(target) as? MemberImpl ?: return null
|
||||
return MemberLeaveEvent.Kick(member.also {
|
||||
member.cancel(CancellationException("Being kicked"))
|
||||
group.members.delegate.remove(member)
|
||||
}, group.members[operator])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,6 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive
|
||||
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.discardExact
|
||||
import kotlinx.io.core.readBytes
|
||||
@ -478,20 +476,23 @@ internal object Transformers528 : Map<Long, Lambda528> by mapOf(
|
||||
return@lambda528 emptySequence()
|
||||
},
|
||||
// bot 在其他客户端被踢或主动退出而同步情况
|
||||
0xD4L to lambda528 { bot ->
|
||||
0xD4L to lambda528 { _ ->
|
||||
// this.soutv("0x210")
|
||||
@Serializable
|
||||
data class SubD4(
|
||||
// ok
|
||||
val uin: Long
|
||||
) : ProtoBuf
|
||||
/* @Serializable
|
||||
data class SubD4(
|
||||
// ok
|
||||
val uin: Long
|
||||
) : ProtoBuf
|
||||
|
||||
val uin = vProtobuf.loadAs(SubD4.serializer()).uin
|
||||
val group = bot.getGroupByUinOrNull(uin) ?: bot.getGroupOrNull(uin)
|
||||
return@lambda528 if (group != null && bot.groups.delegate.remove(group)) {
|
||||
group.cancel(CancellationException("Being kicked"))
|
||||
sequenceOf(BotLeaveEvent.Active(group))
|
||||
} else emptySequence()
|
||||
val uin = vProtobuf.loadAs(SubD4.serializer()).uin
|
||||
val group = bot.getGroupByUinOrNull(uin) ?: bot.getGroupOrNull(uin)
|
||||
return@lambda528 if (group != null && bot.groups.delegate.remove(group)) {
|
||||
group.cancel(CancellationException("Being kicked"))
|
||||
sequenceOf(BotLeaveEvent.Active(group))
|
||||
} else emptySequence()*/
|
||||
|
||||
//ignore
|
||||
return@lambda528 emptySequence()
|
||||
},
|
||||
//戳一戳信息等
|
||||
0x122L to lambda528 { bot, _ ->
|
||||
|
Loading…
Reference in New Issue
Block a user