mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-31 03:30:08 +08:00
Add companion Key
s to GroupImage
, FriendImage
, OnlineImage
, OfflineImage
This commit is contained in:
parent
917aaf685b
commit
7443e2aedd
@ -85,6 +85,8 @@ abstract class AbstractImage internal constructor() : Image {
|
|||||||
* 一般由 [Contact.uploadImage] 得到
|
* 一般由 [Contact.uploadImage] 得到
|
||||||
*/
|
*/
|
||||||
interface OnlineImage : Image {
|
interface OnlineImage : Image {
|
||||||
|
companion object Key : Message.Key<OnlineImage>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 原图下载链接. 包含域名
|
* 原图下载链接. 包含域名
|
||||||
*/
|
*/
|
||||||
@ -115,7 +117,9 @@ suspend fun Image.queryUrl(): String {
|
|||||||
* 一般由 [Contact.uploadImage] 得到
|
* 一般由 [Contact.uploadImage] 得到
|
||||||
* @see queryOriginUrl
|
* @see queryOriginUrl
|
||||||
*/
|
*/
|
||||||
interface OfflineImage : Image
|
interface OfflineImage : Image {
|
||||||
|
companion object Key : Message.Key<OfflineImage>
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 原图下载链接. 包含域名
|
* 原图下载链接. 包含域名
|
||||||
@ -142,6 +146,8 @@ suspend inline fun OfflineImage.queryOriginUrl(): String = queryUrl()
|
|||||||
// CustomFace
|
// CustomFace
|
||||||
@OptIn(MiraiInternalAPI::class)
|
@OptIn(MiraiInternalAPI::class)
|
||||||
sealed class GroupImage : AbstractImage() {
|
sealed class GroupImage : AbstractImage() {
|
||||||
|
companion object Key : Message.Key<GroupImage>
|
||||||
|
|
||||||
abstract val filepath: String
|
abstract val filepath: String
|
||||||
abstract val fileId: Int
|
abstract val fileId: Int
|
||||||
abstract val serverIp: Int
|
abstract val serverIp: Int
|
||||||
@ -213,6 +219,8 @@ abstract class OnlineGroupImage : GroupImage(), OnlineImage
|
|||||||
*/ // NotOnlineImage
|
*/ // NotOnlineImage
|
||||||
@OptIn(MiraiInternalAPI::class)
|
@OptIn(MiraiInternalAPI::class)
|
||||||
sealed class FriendImage : AbstractImage() {
|
sealed class FriendImage : AbstractImage() {
|
||||||
|
companion object Key : Message.Key<FriendImage>
|
||||||
|
|
||||||
abstract val resourceId: String
|
abstract val resourceId: String
|
||||||
abstract val md5: ByteArray
|
abstract val md5: ByteArray
|
||||||
abstract val filepath: String
|
abstract val filepath: String
|
||||||
|
@ -127,6 +127,10 @@ fun <M : Message> MessageChain.firstOrNull(key: Message.Key<M>): M? = when (key)
|
|||||||
AtAll -> first<AtAll>()
|
AtAll -> first<AtAll>()
|
||||||
PlainText -> first<PlainText>()
|
PlainText -> first<PlainText>()
|
||||||
Image -> first<Image>()
|
Image -> first<Image>()
|
||||||
|
OnlineImage -> first<OnlineImage>()
|
||||||
|
OfflineImage -> first<OfflineImage>()
|
||||||
|
GroupImage -> first<GroupImage>()
|
||||||
|
FriendImage -> first<FriendImage>()
|
||||||
Face -> first<Face>()
|
Face -> first<Face>()
|
||||||
QuoteReply -> first<QuoteReply>()
|
QuoteReply -> first<QuoteReply>()
|
||||||
MessageSource -> first<MessageSource>()
|
MessageSource -> first<MessageSource>()
|
||||||
@ -360,7 +364,7 @@ fun Message.flatten(): Sequence<SingleMessage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun CombinedMessage.flatten(): Sequence<SingleMessage> {
|
fun CombinedMessage.flatten(): Sequence<SingleMessage> {
|
||||||
if (this.isFlat()){
|
if (this.isFlat()) {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
return (this as Iterable<SingleMessage>).asSequence()
|
return (this as Iterable<SingleMessage>).asSequence()
|
||||||
} else return this.asSequence().flatten()
|
} else return this.asSequence().flatten()
|
||||||
|
Loading…
Reference in New Issue
Block a user