mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-04 07:44:42 +08:00
change robot structure
This commit is contained in:
parent
6991a73af5
commit
c2eee671ca
@ -1,5 +1,6 @@
|
||||
package net.mamoe.mirai.network.packet
|
||||
|
||||
import net.mamoe.mirai.util.toUHexString
|
||||
import net.mamoe.mirai.utils.MiraiLogger
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.DataInputStream
|
||||
@ -32,7 +33,7 @@ class ServerGroupUploadFileEventPacket(input: DataInputStream, packetId: ByteArr
|
||||
lateinit var message: String
|
||||
|
||||
override fun decode() {
|
||||
message = String(this.input.goto(65).readNBytes(this.input.goto(60).readShort().toInt()))
|
||||
message = String(this.input.goto(64).readNBytes(this.input.goto(60).readShort().toInt()))
|
||||
}//todo test
|
||||
}
|
||||
|
||||
@ -46,12 +47,7 @@ class ServerGroupMessageEventPacket(input: DataInputStream, packetId: ByteArray,
|
||||
NORMAL,
|
||||
XML,
|
||||
AT,
|
||||
FACE,//qq自带表情 [face107.gif]
|
||||
|
||||
PLAIN_TEXT, //纯文本
|
||||
IMAGE, //自定义图片 {F50C5235-F958-6DF7-4EFA-397736E125A4}.gif
|
||||
|
||||
ANONYMOUS,//匿名用户发出的消息
|
||||
IMAGE,
|
||||
|
||||
OTHER,
|
||||
}
|
||||
@ -60,26 +56,17 @@ class ServerGroupMessageEventPacket(input: DataInputStream, packetId: ByteArray,
|
||||
group = this.input.goto(51).readInt()
|
||||
qq = this.input.goto(56).readInt()
|
||||
val fontLength = this.input.goto(108).readShort()
|
||||
//println(this.input.goto(110 + fontLength).readNBytes(2).toUHexString())//always 00 00
|
||||
println(this.input.goto(110 + fontLength).readNBytes(2).toUHexString())
|
||||
|
||||
messageType = when (val id = this.input.goto(110 + fontLength + 2).readByte().toInt()) {
|
||||
19 -> MessageType.NORMAL
|
||||
14 -> MessageType.XML
|
||||
2 -> MessageType.IMAGE
|
||||
6 -> MessageType.AT
|
||||
|
||||
|
||||
1 -> MessageType.PLAIN_TEXT
|
||||
2 -> MessageType.FACE
|
||||
3 -> MessageType.IMAGE
|
||||
25 -> MessageType.ANONYMOUS
|
||||
|
||||
else -> {
|
||||
println("id=$id")
|
||||
MessageType.OTHER
|
||||
}
|
||||
else -> MessageType.OTHER
|
||||
}
|
||||
|
||||
|
||||
when (messageType) {
|
||||
MessageType.NORMAL -> {
|
||||
val gzippedMessage = this.input.goto(110 + fontLength + 16).readNBytes(this.input.goto(110 + fontLength + 3).readShort().toInt() - 11)
|
||||
@ -97,7 +84,7 @@ class ServerGroupMessageEventPacket(input: DataInputStream, packetId: ByteArray,
|
||||
}
|
||||
}
|
||||
|
||||
MessageType.FACE -> {
|
||||
MessageType.IMAGE -> {
|
||||
val faceId = this.input.goto(110 + fontLength + 8).readByte()
|
||||
message = "[face${faceId}.gif]"
|
||||
}
|
||||
@ -155,7 +142,7 @@ class ServerFriendMessageEventPacket(input: DataInputStream, packetId: ByteArray
|
||||
val fontLength = input.readShort(93+msgLength)
|
||||
val offset = msgLength+fontLength
|
||||
message = if(input.readByte(97+offset).toUHexString() == "02"){
|
||||
"[face" + input.goto(103+offset).readVarString(1) + ".gif]"
|
||||
"[face" + input.goto(103+offset).readByte(1).toInt().toString() + ".gif]"
|
||||
//.gif
|
||||
}else {
|
||||
val offset2 = input.readShort(101 + offset)
|
||||
|
Loading…
Reference in New Issue
Block a user