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
e3add186
Commit
e3add186
authored
Apr 25, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `Message.isContentNotEmpty`
parent
97dda77f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt
...commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt
+14
-0
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt
View file @
e3add186
...
@@ -266,13 +266,27 @@ interface Message { // must be interface. Don't consider any changes.
...
@@ -266,13 +266,27 @@ interface Message { // must be interface. Don't consider any changes.
this
.
followedByInternalForBinaryCompatibility
(
another
.
toString
().
toMessage
())
this
.
followedByInternalForBinaryCompatibility
(
another
.
toString
().
toMessage
())
}
}
/**
* 判断消息内容是否为空.
*
* 以下情况视为 "空消息":
*
* - 是 [MessageMetadata] (因为 [MessageMetadata.contentToString] 都必须返回空字符串)
* - [PlainText] 长度为 0
* - [MessageChain] 所有元素都满足 [isContentEmpty]
*/
@SinceMirai
(
"0.39.3"
)
@SinceMirai
(
"0.39.3"
)
fun
Message
.
isContentEmpty
():
Boolean
=
when
(
this
)
{
fun
Message
.
isContentEmpty
():
Boolean
=
when
(
this
)
{
is
MessageMetadata
->
true
is
PlainText
->
this
.
isEmpty
()
is
PlainText
->
this
.
isEmpty
()
is
MessageChain
->
this
.
any
{
it
.
isContentEmpty
()
}
is
MessageChain
->
this
.
any
{
it
.
isContentEmpty
()
}
else
->
false
else
->
false
}
}
@SinceMirai
(
"0.39.3"
)
inline
fun
Message
.
isContentNotEmpty
():
Boolean
=
!
this
.
isContentEmpty
()
inline
fun
Message
.
isPlain
():
Boolean
=
this
is
PlainText
inline
fun
Message
.
isPlain
():
Boolean
=
this
is
PlainText
inline
fun
Message
.
isNotPlain
():
Boolean
=
this
!
is
PlainText
inline
fun
Message
.
isNotPlain
():
Boolean
=
this
!
is
PlainText
...
...
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