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
550b4e86
Commit
550b4e86
authored
Oct 24, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inline MessageChain
parent
7892333c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
10 deletions
+3
-10
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/Message.kt
.../src/commonMain/kotlin/net.mamoe.mirai/message/Message.kt
+3
-3
mirai-demos/mirai-demo-1/src/main/java/demo1/Main.kt
mirai-demos/mirai-demo-1/src/main/java/demo1/Main.kt
+0
-7
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/Message.kt
View file @
550b4e86
...
...
@@ -139,13 +139,13 @@ inline class Face(val id: FaceID) : Message {
* - 若一个 [MessageChain] 与一个其他 [Message] 连接, [Message] 将会被添加入 [MessageChain].
* - 若一个 [Message] 与一个 [MessageChain] 连接, 将会创建一个新的 [MessageChain], 并顺序添加连接时的参数.
*/
data class
MessageChain
constructor
(
//todo 优化: 不构造 list. 而是在每个 Message 内写 head 和 tail 来连接.
inline
class
MessageChain
constructor
(
/**
* Elements will not be instances of [MessageChain]
*/
private
val
delegate
:
MutableList
<
Message
>
)
:
Message
,
MutableList
<
Message
>
{
constructor
()
:
this
(
mutableListOf
(
))
constructor
()
:
this
(
ArrayList
(
8
))
constructor
(
vararg
messages
:
Message
)
:
this
(
messages
.
toMutableList
())
constructor
(
messages
:
Iterable
<
Message
>)
:
this
(
messages
.
toMutableList
())
...
...
@@ -203,6 +203,6 @@ data class MessageChain constructor(//todo 优化: 不构造 list. 而是在每
override
fun
subList
(
fromIndex
:
Int
,
toIndex
:
Int
):
MutableList
<
Message
>
=
delegate
.
subList
(
fromIndex
,
toIndex
)
override
fun
iterator
():
MutableIterator
<
Message
>
=
delegate
.
iterator
()
override
operator
fun
contains
(
element
:
Message
):
Boolean
=
delegate
.
contains
(
element
)
override
val
size
:
Int
=
delegate
.
size
override
val
size
:
Int
get
()
=
delegate
.
size
// endregion
}
\ No newline at end of file
mirai-demos/mirai-demo-1/src/main/java/demo1/Main.kt
View file @
550b4e86
...
...
@@ -140,13 +140,6 @@ suspend fun main() = coroutineScope {
}
}
//通过 KClass 扩展方式监听事件(不推荐)
GroupMessageEvent
::
class
.
subscribeAlways
{
when
{
it
.
message
.
contains
(
"复读"
)
->
it
.
reply
(
it
.
message
)
}
}
//DSL 监听
subscribeAll
<
FriendMessageEvent
>
{
...
...
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