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
985b0b4b
Commit
985b0b4b
authored
Apr 03, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make `FlashImage` constructable from `mirai-core`
parent
5cb93c9f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
59 deletions
+53
-59
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/FlashImageImpl.kt
...otlin/net/mamoe/mirai/qqandroid/message/FlashImageImpl.kt
+4
-51
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/FlashImage.kt
...monMain/kotlin/net.mamoe.mirai/message/data/FlashImage.kt
+49
-8
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/FlashImageImpl.kt
View file @
985b0b4b
package
net.mamoe.mirai.qqandroid.message
package
net.mamoe.mirai.qqandroid.message
import
net.mamoe.mirai.message.data.*
import
net.mamoe.mirai.message.data.FriendFlashImage
import
net.mamoe.mirai.message.data.GroupFlashImage
import
net.mamoe.mirai.qqandroid.network.protocol.data.proto.HummerCommelem
import
net.mamoe.mirai.qqandroid.network.protocol.data.proto.HummerCommelem
import
net.mamoe.mirai.qqandroid.network.protocol.data.proto.ImMsgBody
import
net.mamoe.mirai.qqandroid.network.protocol.data.proto.ImMsgBody
import
net.mamoe.mirai.qqandroid.utils.io.serialization.toByteArray
import
net.mamoe.mirai.qqandroid.utils.io.serialization.toByteArray
fun
FlashImage
(
image
:
Image
)
=
when
(
image
)
{
is
GroupImage
->
GroupFlashImageImpl
(
image
)
is
FriendImage
->
FriendFlashImageImpl
(
image
)
else
->
throw
IllegalArgumentException
(
"不支持的图片类型(Please use GroupImage or FriendImage)"
)
}
fun
Image
.
flash
()
=
FlashImage
(
this
)
internal
fun
GroupFlashImage
.
toJceData
()
=
ImMsgBody
.
Elem
(
internal
class
GroupFlashImageImpl
(
override
val
image
:
GroupImage
)
:
AbstractGroupFlashImage
()
{
private
var
stringValue
:
String
?
=
null
get
()
{
return
field
?:
kotlin
.
run
{
field
=
"[mirai:flash:${image.imageId}]"
field
}
}
override
fun
toString
():
String
=
stringValue
!!
override
val
length
:
Int
get
()
=
stringValue
!!
.
length
override
fun
get
(
index
:
Int
)
=
stringValue
!!
[
index
]
override
fun
subSequence
(
startIndex
:
Int
,
endIndex
:
Int
)
=
stringValue
!!
.
subSequence
(
startIndex
,
endIndex
)
override
fun
compareTo
(
other
:
String
)
=
other
.
compareTo
(
stringValue
!!
)
}
internal
class
FriendFlashImageImpl
(
override
val
image
:
FriendImage
)
:
AbstractFriendFlashImage
()
{
private
val
stringValue
=
"flash"
override
fun
toString
()
=
stringValue
override
val
length
=
stringValue
.
length
override
fun
get
(
index
:
Int
)
=
stringValue
.
get
(
index
)
override
fun
subSequence
(
startIndex
:
Int
,
endIndex
:
Int
)
=
stringValue
.
subSequence
(
startIndex
,
endIndex
)
override
fun
compareTo
(
other
:
String
)
=
other
.
compareTo
(
stringValue
)
}
internal
fun
GroupFlashImageImpl
.
toJceData
()
=
ImMsgBody
.
Elem
(
commonElem
=
ImMsgBody
.
CommonElem
(
commonElem
=
ImMsgBody
.
CommonElem
(
serviceType
=
3
,
serviceType
=
3
,
businessType
=
0
,
businessType
=
0
,
...
@@ -68,7 +21,7 @@ internal fun GroupFlashImageImpl.toJceData() = ImMsgBody.Elem(
...
@@ -68,7 +21,7 @@ internal fun GroupFlashImageImpl.toJceData() = ImMsgBody.Elem(
)
)
)
)
internal
fun
FriendFlashImage
Impl
.
toJceData
()
=
ImMsgBody
.
Elem
(
internal
fun
FriendFlashImage
.
toJceData
()
=
ImMsgBody
.
Elem
(
commonElem
=
ImMsgBody
.
CommonElem
(
commonElem
=
ImMsgBody
.
CommonElem
(
serviceType
=
3
,
serviceType
=
3
,
businessType
=
0
,
businessType
=
0
,
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/FlashImage.kt
View file @
985b0b4b
@
file
:
Suppress
(
"NOTHING_TO_INLINE"
,
"unused"
)
package
net.mamoe.mirai.message.data
package
net.mamoe.mirai.message.data
import
net.mamoe.mirai.utils.SinceMirai
import
kotlin.jvm.JvmSynthetic
/**
* 闪照
*
* @see Image.flash
*/
@SinceMirai
(
""
)
sealed
class
FlashImage
:
MessageContent
{
sealed
class
FlashImage
:
MessageContent
{
companion
object
Key
:
Message
.
Key
<
FlashImage
>
companion
object
Key
:
Message
.
Key
<
FlashImage
>
{
operator
fun
invoke
(
image
:
Image
):
FlashImage
{
return
when
(
image
)
{
is
GroupImage
->
GroupFlashImage
(
image
)
is
FriendImage
->
FriendFlashImage
(
image
)
else
->
throw
IllegalArgumentException
(
"不支持的图片类型(Please use GroupImage or FriendImage)"
)
}
}
}
abstract
val
image
:
Image
/**
}
* 闪照的图片, 不同于普通的图片.
*/
abstract
val
image
:
Image
private
var
stringValue
:
String
?
=
null
get
()
{
return
field
?:
kotlin
.
run
{
field
=
"[mirai:flash:${image.imageId}]"
field
}
}
abstract
class
AbstractGroupFlashImage
:
FlashImage
()
{
override
fun
toString
():
String
=
stringValue
!!
abstract
override
val
image
:
GroupImage
override
val
length
:
Int
get
()
=
stringValue
!!
.
length
override
fun
get
(
index
:
Int
)
=
stringValue
!!
[
index
]
override
fun
subSequence
(
startIndex
:
Int
,
endIndex
:
Int
)
=
stringValue
!!
.
subSequence
(
startIndex
,
endIndex
)
override
fun
compareTo
(
other
:
String
)
=
other
.
compareTo
(
stringValue
!!
)
}
}
abstract
class
AbstractFriendFlashImage
:
FlashImage
()
{
@JvmSynthetic
abstract
override
val
image
:
FriendImage
inline
fun
Image
.
flash
():
FlashImage
=
FlashImage
(
this
)
}
\ No newline at end of file
@JvmSynthetic
inline
fun
GroupImage
.
flash
():
GroupFlashImage
=
FlashImage
(
this
)
as
GroupFlashImage
@JvmSynthetic
inline
fun
FriendImage
.
flash
():
FriendFlashImage
=
FlashImage
(
this
)
as
FriendFlashImage
class
GroupFlashImage
internal
constructor
(
override
val
image
:
GroupImage
)
:
FlashImage
()
class
FriendFlashImage
internal
constructor
(
override
val
image
:
FriendImage
)
:
FlashImage
()
\ No newline at end of file
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