Commit cd41166f authored by Him188's avatar Him188

Fix init error

parent 32553fad
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE * https://github.com/mamoe/mirai/blob/master/LICENSE
*/ */
@file:Suppress("unused")
package net.mamoe.mirai.message package net.mamoe.mirai.message
import android.graphics.Bitmap import android.graphics.Bitmap
...@@ -28,29 +30,66 @@ import java.net.URL ...@@ -28,29 +30,66 @@ import java.net.URL
replaceWith = ReplaceWith("ContactMessage", "net.mamoe.mirai.message.ContactMessage") replaceWith = ReplaceWith("ContactMessage", "net.mamoe.mirai.message.ContactMessage")
) )
@OptIn(MiraiInternalAPI::class) @OptIn(MiraiInternalAPI::class)
actual sealed class MessagePacket<TSender : QQ, TSubject : Contact> actual constructor() : actual abstract class MessagePacket<TSender : QQ, TSubject : Contact> actual constructor() :
MessagePacketBase<TSender, TSubject>() { MessagePacketBase<TSender, TSubject>() {
@JvmSynthetic
suspend inline fun uploadImage(image: Bitmap): Image = subject.uploadImage(image) suspend inline fun uploadImage(image: Bitmap): Image = subject.uploadImage(image)
@JvmSynthetic
suspend inline fun uploadImage(image: URL): Image = subject.uploadImage(image) suspend inline fun uploadImage(image: URL): Image = subject.uploadImage(image)
@JvmSynthetic
suspend inline fun uploadImage(image: Input): Image = subject.uploadImage(image) suspend inline fun uploadImage(image: Input): Image = subject.uploadImage(image)
@JvmSynthetic
suspend inline fun uploadImage(image: InputStream): Image = subject.uploadImage(image) suspend inline fun uploadImage(image: InputStream): Image = subject.uploadImage(image)
@JvmSynthetic
suspend inline fun uploadImage(image: File): Image = subject.uploadImage(image) suspend inline fun uploadImage(image: File): Image = subject.uploadImage(image)
@JvmSynthetic
suspend inline fun sendImage(image: Bitmap): MessageReceipt<TSubject> = subject.sendImage(image) suspend inline fun sendImage(image: Bitmap): MessageReceipt<TSubject> = subject.sendImage(image)
@JvmSynthetic
suspend inline fun sendImage(image: URL): MessageReceipt<TSubject> = subject.sendImage(image) suspend inline fun sendImage(image: URL): MessageReceipt<TSubject> = subject.sendImage(image)
@JvmSynthetic
suspend inline fun sendImage(image: Input): MessageReceipt<TSubject> = subject.sendImage(image) suspend inline fun sendImage(image: Input): MessageReceipt<TSubject> = subject.sendImage(image)
@JvmSynthetic
suspend inline fun sendImage(image: InputStream): MessageReceipt<TSubject> = subject.sendImage(image) suspend inline fun sendImage(image: InputStream): MessageReceipt<TSubject> = subject.sendImage(image)
@JvmSynthetic
suspend inline fun sendImage(image: File): MessageReceipt<TSubject> = subject.sendImage(image) suspend inline fun sendImage(image: File): MessageReceipt<TSubject> = subject.sendImage(image)
@JvmSynthetic
suspend inline fun Bitmap.upload(): Image = upload(subject) suspend inline fun Bitmap.upload(): Image = upload(subject)
@JvmSynthetic
suspend inline fun URL.uploadAsImage(): Image = uploadAsImage(subject) suspend inline fun URL.uploadAsImage(): Image = uploadAsImage(subject)
@JvmSynthetic
suspend inline fun Input.uploadAsImage(): Image = uploadAsImage(subject) suspend inline fun Input.uploadAsImage(): Image = uploadAsImage(subject)
@JvmSynthetic
suspend inline fun InputStream.uploadAsImage(): Image = uploadAsImage(subject) suspend inline fun InputStream.uploadAsImage(): Image = uploadAsImage(subject)
@JvmSynthetic
suspend inline fun File.uploadAsImage(): Image = uploadAsImage(subject) suspend inline fun File.uploadAsImage(): Image = uploadAsImage(subject)
@JvmSynthetic
suspend inline fun Bitmap.send(): MessageReceipt<TSubject> = sendTo(subject) suspend inline fun Bitmap.send(): MessageReceipt<TSubject> = sendTo(subject)
@JvmSynthetic
suspend inline fun URL.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject) suspend inline fun URL.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject)
@JvmSynthetic
suspend inline fun Input.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject) suspend inline fun Input.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject)
@JvmSynthetic
suspend inline fun InputStream.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject) suspend inline fun InputStream.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject)
@JvmSynthetic
suspend inline fun File.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject) suspend inline fun File.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject)
} }
\ No newline at end of file
...@@ -65,7 +65,8 @@ abstract class ContactMessage : MessagePacket<QQ, Contact>(), BotEvent ...@@ -65,7 +65,8 @@ abstract class ContactMessage : MessagePacket<QQ, Contact>(), BotEvent
message = "use ContactMessage", message = "use ContactMessage",
replaceWith = ReplaceWith("ContactMessage", "net.mamoe.mirai.message.ContactMessage") replaceWith = ReplaceWith("ContactMessage", "net.mamoe.mirai.message.ContactMessage")
) )
expect sealed class MessagePacket<TSender : QQ, TSubject : Contact>() : MessagePacketBase<TSender, TSubject> expect abstract class MessagePacket<TSender : QQ, TSubject : Contact> constructor() :
MessagePacketBase<TSender, TSubject>
/** /**
* 仅内部使用, 请使用 [ContactMessage] * 仅内部使用, 请使用 [ContactMessage]
......
...@@ -38,71 +38,99 @@ import java.net.URL ...@@ -38,71 +38,99 @@ import java.net.URL
replaceWith = ReplaceWith("ContactMessage", "net.mamoe.mirai.message.ContactMessage") replaceWith = ReplaceWith("ContactMessage", "net.mamoe.mirai.message.ContactMessage")
) )
@OptIn(MiraiInternalAPI::class, MiraiExperimentalAPI::class) @OptIn(MiraiInternalAPI::class, MiraiExperimentalAPI::class)
actual sealed class MessagePacket<TSender : QQ, TSubject : Contact> actual constructor() : MessagePacketBase<TSender, TSubject>() { actual abstract class MessagePacket<TSender : QQ, TSubject : Contact> actual constructor() :
MessagePacketBase<TSender, TSubject>() {
// region 上传图片 // region 上传图片
@JvmSynthetic
suspend inline fun uploadImage(image: BufferedImage): Image = subject.uploadImage(image) suspend inline fun uploadImage(image: BufferedImage): Image = subject.uploadImage(image)
@JvmSynthetic
suspend inline fun uploadImage(image: URL): Image = subject.uploadImage(image) suspend inline fun uploadImage(image: URL): Image = subject.uploadImage(image)
@JvmSynthetic
suspend inline fun uploadImage(image: Input): Image = subject.uploadImage(image) suspend inline fun uploadImage(image: Input): Image = subject.uploadImage(image)
@JvmSynthetic
suspend inline fun uploadImage(image: InputStream): Image = subject.uploadImage(image) suspend inline fun uploadImage(image: InputStream): Image = subject.uploadImage(image)
@JvmSynthetic
suspend inline fun uploadImage(image: File): Image = subject.uploadImage(image) suspend inline fun uploadImage(image: File): Image = subject.uploadImage(image)
// endregion // endregion
// region 发送图片 // region 发送图片
@JvmSynthetic
suspend inline fun sendImage(image: BufferedImage): MessageReceipt<TSubject> = subject.sendImage(image) suspend inline fun sendImage(image: BufferedImage): MessageReceipt<TSubject> = subject.sendImage(image)
@JvmSynthetic
suspend inline fun sendImage(image: URL): MessageReceipt<TSubject> = subject.sendImage(image) suspend inline fun sendImage(image: URL): MessageReceipt<TSubject> = subject.sendImage(image)
@JvmSynthetic
suspend inline fun sendImage(image: Input): MessageReceipt<TSubject> = subject.sendImage(image) suspend inline fun sendImage(image: Input): MessageReceipt<TSubject> = subject.sendImage(image)
@JvmSynthetic
suspend inline fun sendImage(image: InputStream): MessageReceipt<TSubject> = subject.sendImage(image) suspend inline fun sendImage(image: InputStream): MessageReceipt<TSubject> = subject.sendImage(image)
@JvmSynthetic
suspend inline fun sendImage(image: File): MessageReceipt<TSubject> = subject.sendImage(image) suspend inline fun sendImage(image: File): MessageReceipt<TSubject> = subject.sendImage(image)
// endregion // endregion
// region 上传图片 (扩展) // region 上传图片 (扩展)
@JvmSynthetic
suspend inline fun BufferedImage.upload(): Image = upload(subject) suspend inline fun BufferedImage.upload(): Image = upload(subject)
@JvmSynthetic
suspend inline fun URL.uploadAsImage(): Image = uploadAsImage(subject) suspend inline fun URL.uploadAsImage(): Image = uploadAsImage(subject)
@JvmSynthetic
suspend inline fun Input.uploadAsImage(): Image = uploadAsImage(subject) suspend inline fun Input.uploadAsImage(): Image = uploadAsImage(subject)
@JvmSynthetic
suspend inline fun InputStream.uploadAsImage(): Image = uploadAsImage(subject) suspend inline fun InputStream.uploadAsImage(): Image = uploadAsImage(subject)
@JvmSynthetic
suspend inline fun File.uploadAsImage(): Image = uploadAsImage(subject) suspend inline fun File.uploadAsImage(): Image = uploadAsImage(subject)
// endregion 上传图片 (扩展) // endregion 上传图片 (扩展)
// region 发送图片 (扩展) // region 发送图片 (扩展)
@JvmSynthetic
suspend inline fun BufferedImage.send(): MessageReceipt<TSubject> = sendTo(subject) suspend inline fun BufferedImage.send(): MessageReceipt<TSubject> = sendTo(subject)
@JvmSynthetic
suspend inline fun URL.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject) suspend inline fun URL.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject)
@JvmSynthetic
suspend inline fun Input.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject) suspend inline fun Input.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject)
@JvmSynthetic
suspend inline fun InputStream.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject) suspend inline fun InputStream.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject)
@JvmSynthetic
suspend inline fun File.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject) suspend inline fun File.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject)
// endregion 发送图片 (扩展) // endregion 发送图片 (扩展)
// region 下载图片 (扩展) // region 下载图片 (扩展)
@JvmSynthetic
suspend inline fun Image.downloadTo(file: File) = file.outputStream().use { downloadTo(it) } suspend inline fun Image.downloadTo(file: File) = file.outputStream().use { downloadTo(it) }
/** /**
* 下载图片到 [output] 但不关闭这个 [output] * 下载图片到 [output] 但不关闭这个 [output]
*/ */
@JvmSynthetic
suspend inline fun Image.downloadTo(output: OutputStream) = channel().copyTo(output) suspend inline fun Image.downloadTo(output: OutputStream) = channel().copyTo(output)
/** /**
* 下载图片到 [output] 并关闭这个 [output] * 下载图片到 [output] 并关闭这个 [output]
*/ */
@JvmSynthetic
suspend inline fun Image.downloadAndClose(output: OutputStream) = channel().copyAndClose(output) suspend inline fun Image.downloadAndClose(output: OutputStream) = channel().copyAndClose(output)
/** /**
* 下载图片到 [output] 但不关闭这个 [output] * 下载图片到 [output] 但不关闭这个 [output]
*/ */
@JvmSynthetic
suspend inline fun Image.downloadTo(output: Output) = channel().copyTo(output) suspend inline fun Image.downloadTo(output: Output) = channel().copyTo(output)
/** /**
* 下载图片到 [output] 并关闭这个 [output] * 下载图片到 [output] 并关闭这个 [output]
*/ */
@JvmSynthetic
suspend inline fun Image.downloadAndClose(output: Output) = channel().copyAndClose(output) suspend inline fun Image.downloadAndClose(output: Output) = channel().copyAndClose(output)
/** /**
* 下载图片到 [output] 但不关闭这个 [output] * 下载图片到 [output] 但不关闭这个 [output]
*/ */
@JvmSynthetic
suspend inline fun Image.downloadTo(output: ByteWriteChannel) = channel().copyTo(output) suspend inline fun Image.downloadTo(output: ByteWriteChannel) = channel().copyTo(output)
/** /**
* 下载图片到 [output] 并关闭这个 [output] * 下载图片到 [output] 并关闭这个 [output]
*/ */
@JvmSynthetic
suspend inline fun Image.downloadAndClose(output: ByteWriteChannel) = channel().copyAndClose(output) suspend inline fun Image.downloadAndClose(output: ByteWriteChannel) = channel().copyAndClose(output)
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment