1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-03-30 01:40:29 +08:00
This commit is contained in:
Him188 2019-11-15 22:56:47 +08:00
parent eb1da6a326
commit 8b3d710ede

View File

@ -22,35 +22,35 @@ import java.net.URL
// region IMAGE.sendAsImageTo(Contact)
/**
* 将图片发送到指定联系人. 不会创建临时文件
* [Dispatchers.IO] 将图片发送到指定联系人. 不会创建临时文件
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun BufferedImage.sendTo(contact: Contact) = withContext(Dispatchers.IO) { toExternalImage() }.sendTo(contact)
/**
* 下载 [URL] 到临时文件并将其作为图片发送到指定联系人
* [Dispatchers.IO] 下载 [URL] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun URL.sendAsImageTo(contact: Contact) = withContext(Dispatchers.IO) { toExternalImage() }.sendTo(contact)
/**
* 读取 [Input] 到临时文件并将其作为图片发送到指定联系人
* [Dispatchers.IO] 读取 [Input] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun Input.sendAsImageTo(contact: Contact) = withContext(Dispatchers.IO) { toExternalImage() }.sendTo(contact)
/**
* 读取 [InputStream] 到临时文件并将其作为图片发送到指定联系人
* [Dispatchers.IO] 读取 [InputStream] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun InputStream.sendAsImageTo(contact: Contact) = withContext(Dispatchers.IO) { toExternalImage() }.sendTo(contact)
/**
* 将文件作为图片发送到指定联系人
* [Dispatchers.IO] 将文件作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
@ -64,35 +64,35 @@ suspend fun File.sendAsImageTo(contact: Contact) {
// region IMAGE.Upload(Contact): Image
/**
* 将图片上传后构造 [Image]. 不会创建临时文件
* [Dispatchers.IO] 将图片上传后构造 [Image]. 不会创建临时文件
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun BufferedImage.upload(contact: Contact): Image = withContext(Dispatchers.IO) { toExternalImage() }.upload(contact)
/**
* 下载 [URL] 到临时文件并将其作为图片上传后构造 [Image]
* [Dispatchers.IO] 下载 [URL] 到临时文件并将其作为图片上传后构造 [Image]
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun URL.upload(contact: Contact): Image = withContext(Dispatchers.IO) { toExternalImage() }.upload(contact)
/**
* 读取 [Input] 到临时文件并将其作为图片上传后构造 [Image]
* [Dispatchers.IO] 读取 [Input] 到临时文件并将其作为图片上传后构造 [Image]
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun Input.upload(contact: Contact): Image = withContext(Dispatchers.IO) { toExternalImage() }.upload(contact)
/**
* 读取 [InputStream] 到临时文件并将其作为图片上传后构造 [Image]
* [Dispatchers.IO] 读取 [InputStream] 到临时文件并将其作为图片上传后构造 [Image]
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun InputStream.upload(contact: Contact): Image = withContext(Dispatchers.IO) { toExternalImage() }.upload(contact)
/**
* 将文件作为图片上传后构造 [Image]
* [Dispatchers.IO] 将文件作为图片上传后构造 [Image]
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
@ -106,35 +106,35 @@ suspend fun File.upload(contact: Contact): Image {
// region Contact.sendImage(IMAGE)
/**
* 将图片发送到指定联系人. 不会保存临时文件
* [Dispatchers.IO] 将图片发送到指定联系人. 不会保存临时文件
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun Contact.sendImage(bufferedImage: BufferedImage) = bufferedImage.sendTo(this)
/**
* 下载 [URL] 到临时文件并将其作为图片发送到指定联系人
* [Dispatchers.IO] 下载 [URL] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun Contact.sendImage(imageUrl: URL) = imageUrl.sendAsImageTo(this)
/**
* 读取 [Input] 到临时文件并将其作为图片发送到指定联系人
* [Dispatchers.IO] 读取 [Input] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun Contact.sendImage(imageInput: Input) = imageInput.sendAsImageTo(this)
/**
* 读取 [InputStream] 到临时文件并将其作为图片发送到指定联系人
* [Dispatchers.IO] 读取 [InputStream] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun Contact.sendImage(imageStream: InputStream) = imageStream.sendAsImageTo(this)
/**
* 将文件作为图片发送到指定联系人
* [Dispatchers.IO] 将文件作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
@ -145,35 +145,35 @@ suspend fun Contact.sendImage(file: File) = file.sendAsImageTo(this)
// region Contact.uploadImage(IMAGE)
/**
* 将图片发送到指定联系人. 不会保存临时文件
* [Dispatchers.IO] 将图片发送到指定联系人. 不会保存临时文件
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun Contact.uploadImage(bufferedImage: BufferedImage): Image = bufferedImage.upload(this)
/**
* 下载 [URL] 到临时文件并将其作为图片发送到指定联系人
* [Dispatchers.IO] 下载 [URL] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun Contact.uploadImage(imageUrl: URL): Image = imageUrl.upload(this)
/**
* 读取 [Input] 到临时文件并将其作为图片发送到指定联系人
* [Dispatchers.IO] 读取 [Input] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun Contact.uploadImage(imageInput: Input): Image = imageInput.upload(this)
/**
* 读取 [InputStream] 到临时文件并将其作为图片发送到指定联系人
* [Dispatchers.IO] 读取 [InputStream] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
suspend fun Contact.uploadImage(imageStream: InputStream): Image = imageStream.upload(this)
/**
* 将文件作为图片发送到指定联系人
* [Dispatchers.IO] 将文件作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)