mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-07 16:40:43 +08:00
Move Contact.sendImage from ExternalResource to Contact
This commit is contained in:
parent
7fe0eb23b6
commit
fc3d880e19
@ -21,6 +21,7 @@ import net.mamoe.mirai.message.MessageReceipt.Companion.quote
|
|||||||
import net.mamoe.mirai.message.MessageReceipt.Companion.recall
|
import net.mamoe.mirai.message.MessageReceipt.Companion.recall
|
||||||
import net.mamoe.mirai.message.data.*
|
import net.mamoe.mirai.message.data.*
|
||||||
import net.mamoe.mirai.utils.*
|
import net.mamoe.mirai.utils.*
|
||||||
|
import net.mamoe.mirai.utils.ExternalResource.Companion.sendAsImageTo
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
|
||||||
@ -114,6 +115,16 @@ public interface Contact : ContactOrBot, CoroutineScope {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
@JvmBlockingBridge
|
@JvmBlockingBridge
|
||||||
public suspend fun <C : Contact> C.sendImage(file: File): MessageReceipt<C> = file.sendAsImageTo(this)
|
public suspend fun <C : Contact> C.sendImage(file: File): MessageReceipt<C> = file.sendAsImageTo(this)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将资源作为单独的图片消息发送给 [this]
|
||||||
|
*
|
||||||
|
* @see Contact.sendMessage 最终调用, 发送消息.
|
||||||
|
*/
|
||||||
|
@JvmBlockingBridge
|
||||||
|
@JvmStatic
|
||||||
|
public suspend inline fun <C : Contact> C.sendImage(resource: ExternalResource): MessageReceipt<C> =
|
||||||
|
resource.sendAsImageTo(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import net.mamoe.mirai.message.MessageReceipt
|
|||||||
import net.mamoe.mirai.message.data.Image
|
import net.mamoe.mirai.message.data.Image
|
||||||
import net.mamoe.mirai.message.data.sendTo
|
import net.mamoe.mirai.message.data.sendTo
|
||||||
import net.mamoe.mirai.utils.ExternalResource.Companion.sendAsImageTo
|
import net.mamoe.mirai.utils.ExternalResource.Companion.sendAsImageTo
|
||||||
import net.mamoe.mirai.utils.ExternalResource.Companion.sendImage
|
|
||||||
import net.mamoe.mirai.utils.ExternalResource.Companion.toExternalResource
|
import net.mamoe.mirai.utils.ExternalResource.Companion.toExternalResource
|
||||||
import net.mamoe.mirai.utils.ExternalResource.Companion.uploadAsImage
|
import net.mamoe.mirai.utils.ExternalResource.Companion.uploadAsImage
|
||||||
import java.io.*
|
import java.io.*
|
||||||
@ -171,15 +170,6 @@ public interface ExternalResource : Closeable {
|
|||||||
is User -> contact.uploadImage(this)
|
is User -> contact.uploadImage(this)
|
||||||
else -> error("unreachable")
|
else -> error("unreachable")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 将图片作为单独的消息发送给 [this]
|
|
||||||
*
|
|
||||||
* @see Contact.sendMessage 最终调用, 发送消息.
|
|
||||||
*/
|
|
||||||
@JvmSynthetic
|
|
||||||
public suspend inline fun <C : Contact> C.sendImage(image: ExternalResource): MessageReceipt<C> =
|
|
||||||
image.sendAsImageTo(this)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user