Commit 288d0df7 authored by Him188's avatar Him188

Image support

parent 08783fe2
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive
import kotlinx.coroutines.delay
import kotlinx.io.core.ByteReadPacket import kotlinx.io.core.ByteReadPacket
import kotlinx.io.core.discardExact import kotlinx.io.core.discardExact
import kotlinx.io.core.readBytes import kotlinx.io.core.readBytes
...@@ -52,7 +53,11 @@ internal class OnlinePush { ...@@ -52,7 +53,11 @@ internal class OnlinePush {
override suspend fun QQAndroidBot.handle(packet: GroupMessage) { override suspend fun QQAndroidBot.handle(packet: GroupMessage) {
if (packet.senderName == "Him188moe") { if (packet.senderName == "Him188moe") {
this.getQQ(2978594313).sendMessage("FROM MIRAI") packet.group.sendMessage("hello from mirai")
delay(100)
packet.group.sendMessage(packet.message)
delay(100)
this.getQQ(1040400290).sendMessage("FROM MIRAI")
} }
} }
} }
......
...@@ -16,6 +16,15 @@ internal fun MessageChain.toRichTextElems(): MutableList<ImMsgBody.Elem> { ...@@ -16,6 +16,15 @@ internal fun MessageChain.toRichTextElems(): MutableList<ImMsgBody.Elem> {
is At -> { is At -> {
} }
is Image -> {
elems.add(
ImMsgBody.Elem(
notOnlineImage = ImMsgBody.NotOnlineImage(
filePath = it.id.value
)
)
)
}
} }
} }
...@@ -23,23 +32,27 @@ internal fun MessageChain.toRichTextElems(): MutableList<ImMsgBody.Elem> { ...@@ -23,23 +32,27 @@ internal fun MessageChain.toRichTextElems(): MutableList<ImMsgBody.Elem> {
} }
internal fun ImMsgBody.RichText.toMessageChain() : MessageChain{ internal fun ImMsgBody.RichText.toMessageChain(): MessageChain {
val message = MessageChain(initialCapacity = elems.size) val message = MessageChain(initialCapacity = elems.size)
elems.forEach { elems.forEach {
when { when {
it.notOnlineImage != null -> message.add(Image( it.notOnlineImage != null -> message.add(
Image(
ImageIdQQA( ImageIdQQA(
it.notOnlineImage.resId, it.notOnlineImage.resId,
it.notOnlineImage.origUrl it.notOnlineImage.origUrl
) )
)) )
it.customFace != null -> message.add(Image( )
it.customFace != null -> message.add(
Image(
ImageIdQQA( ImageIdQQA(
it.customFace.filePath, it.customFace.filePath,
it.customFace.origUrl it.customFace.origUrl
) )
)) )
)
it.text != null -> message.add(it.text.str.toMessage()) it.text != null -> message.add(it.text.str.toMessage())
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment