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