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
0a4fb48c
Commit
0a4fb48c
authored
Feb 29, 2020
by
jasonczc
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
16fc510f
0cbc0f0e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
3 deletions
+74
-3
.editorconfig
.editorconfig
+2
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
...ommonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
+1
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscribeMessages.kt
...monMain/kotlin/net.mamoe.mirai/event/subscribeMessages.kt
+71
-2
No files found.
.editorconfig
0 → 100644
View file @
0a4fb48c
[*.{kt, kts}]
max_line_length = 120
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
View file @
0a4fb48c
...
@@ -300,7 +300,7 @@ internal class MemberImpl(
...
@@ -300,7 +300,7 @@ internal class MemberImpl(
@Suppress
(
"DuplicatedCode"
)
@Suppress
(
"DuplicatedCode"
)
override
fun
equals
(
other
:
Any
?):
Boolean
{
// 不要删除. trust me
override
fun
equals
(
other
:
Any
?):
Boolean
{
// 不要删除. trust me
if
(
this
===
other
)
return
true
if
(
this
===
other
)
return
true
if
(
other
!
is
Contact
)
return
false
if
(
other
!
is
Member
)
return
false
if
(
this
::
class
!= other::class) return false
if
(
this
::
class
!= other::class) return false
return this.id == other.id && this.bot == other.bot
return this.id == other.id && this.bot == other.bot
}
}
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscribeMessages.kt
View file @
0a4fb48c
...
@@ -324,7 +324,7 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
...
@@ -324,7 +324,7 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
content
{
sub
in
it
}
content
{
sub
in
it
}
/**
/**
* 如果消息内容包含 [sub]
* 如果消息内容包含 [sub]
中的任意一个元素
*/
*/
@MessageDsl
@MessageDsl
inline
fun
contains
(
inline
fun
contains
(
...
@@ -345,6 +345,72 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
...
@@ -345,6 +345,72 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
}
}
}
}
/**
* 如果消息内容包含 [sub]
*/
@MessageDsl
fun
containsAny
(
vararg
sub
:
String
):
ListeningFilter
=
content
{
sub
.
any
{
item
->
item
in
it
}
}
/**
* 如果消息内容包含 [sub] 中的任意一个元素
*/
@MessageDsl
inline
fun
containsAny
(
vararg
sub
:
String
,
ignoreCase
:
Boolean
=
false
,
trim
:
Boolean
=
true
,
crossinline
onEvent
:
MessageListener
<
T
>
):
Listener
<
T
>
{
return
if
(
trim
)
{
val
list
=
sub
.
map
{
it
.
trim
()
}
content
({
list
.
any
{
toCheck
->
it
.
contains
(
toCheck
,
ignoreCase
=
ignoreCase
)
}
},
{
onEvent
(
this
,
this
.
message
.
toString
().
trim
())
})
}
else
{
content
({
sub
.
any
{
toCheck
->
it
.
contains
(
toCheck
,
ignoreCase
=
ignoreCase
)
}
},
{
onEvent
(
this
,
this
.
message
.
toString
())
})
}
}
/**
* 如果消息内容包含 [sub]
*/
@MessageDsl
fun
containsAll
(
vararg
sub
:
String
):
ListeningFilter
=
content
{
sub
.
all
{
item
->
item
in
it
}
}
/**
* 如果消息内容包含 [sub] 中的任意一个元素
*/
@MessageDsl
inline
fun
containsAll
(
vararg
sub
:
String
,
ignoreCase
:
Boolean
=
false
,
trim
:
Boolean
=
true
,
crossinline
onEvent
:
MessageListener
<
T
>
):
Listener
<
T
>
{
return
if
(
trim
)
{
val
list
=
sub
.
map
{
it
.
trim
()
}
content
({
list
.
all
{
toCheck
->
it
.
contains
(
toCheck
,
ignoreCase
=
ignoreCase
)
}
},
{
onEvent
(
this
,
this
.
message
.
toString
().
trim
())
})
}
else
{
content
({
sub
.
all
{
toCheck
->
it
.
contains
(
toCheck
,
ignoreCase
=
ignoreCase
)
}
},
{
onEvent
(
this
,
this
.
message
.
toString
())
})
}
}
/**
/**
* 如果消息的前缀是 [prefix]
* 如果消息的前缀是 [prefix]
*/
*/
...
@@ -538,7 +604,10 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
...
@@ -538,7 +604,10 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
* 如果 [filter] 返回 `true` 就执行 `onEvent`
* 如果 [filter] 返回 `true` 就执行 `onEvent`
*/
*/
@MessageDsl
@MessageDsl
inline
fun
content
(
crossinline
filter
:
T
.(
String
)
->
Boolean
,
crossinline
onEvent
:
MessageListener
<
T
>):
Listener
<
T
>
=
inline
fun
content
(
crossinline
filter
:
T
.(
String
)
->
Boolean
,
crossinline
onEvent
:
MessageListener
<
T
>
):
Listener
<
T
>
=
subscriber
{
subscriber
{
if
(
filter
(
this
,
it
))
onEvent
(
this
,
it
)
if
(
filter
(
this
,
it
))
onEvent
(
this
,
it
)
}
}
...
...
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