Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
cd41166f
Commit
cd41166f
authored
Apr 02, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix init error
parent
32553fad
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
3 deletions
+71
-3
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/message/MessagePacket.kt
...droidMain/kotlin/net/mamoe/mirai/message/MessagePacket.kt
+40
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt
...ommonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt
+2
-1
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/MessagePacket.kt
...c/jvmMain/kotlin/net/mamoe/mirai/message/MessagePacket.kt
+29
-1
No files found.
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/message/MessagePacket.kt
View file @
cd41166f
...
...
@@ -7,6 +7,8 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
@
file
:
Suppress
(
"unused"
)
package
net.mamoe.mirai.message
import
android.graphics.Bitmap
...
...
@@ -28,29 +30,66 @@ import java.net.URL
replaceWith
=
ReplaceWith
(
"ContactMessage"
,
"net.mamoe.mirai.message.ContactMessage"
)
)
@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
>()
{
@JvmSynthetic
suspend
inline
fun
uploadImage
(
image
:
Bitmap
):
Image
=
subject
.
uploadImage
(
image
)
@JvmSynthetic
suspend
inline
fun
uploadImage
(
image
:
URL
):
Image
=
subject
.
uploadImage
(
image
)
@JvmSynthetic
suspend
inline
fun
uploadImage
(
image
:
Input
):
Image
=
subject
.
uploadImage
(
image
)
@JvmSynthetic
suspend
inline
fun
uploadImage
(
image
:
InputStream
):
Image
=
subject
.
uploadImage
(
image
)
@JvmSynthetic
suspend
inline
fun
uploadImage
(
image
:
File
):
Image
=
subject
.
uploadImage
(
image
)
@JvmSynthetic
suspend
inline
fun
sendImage
(
image
:
Bitmap
):
MessageReceipt
<
TSubject
>
=
subject
.
sendImage
(
image
)
@JvmSynthetic
suspend
inline
fun
sendImage
(
image
:
URL
):
MessageReceipt
<
TSubject
>
=
subject
.
sendImage
(
image
)
@JvmSynthetic
suspend
inline
fun
sendImage
(
image
:
Input
):
MessageReceipt
<
TSubject
>
=
subject
.
sendImage
(
image
)
@JvmSynthetic
suspend
inline
fun
sendImage
(
image
:
InputStream
):
MessageReceipt
<
TSubject
>
=
subject
.
sendImage
(
image
)
@JvmSynthetic
suspend
inline
fun
sendImage
(
image
:
File
):
MessageReceipt
<
TSubject
>
=
subject
.
sendImage
(
image
)
@JvmSynthetic
suspend
inline
fun
Bitmap
.
upload
():
Image
=
upload
(
subject
)
@JvmSynthetic
suspend
inline
fun
URL
.
uploadAsImage
():
Image
=
uploadAsImage
(
subject
)
@JvmSynthetic
suspend
inline
fun
Input
.
uploadAsImage
():
Image
=
uploadAsImage
(
subject
)
@JvmSynthetic
suspend
inline
fun
InputStream
.
uploadAsImage
():
Image
=
uploadAsImage
(
subject
)
@JvmSynthetic
suspend
inline
fun
File
.
uploadAsImage
():
Image
=
uploadAsImage
(
subject
)
@JvmSynthetic
suspend
inline
fun
Bitmap
.
send
():
MessageReceipt
<
TSubject
>
=
sendTo
(
subject
)
@JvmSynthetic
suspend
inline
fun
URL
.
sendAsImage
():
MessageReceipt
<
TSubject
>
=
sendAsImageTo
(
subject
)
@JvmSynthetic
suspend
inline
fun
Input
.
sendAsImage
():
MessageReceipt
<
TSubject
>
=
sendAsImageTo
(
subject
)
@JvmSynthetic
suspend
inline
fun
InputStream
.
sendAsImage
():
MessageReceipt
<
TSubject
>
=
sendAsImageTo
(
subject
)
@JvmSynthetic
suspend
inline
fun
File
.
sendAsImage
():
MessageReceipt
<
TSubject
>
=
sendAsImageTo
(
subject
)
}
\ No newline at end of file
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt
View file @
cd41166f
...
...
@@ -65,7 +65,8 @@ abstract class ContactMessage : MessagePacket<QQ, Contact>(), BotEvent
message
=
"use 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]
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/MessagePacket.kt
View file @
cd41166f
...
...
@@ -38,71 +38,99 @@ import java.net.URL
replaceWith
=
ReplaceWith
(
"ContactMessage"
,
"net.mamoe.mirai.message.ContactMessage"
)
)
@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 上传图片
@JvmSynthetic
suspend
inline
fun
uploadImage
(
image
:
BufferedImage
):
Image
=
subject
.
uploadImage
(
image
)
@JvmSynthetic
suspend
inline
fun
uploadImage
(
image
:
URL
):
Image
=
subject
.
uploadImage
(
image
)
@JvmSynthetic
suspend
inline
fun
uploadImage
(
image
:
Input
):
Image
=
subject
.
uploadImage
(
image
)
@JvmSynthetic
suspend
inline
fun
uploadImage
(
image
:
InputStream
):
Image
=
subject
.
uploadImage
(
image
)
@JvmSynthetic
suspend
inline
fun
uploadImage
(
image
:
File
):
Image
=
subject
.
uploadImage
(
image
)
// endregion
// region 发送图片
@JvmSynthetic
suspend
inline
fun
sendImage
(
image
:
BufferedImage
):
MessageReceipt
<
TSubject
>
=
subject
.
sendImage
(
image
)
@JvmSynthetic
suspend
inline
fun
sendImage
(
image
:
URL
):
MessageReceipt
<
TSubject
>
=
subject
.
sendImage
(
image
)
@JvmSynthetic
suspend
inline
fun
sendImage
(
image
:
Input
):
MessageReceipt
<
TSubject
>
=
subject
.
sendImage
(
image
)
@JvmSynthetic
suspend
inline
fun
sendImage
(
image
:
InputStream
):
MessageReceipt
<
TSubject
>
=
subject
.
sendImage
(
image
)
@JvmSynthetic
suspend
inline
fun
sendImage
(
image
:
File
):
MessageReceipt
<
TSubject
>
=
subject
.
sendImage
(
image
)
// endregion
// region 上传图片 (扩展)
@JvmSynthetic
suspend
inline
fun
BufferedImage
.
upload
():
Image
=
upload
(
subject
)
@JvmSynthetic
suspend
inline
fun
URL
.
uploadAsImage
():
Image
=
uploadAsImage
(
subject
)
@JvmSynthetic
suspend
inline
fun
Input
.
uploadAsImage
():
Image
=
uploadAsImage
(
subject
)
@JvmSynthetic
suspend
inline
fun
InputStream
.
uploadAsImage
():
Image
=
uploadAsImage
(
subject
)
@JvmSynthetic
suspend
inline
fun
File
.
uploadAsImage
():
Image
=
uploadAsImage
(
subject
)
// endregion 上传图片 (扩展)
// region 发送图片 (扩展)
@JvmSynthetic
suspend
inline
fun
BufferedImage
.
send
():
MessageReceipt
<
TSubject
>
=
sendTo
(
subject
)
@JvmSynthetic
suspend
inline
fun
URL
.
sendAsImage
():
MessageReceipt
<
TSubject
>
=
sendAsImageTo
(
subject
)
@JvmSynthetic
suspend
inline
fun
Input
.
sendAsImage
():
MessageReceipt
<
TSubject
>
=
sendAsImageTo
(
subject
)
@JvmSynthetic
suspend
inline
fun
InputStream
.
sendAsImage
():
MessageReceipt
<
TSubject
>
=
sendAsImageTo
(
subject
)
@JvmSynthetic
suspend
inline
fun
File
.
sendAsImage
():
MessageReceipt
<
TSubject
>
=
sendAsImageTo
(
subject
)
// endregion 发送图片 (扩展)
// region 下载图片 (扩展)
@JvmSynthetic
suspend
inline
fun
Image
.
downloadTo
(
file
:
File
)
=
file
.
outputStream
().
use
{
downloadTo
(
it
)
}
/**
* 下载图片到 [output] 但不关闭这个 [output]
*/
@JvmSynthetic
suspend
inline
fun
Image
.
downloadTo
(
output
:
OutputStream
)
=
channel
().
copyTo
(
output
)
/**
* 下载图片到 [output] 并关闭这个 [output]
*/
@JvmSynthetic
suspend
inline
fun
Image
.
downloadAndClose
(
output
:
OutputStream
)
=
channel
().
copyAndClose
(
output
)
/**
* 下载图片到 [output] 但不关闭这个 [output]
*/
@JvmSynthetic
suspend
inline
fun
Image
.
downloadTo
(
output
:
Output
)
=
channel
().
copyTo
(
output
)
/**
* 下载图片到 [output] 并关闭这个 [output]
*/
@JvmSynthetic
suspend
inline
fun
Image
.
downloadAndClose
(
output
:
Output
)
=
channel
().
copyAndClose
(
output
)
/**
* 下载图片到 [output] 但不关闭这个 [output]
*/
@JvmSynthetic
suspend
inline
fun
Image
.
downloadTo
(
output
:
ByteWriteChannel
)
=
channel
().
copyTo
(
output
)
/**
* 下载图片到 [output] 并关闭这个 [output]
*/
@JvmSynthetic
suspend
inline
fun
Image
.
downloadAndClose
(
output
:
ByteWriteChannel
)
=
channel
().
copyAndClose
(
output
)
/*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment