mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-08 17:20:11 +08:00
Make all the KnownEventParserAndHandlers internal
This commit is contained in:
parent
b5efba2949
commit
6a294c0cb7
@ -22,7 +22,7 @@ data class AndroidDeviceStatusChangePacket(val kind: Kind) : Packet {
|
||||
* Android 客户端在线状态改变
|
||||
*/
|
||||
@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 {
|
||||
discardExact(13)
|
||||
return AndroidDeviceStatusChangePacket(
|
||||
|
@ -15,7 +15,7 @@ inline class ConnectionOccupiedEvent(val message: String) : EventPacket {
|
||||
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 {
|
||||
discardExact(6)
|
||||
return ConnectionOccupiedEvent(readBytes((remaining - 8).toInt()).encodeToString())
|
||||
|
@ -96,6 +96,7 @@ abstract class KnownEventParserAndHandler<TPacket : Packet>(override val id: USh
|
||||
FriendMessageEventParserAndHandler,
|
||||
FriendAddRequestEventPacket,
|
||||
MemberGoneEventPacketHandler,
|
||||
ConnectionOccupiedPacketFactory
|
||||
ConnectionOccupiedPacketHandler,
|
||||
MemberJoinPacketHandler
|
||||
)
|
||||
}
|
@ -37,7 +37,7 @@ data class ReceiveFriendAddRequestEvent(
|
||||
}
|
||||
|
||||
@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 {
|
||||
// 00 00 00 08 00 0A 00 04 01 00
|
||||
// 00 00 00 01
|
||||
|
@ -14,7 +14,7 @@ data class FriendConversationInitialize(
|
||||
) : EventPacket
|
||||
|
||||
@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 {
|
||||
discardExact(4)// 00 00 00 00
|
||||
return FriendConversationInitialize(readUInt())
|
||||
|
@ -11,7 +11,7 @@ import net.mamoe.mirai.utils.io.debugPrint
|
||||
data class GroupFileUploadPacket(inline val xmlMessage: String) : EventPacket
|
||||
|
||||
@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 {
|
||||
this.debugPrint("GroupFileUploadPacket")
|
||||
return GroupFileUploadPacket("")
|
||||
|
@ -1,7 +1,40 @@
|
||||
@file:Suppress("EXPERIMENTAL_UNSIGNED_LITERALS")
|
||||
|
||||
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
|
||||
//
|
||||
//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) {
|
||||
|
||||
}
|
||||
}
|
@ -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 {
|
||||
discardExact(11)
|
||||
|
||||
|
@ -28,7 +28,7 @@ data class MemberPermissionChangePacket(
|
||||
}
|
||||
|
||||
@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 {
|
||||
// 群里一个人变成管理员:
|
||||
// 00 00 00 08 00 0A 00 04 01 00 00 00 22 96 29 7B 01 01 76 E4 B8 DD 01
|
||||
|
@ -113,7 +113,7 @@ data class GroupMessage(
|
||||
}
|
||||
|
||||
@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 {
|
||||
discardExact(31)
|
||||
val groupNumber = readUInt()
|
||||
@ -183,7 +183,7 @@ data class FriendMessage(
|
||||
|
||||
@Suppress("unused")
|
||||
@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 {
|
||||
discardExact(2)
|
||||
val l1 = readShort()
|
||||
|
Loading…
Reference in New Issue
Block a user