mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-23 14:20:24 +08:00
SEND IMAGE SUPPORT
This commit is contained in:
parent
06224aa10a
commit
359be12356
@ -5,6 +5,7 @@ import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumberType
|
||||
import kotlinx.serialization.protobuf.ProtoType
|
||||
import net.mamoe.mirai.qqandroid.io.ProtoBuf
|
||||
import net.mamoe.mirai.qqandroid.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
|
||||
@Serializable
|
||||
@ -624,7 +625,7 @@ internal class ImMsgBody : ProtoBuf {
|
||||
internal class NotOnlineImage(
|
||||
@SerialId(1) val filePath: String = "",
|
||||
@SerialId(2) val fileLen: Int = 0,
|
||||
@SerialId(3) val downloadPath: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(3) val downloadPath: String = "",
|
||||
@SerialId(4) val oldVerSendFile: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(5) val imgType: Int = 0,
|
||||
@SerialId(6) val previewsImage: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@ -653,6 +654,20 @@ internal class ImMsgBody : ProtoBuf {
|
||||
@SerialId(29) val pbReserve: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable // 非官方.
|
||||
internal data class PbReserve(
|
||||
@SerialId(1) val unknown1: Int = 1,
|
||||
@SerialId(2) val unknown2: Int = 0,
|
||||
@SerialId(6) val unknown3: Int = 0,
|
||||
@SerialId(8) val hint: String = "[动画表情]",
|
||||
@SerialId(10) val unknown5: Int = 0,
|
||||
@SerialId(15) val unknwon6: Int = 5
|
||||
) : ProtoBuf {
|
||||
companion object {
|
||||
val DEFAULT: ByteArray = PbReserve().toByteArray(serializer())
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
internal class OnlineImage(
|
||||
@SerialId(1) val guid: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
|
@ -3,6 +3,7 @@ package net.mamoe.mirai.qqandroid.utils
|
||||
import net.mamoe.mirai.data.ImageLink
|
||||
import net.mamoe.mirai.message.data.*
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.ImMsgBody
|
||||
import net.mamoe.mirai.utils.io.hexToBytes
|
||||
|
||||
|
||||
internal fun MessageChain.toRichTextElems(): MutableList<ImMsgBody.Elem> {
|
||||
@ -20,7 +21,16 @@ internal fun MessageChain.toRichTextElems(): MutableList<ImMsgBody.Elem> {
|
||||
elems.add(
|
||||
ImMsgBody.Elem(
|
||||
notOnlineImage = ImMsgBody.NotOnlineImage(
|
||||
filePath = it.id.value
|
||||
filePath = it.id.value, // 错了, 应该是 2B23D705CAD1F2CF3710FE582692FCC4.jpg
|
||||
fileLen = 1149, // 假的
|
||||
downloadPath = it.id.value,
|
||||
imgType = 1000, // 不确定
|
||||
picMd5 = "2B 23 D7 05 CA D1 F2 CF 37 10 FE 58 26 92 FC C4".hexToBytes(),
|
||||
picHeight = 66,
|
||||
picWidth = 66,
|
||||
resId = it.id.value,
|
||||
bizType = 5,
|
||||
pbReserve = ImMsgBody.PbReserve.DEFAULT // 可能还可以改变 `[动画表情]`
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -14,7 +14,7 @@ fun Image(id: String) = Image(ImageId(id))
|
||||
* 由接收消息时构建, 可直接发送
|
||||
*
|
||||
* @param id 这个图片的 [ImageId]
|
||||
*/
|
||||
*/ // TODO: 2020/1/31 去掉 Image. 将 Image 改为 interface/class
|
||||
inline class Image(inline val id: ImageId) : Message {
|
||||
override fun toString(): String = "[${id.value}]"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user