Make all the KnownEventParserAndHandlers internal

This commit is contained in:
Him188 2019-11-28 23:11:52 +08:00
parent b5efba2949
commit 6a294c0cb7
10 changed files with 45 additions and 11 deletions

View File

@ -22,7 +22,7 @@ data class AndroidDeviceStatusChangePacket(val kind: Kind) : Packet {
* Android 客户端在线状态改变 * Android 客户端在线状态改变
*/ */
@PacketVersion(date = "2019.10.31", timVersion = "2.3.2 (21173)") @PacketVersion(date = "2019.10.31", timVersion = "2.3.2 (21173)")
object AndroidDeviceOnlineStatusChangedEventFactory : KnownEventParserAndHandler<AndroidDeviceStatusChangePacket>(0x00C4u) { internal object AndroidDeviceOnlineStatusChangedEventFactory : KnownEventParserAndHandler<AndroidDeviceStatusChangePacket>(0x00C4u) {
override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): AndroidDeviceStatusChangePacket { override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): AndroidDeviceStatusChangePacket {
discardExact(13) discardExact(13)
return AndroidDeviceStatusChangePacket( return AndroidDeviceStatusChangePacket(

View File

@ -15,7 +15,7 @@ inline class ConnectionOccupiedEvent(val message: String) : EventPacket {
override fun toString(): String = "ConnectionOccupiedEvent(${message.replace("\n", "")})" override fun toString(): String = "ConnectionOccupiedEvent(${message.replace("\n", "")})"
} }
internal object ConnectionOccupiedPacketFactory : KnownEventParserAndHandler<ConnectionOccupiedEvent>(0x0030u) { internal object ConnectionOccupiedPacketHandler : KnownEventParserAndHandler<ConnectionOccupiedEvent>(0x0030u) {
override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): ConnectionOccupiedEvent { override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): ConnectionOccupiedEvent {
discardExact(6) discardExact(6)
return ConnectionOccupiedEvent(readBytes((remaining - 8).toInt()).encodeToString()) return ConnectionOccupiedEvent(readBytes((remaining - 8).toInt()).encodeToString())

View File

@ -96,6 +96,7 @@ abstract class KnownEventParserAndHandler<TPacket : Packet>(override val id: USh
FriendMessageEventParserAndHandler, FriendMessageEventParserAndHandler,
FriendAddRequestEventPacket, FriendAddRequestEventPacket,
MemberGoneEventPacketHandler, MemberGoneEventPacketHandler,
ConnectionOccupiedPacketFactory ConnectionOccupiedPacketHandler,
MemberJoinPacketHandler
) )
} }

View File

@ -37,7 +37,7 @@ data class ReceiveFriendAddRequestEvent(
} }
@PacketVersion(date = "2019.11.20", timVersion = "2.3.2 (21173)") @PacketVersion(date = "2019.11.20", timVersion = "2.3.2 (21173)")
object FriendAddRequestEventPacket : KnownEventParserAndHandler<ReceiveFriendAddRequestEvent>(0x02DFu) { internal object FriendAddRequestEventPacket : KnownEventParserAndHandler<ReceiveFriendAddRequestEvent>(0x02DFu) {
override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): ReceiveFriendAddRequestEvent = bot.withSession { override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): ReceiveFriendAddRequestEvent = bot.withSession {
// 00 00 00 08 00 0A 00 04 01 00 // 00 00 00 08 00 0A 00 04 01 00
// 00 00 00 01 // 00 00 00 01

View File

@ -14,7 +14,7 @@ data class FriendConversationInitialize(
) : EventPacket ) : EventPacket
@PacketVersion(date = "2019.11.2", timVersion = "2.3.2 (21173)") @PacketVersion(date = "2019.11.2", timVersion = "2.3.2 (21173)")
object FriendConversationInitializedEventParserAndHandler : KnownEventParserAndHandler<FriendConversationInitialize>(0x0079u) { internal object FriendConversationInitializedEventParserAndHandler : KnownEventParserAndHandler<FriendConversationInitialize>(0x0079u) {
override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): FriendConversationInitialize { override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): FriendConversationInitialize {
discardExact(4)// 00 00 00 00 discardExact(4)// 00 00 00 00
return FriendConversationInitialize(readUInt()) return FriendConversationInitialize(readUInt())

View File

@ -11,7 +11,7 @@ import net.mamoe.mirai.utils.io.debugPrint
data class GroupFileUploadPacket(inline val xmlMessage: String) : EventPacket data class GroupFileUploadPacket(inline val xmlMessage: String) : EventPacket
@PacketVersion(date = "2019.7.1", timVersion = "2.3.2 (21173)") @PacketVersion(date = "2019.7.1", timVersion = "2.3.2 (21173)")
object GroupFileUploadEventFactory : KnownEventParserAndHandler<GroupFileUploadPacket>(0x002Du) { internal object GroupFileUploadEventFactory : KnownEventParserAndHandler<GroupFileUploadPacket>(0x002Du) {
override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): GroupFileUploadPacket { override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): GroupFileUploadPacket {
this.debugPrint("GroupFileUploadPacket") this.debugPrint("GroupFileUploadPacket")
return GroupFileUploadPacket("") return GroupFileUploadPacket("")

View File

@ -1,7 +1,40 @@
@file:Suppress("EXPERIMENTAL_UNSIGNED_LITERALS")
package net.mamoe.mirai.network.protocol.tim.packet.event package net.mamoe.mirai.network.protocol.tim.packet.event
import kotlinx.io.core.ByteReadPacket
import net.mamoe.mirai.Bot
import net.mamoe.mirai.contact.Member
import net.mamoe.mirai.event.events.BotEvent
import net.mamoe.mirai.network.BotNetworkHandler
import net.mamoe.mirai.network.protocol.tim.packet.Packet
import net.mamoe.mirai.utils.MiraiInternalAPI
//群有新成员加入 //群有新成员加入
//事件 id 00 21 //事件 id 00 21
// //
//00 00 00 08 00 0A 00 04 01 00 00 00 32 DC FC C8 01 2D 5C 53 A6 03 3E 03 3F A2 06 B4 B4 BD A8 D5 DF 00 30 42 34 37 31 30 36 43 30 44 44 34 41 34 44 30 35 30 39 44 45 31 32 30 42 43 35 45 34 44 38 45 42 37 30 36 39 31 45 36 44 45 36 44 39 46 37 36 30 //00 00 00 08 00 0A 00 04 01 00 00 00 32 DC FC C8 01 2D 5C 53 A6 03 3E 03 3F A2 06 B4 B4 BD A8 D5 DF 00 30 42 34 37 31 30 36 43 30 44 44 34 41 34 44 30 35 30 39 44 45 31 32 30 42 43 35 45 34 44 38 45 42 37 30 36 39 31 45 36 44 45 36 44 39 46 37 36 30
/**
* 新成员加入. 此时这个人还没被添加到群列表
*/
internal class MemberJoinEventPacket(
val member: Member
) : Packet
class MemberJoinEvent : BotEvent() {
}
@UseExperimental(MiraiInternalAPI::class)
internal object MemberJoinPacketHandler : KnownEventParserAndHandler<MemberJoinEventPacket>(0x0021u) {
override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): MemberJoinEventPacket {
TODO()
}
override suspend fun BotNetworkHandler<*>.handlePacket(packet: MemberJoinEventPacket) {
}
}

View File

@ -48,7 +48,7 @@ data class BeingKickEvent(val group: Group, val operator: Member) : MemberListCh
/** /**
* 成员退出. 可能是被踢出也可能是主动退出 * 成员退出. 可能是被踢出也可能是主动退出
*/ */
object MemberGoneEventPacketHandler : KnownEventParserAndHandler<MemberListChangedEvent>(0x0022u) { internal object MemberGoneEventPacketHandler : KnownEventParserAndHandler<MemberListChangedEvent>(0x0022u) {
override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): MemberListChangedEvent { override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): MemberListChangedEvent {
discardExact(11) discardExact(11)

View File

@ -28,7 +28,7 @@ data class MemberPermissionChangePacket(
} }
@PacketVersion(date = "2019.11.1", timVersion = "2.3.2 (21173)") @PacketVersion(date = "2019.11.1", timVersion = "2.3.2 (21173)")
object GroupMemberPermissionChangedEventFactory : KnownEventParserAndHandler<MemberPermissionChangePacket>(0x002Cu) { internal object GroupMemberPermissionChangedEventFactory : KnownEventParserAndHandler<MemberPermissionChangePacket>(0x002Cu) {
override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): MemberPermissionChangePacket { override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): MemberPermissionChangePacket {
// 群里一个人变成管理员: // 群里一个人变成管理员:
// 00 00 00 08 00 0A 00 04 01 00 00 00 22 96 29 7B 01 01 76 E4 B8 DD 01 // 00 00 00 08 00 0A 00 04 01 00 00 00 22 96 29 7B 01 01 76 E4 B8 DD 01

View File

@ -113,7 +113,7 @@ data class GroupMessage(
} }
@PacketVersion(date = "2019.11.2", timVersion = "2.3.2 (21173)") @PacketVersion(date = "2019.11.2", timVersion = "2.3.2 (21173)")
object GroupMessageEventParserAndHandler : KnownEventParserAndHandler<GroupMessage>(0x0052u) { internal object GroupMessageEventParserAndHandler : KnownEventParserAndHandler<GroupMessage>(0x0052u) {
override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): GroupMessage { override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): GroupMessage {
discardExact(31) discardExact(31)
val groupNumber = readUInt() val groupNumber = readUInt()
@ -183,7 +183,7 @@ data class FriendMessage(
@Suppress("unused") @Suppress("unused")
@PacketVersion(date = "2019.11.2", timVersion = "2.3.2 (21173)") @PacketVersion(date = "2019.11.2", timVersion = "2.3.2 (21173)")
object FriendMessageEventParserAndHandler : KnownEventParserAndHandler<FriendMessage>(0x00A6u) { internal object FriendMessageEventParserAndHandler : KnownEventParserAndHandler<FriendMessage>(0x00A6u) {
override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): FriendMessage { override suspend fun ByteReadPacket.parse(bot: Bot, identity: EventPacketIdentity): FriendMessage {
discardExact(2) discardExact(2)
val l1 = readShort() val l1 = readShort()