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
b0888a27
Commit
b0888a27
authored
May 10, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `Message.plus` extensions instead of member functions
parent
4e187cc9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
3 deletions
+69
-3
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt
...commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt
+67
-1
mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/message/SubscribingGetTest.kt
...Test/kotlin/net/mamoe/mirai/message/SubscribingGetTest.kt
+2
-2
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt
View file @
b0888a27
...
...
@@ -7,18 +7,25 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
@
file
:
Suppress
(
"MemberVisibilityCanBePrivate"
,
"unused"
,
"EXPERIMENTAL_API_USAGE"
,
"NOTHING_TO_INLINE"
)
@
file
:
Suppress
(
"MemberVisibilityCanBePrivate"
,
"unused"
,
"EXPERIMENTAL_API_USAGE"
,
"NOTHING_TO_INLINE"
,
"INVISIBLE_MEMBER"
,
"INVISIBLE_REFERENCE"
)
@
file
:
JvmMultifileClass
@
file
:
JvmName
(
"MessageUtils"
)
package
net.mamoe.mirai.message.data
import
kotlinx.coroutines.flow.Flow
import
kotlinx.coroutines.flow.fold
import
net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.message.MessageEvent
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.data.Message.Key
import
net.mamoe.mirai.utils.PlannedRemoval
import
kotlin.contracts.contract
import
kotlin.internal.HidesMembers
import
kotlin.internal.LowPriorityInOverloadResolution
import
kotlin.jvm.JvmMultifileClass
import
kotlin.jvm.JvmName
import
kotlin.jvm.JvmSynthetic
...
...
@@ -178,12 +185,71 @@ interface Message { // must be interface. Don't consider any changes.
}
}
@LowPriorityInOverloadResolution
@PlannedRemoval
(
"1.2.0"
)
@JvmSynthetic
@Deprecated
(
"for binary compatibility"
,
level
=
DeprecationLevel
.
HIDDEN
)
operator
fun
plus
(
another
:
Message
):
MessageChain
=
this
.
followedBy
(
another
)
@PlannedRemoval
(
"1.2.0"
)
@LowPriorityInOverloadResolution
@JvmSynthetic
@Deprecated
(
"for binary compatibility"
,
level
=
DeprecationLevel
.
HIDDEN
)
operator
fun
plus
(
another
:
SingleMessage
):
MessageChain
=
this
.
followedBy
(
another
)
@PlannedRemoval
(
"1.2.0"
)
@JvmSynthetic
@LowPriorityInOverloadResolution
// won't be resolved
@Deprecated
(
"for binary compatibility"
,
level
=
DeprecationLevel
.
HIDDEN
)
operator
fun
plus
(
another
:
String
):
MessageChain
=
this
.
followedBy
(
another
.
toMessage
())
@PlannedRemoval
(
"1.2.0"
)
@LowPriorityInOverloadResolution
@JvmSynthetic
@Deprecated
(
"for binary compatibility"
,
level
=
DeprecationLevel
.
HIDDEN
)
operator
fun
plus
(
another
:
CharSequence
):
MessageChain
=
this
.
followedBy
(
another
.
toString
().
toMessage
())
}
@JvmSynthetic
@HidesMembers
inline
operator
fun
Message
.
plus
(
another
:
Message
):
MessageChain
=
this
.
followedBy
(
another
)
@HidesMembers
@JvmSynthetic
inline
operator
fun
Message
.
plus
(
another
:
SingleMessage
):
MessageChain
=
this
.
followedBy
(
another
)
@HidesMembers
@JvmSynthetic
inline
operator
fun
Message
.
plus
(
another
:
String
):
MessageChain
=
this
.
followedBy
(
another
.
toMessage
())
@HidesMembers
@JvmSynthetic
inline
operator
fun
Message
.
plus
(
another
:
CharSequence
):
MessageChain
=
this
.
followedBy
(
another
.
toString
().
toMessage
())
@HidesMembers
@JvmSynthetic
inline
operator
fun
Message
.
plus
(
another
:
Iterable
<
Message
>):
MessageChain
=
another
.
fold
(
this
,
Message
::
plus
).
asMessageChain
()
@JvmName
(
"plus1"
)
@HidesMembers
@JvmSynthetic
inline
operator
fun
Message
.
plus
(
another
:
Iterable
<
String
>):
MessageChain
=
another
.
fold
(
this
,
Message
::
plus
).
asMessageChain
()
@JvmSynthetic
@HidesMembers
inline
operator
fun
Message
.
plus
(
another
:
Sequence
<
Message
>):
MessageChain
=
another
.
fold
(
this
,
Message
::
plus
).
asMessageChain
()
@HidesMembers
@JvmSynthetic
inline
operator
fun
Message
.
plus
(
another
:
MessageChain
):
MessageChain
=
this
+
another
as
Message
@HidesMembers
@JvmSynthetic
suspend
inline
operator
fun
Message
.
plus
(
another
:
Flow
<
Message
>):
MessageChain
=
another
.
fold
(
this
)
{
acc
,
it
->
acc
+
it
}.
asMessageChain
()
/**
* [Message.contentToString] 的捷径
...
...
mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/message/SubscribingGetTest.kt
View file @
b0888a27
...
...
@@ -23,7 +23,7 @@ internal class SubscribingGetTest {
@Test
fun
testSyncFromEvent
()
{
runBlockingWithTimeout
(
5
000
)
{
runBlockingWithTimeout
(
10
000
)
{
suspendCancellableCoroutine
<
Unit
>
{
cont
->
launch
{
syncFromEvent
(
3000
)
{
_
:
TestEvent
->
...
...
@@ -31,7 +31,7 @@ internal class SubscribingGetTest {
}
}
launch
{
delay
(
1
000
)
delay
(
2
000
)
TestEvent
().
broadcast
()
}
}
...
...
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