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
98881fe3
Commit
98881fe3
authored
Feb 07, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Common constructor for Image
parent
b7d8396f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt
...c/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt
+19
-6
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt
View file @
98881fe3
...
@@ -4,13 +4,24 @@ package net.mamoe.mirai.message.data
...
@@ -4,13 +4,24 @@ package net.mamoe.mirai.message.data
import
kotlinx.serialization.Serializable
import
kotlinx.serialization.Serializable
import
net.mamoe.mirai.utils.io.chunkedHexToBytes
import
net.mamoe.mirai.utils.io.chunkedHexToBytes
import
kotlin.jvm.JvmName
/**
* 自定义表情 (收藏的表情), 图片
*/
sealed
class
Image
:
Message
{
sealed
class
Image
:
Message
{
companion
object
Key
:
Message
.
Key
<
Image
>
{
@JvmName
(
"fromId"
)
operator
fun
invoke
(
miraiImageId
:
String
):
Image
=
when
(
miraiImageId
.
length
)
{
37
->
NotOnlineImageFromFile
(
miraiImageId
)
// /f8f1ab55-bf8e-4236-b55e-955848d7069f
42
->
CustomFaceFromFile
(
miraiImageId
)
// {01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.png
else
->
throw
IllegalArgumentException
(
"Bad miraiImageId, expecting length=37 or 42, got ${miraiImageId.length}"
)
}
}
abstract
val
miraiImageId
:
String
abstract
val
miraiImageId
:
String
abstract
override
fun
toString
():
String
abstract
override
fun
toString
():
String
companion
object
Key
:
Message
.
Key
<
Image
>
abstract
override
fun
eq
(
other
:
Message
):
Boolean
abstract
override
fun
eq
(
other
:
Message
):
Boolean
}
}
...
@@ -158,15 +169,17 @@ abstract class NotOnlineImage : Image() {
...
@@ -158,15 +169,17 @@ abstract class NotOnlineImage : Image() {
data class
NotOnlineImageFromFile
(
data class
NotOnlineImageFromFile
(
override
val
resourceId
:
String
,
override
val
resourceId
:
String
,
override
val
md5
:
ByteArray
,
override
val
md5
:
ByteArray
,
override
val
filepath
:
String
,
override
val
filepath
:
String
=
resourceId
,
override
val
fileLength
:
Int
,
override
val
fileLength
:
Int
=
0
,
override
val
height
:
Int
,
override
val
height
:
Int
=
0
,
override
val
width
:
Int
,
override
val
width
:
Int
=
0
,
override
val
bizType
:
Int
=
0
,
override
val
bizType
:
Int
=
0
,
override
val
imageType
:
Int
=
1000
,
override
val
imageType
:
Int
=
1000
,
override
val
downloadPath
:
String
=
resourceId
,
override
val
downloadPath
:
String
=
resourceId
,
override
val
fileId
:
Int
=
0
override
val
fileId
:
Int
=
0
)
:
NotOnlineImage
()
{
)
:
NotOnlineImage
()
{
constructor
(
miraiImageId
:
String
)
:
this
(
resourceId
=
miraiImageId
,
md5
=
calculateImageMd5ByMiraiImageId
(
miraiImageId
))
override
fun
equals
(
other
:
Any
?):
Boolean
{
override
fun
equals
(
other
:
Any
?):
Boolean
{
if
(
this
===
other
)
return
true
if
(
this
===
other
)
return
true
if
(
other
==
null
||
this
::
class
!= other::class) return false
if
(
other
==
null
||
this
::
class
!= other::class) return false
...
...
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