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
47c26e43
Commit
47c26e43
authored
Feb 16, 2020
by
jiahua.liu
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
e971fd76
71b1fb34
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
107 additions
and
14 deletions
+107
-14
gradle.properties
gradle.properties
+1
-1
mirai-console-graphical/build.gradle.kts
mirai-console-graphical/build.gradle.kts
+4
-0
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt
...otlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt
+17
-0
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/controller/MiraiController.kt
...moe/mirai/console/graphical/controller/MiraiController.kt
+31
-0
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/PrimaryView.kt
...lin/net/mamoe/mirai/console/graphical/view/PrimaryView.kt
+11
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/MessageSubscribers.kt
...onMain/kotlin/net.mamoe.mirai/event/MessageSubscribers.kt
+38
-13
mirai-japt/build.gradle.kts
mirai-japt/build.gradle.kts
+5
-0
No files found.
gradle.properties
View file @
47c26e43
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
kotlin.code.style
=
official
kotlin.code.style
=
official
# config
# config
mirai_version
=
0.15.1
mirai_version
=
0.15.1
mirai_japt_version
=
1.0.
0
mirai_japt_version
=
1.0.
1
kotlin.incremental.multiplatform
=
true
kotlin.incremental.multiplatform
=
true
kotlin.parallel.tasks.in.project
=
true
kotlin.parallel.tasks.in.project
=
true
# kotlin
# kotlin
...
...
mirai-console-graphical/build.gradle.kts
View file @
47c26e43
...
@@ -31,4 +31,8 @@ dependencies {
...
@@ -31,4 +31,8 @@ dependencies {
api
(
group
=
"no.tornado"
,
name
=
"tornadofx"
,
version
=
"1.7.19"
)
api
(
group
=
"no.tornado"
,
name
=
"tornadofx"
,
version
=
"1.7.19"
)
api
(
"org.bouncycastle:bcprov-jdk15on:1.64"
)
api
(
"org.bouncycastle:bcprov-jdk15on:1.64"
)
// classpath is not set correctly by IDE
// classpath is not set correctly by IDE
}
tasks
.
withType
<
org
.
jetbrains
.
kotlin
.
gradle
.
tasks
.
KotlinCompile
>
{
kotlinOptions
.
jvmTarget
=
"1.8"
}
}
\ No newline at end of file
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt
0 → 100644
View file @
47c26e43
package
net.mamoe.mirai.console.graphical
import
net.mamoe.mirai.console.graphical.view.PrimaryView
import
tornadofx.App
import
tornadofx.launch
fun
main
(
args
:
Array
<
String
>)
{
launch
<
MainApp
>(
args
)
}
class
MainApp
:
App
(
PrimaryView
::
class
)
{
override
fun
init
()
{
super
.
init
()
}
}
\ No newline at end of file
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/controller/MiraiController.kt
0 → 100644
View file @
47c26e43
package
net.mamoe.mirai.console.graphical.controller
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.console.MiraiConsoleUI
import
tornadofx.Controller
class
MiraiController
:
Controller
(),
MiraiConsoleUI
{
override
fun
pushLog
(
identity
:
Long
,
message
:
String
)
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
override
fun
prePushBot
(
identity
:
Long
)
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
override
fun
pushBot
(
bot
:
Bot
)
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
override
fun
pushVersion
(
consoleVersion
:
String
,
consoleBuild
:
String
,
coreVersion
:
String
)
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
override
suspend
fun
requestInput
(
question
:
String
):
String
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
override
fun
pushBotAdminStatus
(
identity
:
Long
,
admins
:
List
<
Long
>)
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
}
\ No newline at end of file
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/view/PrimaryView.kt
0 → 100644
View file @
47c26e43
package
net.mamoe.mirai.console.graphical.view
import
tornadofx.View
import
tornadofx.borderpane
class
PrimaryView
:
View
()
{
override
val
root
=
borderpane
{
}
}
\ No newline at end of file
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/MessageSubscribers.kt
View file @
47c26e43
...
@@ -477,26 +477,45 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
...
@@ -477,26 +477,45 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
}
}
/**
/**
* 如果消息内容可由正则表达式匹配([Regex.matchEntire])
, 就执行 `onEvent`
* 如果消息内容可由正则表达式匹配([Regex.matchEntire])
*/
*/
@MessageDsl
@MessageDsl
fun
matching
(
regex
:
Regex
):
ListeningFilter
=
fun
matching
(
regex
:
Regex
):
ListeningFilter
=
content
{
regex
.
matchEntire
(
it
)
!=
null
}
content
{
regex
.
matchEntire
(
it
)
!=
null
}
/**
/**
* 如果
[filter] 返回 `true`
就执行 `onEvent`
* 如果
消息内容可由正则表达式匹配([Regex.matchEntire]),
就执行 `onEvent`
*/
*/
@MessageDsl
@MessageDsl
inline
fun
matching
(
regex
:
Regex
,
crossinline
onEvent
:
MessageListener
<
T
>):
Listener
<
T
>
=
inline
fun
matching
(
regex
:
Regex
,
crossinline
onEvent
:
@MessageDsl
suspend
T
.(
MatchResult
)
->
Unit
):
Listener
<
T
>
=
content
({
regex
.
matchEntire
(
it
)
!=
null
},
onEvent
)
always
{
val
find
=
regex
.
matchEntire
(
it
)
?:
return
@
always
@Suppress
(
"DSL_SCOPE_VIOLATION_WARNING"
)
this
.
executeAndReply
{
onEvent
.
invoke
(
this
,
find
)
}
}
/**
/**
* 如果消息内容可由正则表达式查找([Regex.find])
, 就执行 `onEvent`
* 如果消息内容可由正则表达式查找([Regex.find])
*/
*/
@MessageDsl
@MessageDsl
fun
finding
(
regex
:
Regex
):
ListeningFilter
=
fun
finding
(
regex
:
Regex
):
ListeningFilter
=
content
{
regex
.
find
(
it
)
!=
null
}
content
{
regex
.
find
(
it
)
!=
null
}
/**
* 如果消息内容可由正则表达式查找([Regex.find]), 就执行 `onEvent`
*/
@MessageDsl
inline
fun
finding
(
regex
:
Regex
,
crossinline
onEvent
:
@MessageDsl
suspend
T
.(
MatchResult
)
->
Unit
):
Listener
<
T
>
=
always
{
val
find
=
regex
.
find
(
it
)
?:
return
@
always
@Suppress
(
"DSL_SCOPE_VIOLATION_WARNING"
)
this
.
executeAndReply
{
onEvent
.
invoke
(
this
,
find
)
}
}
/**
/**
* 若消息内容包含 [this] 则回复 [reply]
* 若消息内容包含 [this] 则回复 [reply]
...
@@ -527,11 +546,14 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
...
@@ -527,11 +546,14 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
* @param replier 若返回 [Message] 则直接发送; 若返回 [Unit] 则不回复; 其他情况则 [Any.toString] 后回复
* @param replier 若返回 [Message] 则直接发送; 若返回 [Unit] 则不回复; 其他情况则 [Any.toString] 后回复
*/
*/
@MessageDsl
@MessageDsl
inline
infix
fun
Regex
.
matchingReply
(
crossinline
replier
:
@MessageDsl
suspend
T
.(
String
)
->
Any
?):
Listener
<
T
>
=
inline
infix
fun
Regex
.
matchingReply
(
crossinline
replier
:
@MessageDsl
suspend
T
.(
MatchResult
)
->
Any
?):
Listener
<
T
>
=
content
({
this
@
matchingReply
.
matchEntire
(
it
)
!=
null
},
{
always
{
val
find
=
this
@
matchingReply
.
matchEntire
(
it
)
?:
return
@
always
@Suppress
(
"DSL_SCOPE_VIOLATION_WARNING"
)
@Suppress
(
"DSL_SCOPE_VIOLATION_WARNING"
)
this
.
executeAndReply
(
replier
)
this
.
executeAndReply
{
})
replier
.
invoke
(
this
,
find
)
}
}
/**
/**
* 若消息内容可由正则表达式查找([Regex.find]), 则执行 [replier] 并将其返回值回复给发信对象.
* 若消息内容可由正则表达式查找([Regex.find]), 则执行 [replier] 并将其返回值回复给发信对象.
...
@@ -541,11 +563,14 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
...
@@ -541,11 +563,14 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
* @param replier 若返回 [Message] 则直接发送; 若返回 [Unit] 则不回复; 其他情况则 [Any.toString] 后回复
* @param replier 若返回 [Message] 则直接发送; 若返回 [Unit] 则不回复; 其他情况则 [Any.toString] 后回复
*/
*/
@MessageDsl
@MessageDsl
inline
infix
fun
Regex
.
findingReply
(
crossinline
replier
:
@MessageDsl
suspend
T
.(
String
)
->
Any
?):
Listener
<
T
>
=
inline
infix
fun
Regex
.
findingReply
(
crossinline
replier
:
@MessageDsl
suspend
T
.(
MatchResult
)
->
Any
?):
Listener
<
T
>
=
content
({
this
@
findingReply
.
find
(
it
)
!=
null
},
{
always
{
val
find
=
this
@
findingReply
.
find
(
it
)
?:
return
@
always
@Suppress
(
"DSL_SCOPE_VIOLATION_WARNING"
)
@Suppress
(
"DSL_SCOPE_VIOLATION_WARNING"
)
this
.
executeAndReply
(
replier
)
this
.
executeAndReply
{
})
replier
.
invoke
(
this
,
find
)
}
}
/**
/**
* 不考虑空格, 若消息内容以 [this] 开始则执行 [replier] 并将其返回值回复给发信对象.
* 不考虑空格, 若消息内容以 [this] 开始则执行 [replier] 并将其返回值回复给发信对象.
...
...
mirai-japt/build.gradle.kts
View file @
47c26e43
...
@@ -39,6 +39,11 @@ description = "Java helper for Mirai"
...
@@ -39,6 +39,11 @@ description = "Java helper for Mirai"
val
mirai_japt_version
:
String
by
rootProject
.
ext
val
mirai_japt_version
:
String
by
rootProject
.
ext
version
=
mirai_japt_version
version
=
mirai_japt_version
java
{
sourceCompatibility
=
JavaVersion
.
VERSION_1_8
targetCompatibility
=
JavaVersion
.
VERSION_1_8
}
kotlin
{
kotlin
{
sourceSets
{
sourceSets
{
all
{
all
{
...
...
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