mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-23 14:20:24 +08:00
Image support
This commit is contained in:
parent
08783fe2b2
commit
288d0df738
@ -2,6 +2,7 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive
|
||||
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.discardExact
|
||||
import kotlinx.io.core.readBytes
|
||||
@ -52,7 +53,11 @@ internal class OnlinePush {
|
||||
|
||||
override suspend fun QQAndroidBot.handle(packet: GroupMessage) {
|
||||
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> {
|
||||
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> {
|
||||
}
|
||||
|
||||
|
||||
internal fun ImMsgBody.RichText.toMessageChain() : MessageChain{
|
||||
internal fun ImMsgBody.RichText.toMessageChain(): MessageChain {
|
||||
val message = MessageChain(initialCapacity = elems.size)
|
||||
|
||||
elems.forEach {
|
||||
when {
|
||||
it.notOnlineImage != null -> message.add(Image(
|
||||
ImageIdQQA(
|
||||
it.notOnlineImage.resId,
|
||||
it.notOnlineImage.origUrl
|
||||
it.notOnlineImage != null -> message.add(
|
||||
Image(
|
||||
ImageIdQQA(
|
||||
it.notOnlineImage.resId,
|
||||
it.notOnlineImage.origUrl
|
||||
)
|
||||
)
|
||||
))
|
||||
it.customFace != null -> message.add(Image(
|
||||
ImageIdQQA(
|
||||
it.customFace.filePath,
|
||||
it.customFace.origUrl
|
||||
)
|
||||
it.customFace != null -> message.add(
|
||||
Image(
|
||||
ImageIdQQA(
|
||||
it.customFace.filePath,
|
||||
it.customFace.origUrl
|
||||
)
|
||||
)
|
||||
))
|
||||
)
|
||||
it.text != null -> message.add(it.text.str.toMessage())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user