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
1258746e
Commit
1258746e
authored
Apr 20, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `BotConfiguration.inheritCoroutineContext`
parent
162dfb7c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.kt
...mmonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.kt
+25
-0
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.kt
View file @
1258746e
...
@@ -14,6 +14,7 @@ import net.mamoe.mirai.Bot
...
@@ -14,6 +14,7 @@ import net.mamoe.mirai.Bot
import
net.mamoe.mirai.network.BotNetworkHandler
import
net.mamoe.mirai.network.BotNetworkHandler
import
kotlin.coroutines.CoroutineContext
import
kotlin.coroutines.CoroutineContext
import
kotlin.coroutines.EmptyCoroutineContext
import
kotlin.coroutines.EmptyCoroutineContext
import
kotlin.coroutines.coroutineContext
import
kotlin.jvm.JvmOverloads
import
kotlin.jvm.JvmOverloads
import
kotlin.jvm.JvmStatic
import
kotlin.jvm.JvmStatic
...
@@ -84,6 +85,7 @@ open class BotConfiguration {
...
@@ -84,6 +85,7 @@ open class BotConfiguration {
/**
/**
* 不显示网络日志
* 不显示网络日志
*/
*/
@ConfigurationDsl
fun
noNetworkLog
()
{
fun
noNetworkLog
()
{
networkLoggerSupplier
=
{
_
:
BotNetworkHandler
->
SilentLogger
}
networkLoggerSupplier
=
{
_
:
BotNetworkHandler
->
SilentLogger
}
}
}
...
@@ -93,10 +95,33 @@ open class BotConfiguration {
...
@@ -93,10 +95,33 @@ open class BotConfiguration {
*
*
* 此函数只在 JVM 有效. 在其他平台将会导致一直使用默认的随机的设备信息.
* 此函数只在 JVM 有效. 在其他平台将会导致一直使用默认的随机的设备信息.
*/
*/
@ConfigurationDsl
@JvmOverloads
@JvmOverloads
fun
fileBasedDeviceInfo
(
filename
:
String
=
"device.json"
)
{
fun
fileBasedDeviceInfo
(
filename
:
String
=
"device.json"
)
{
deviceInfo
=
getFileBasedDeviceInfoSupplier
(
filename
)
deviceInfo
=
getFileBasedDeviceInfoSupplier
(
filename
)
}
}
/**
* 使用当前协程的 [coroutineContext] 作为 [parentCoroutineContext]
*
* 用例:
* ```
* coroutineScope {
* val bot = Bot(...)
* bot.login()
* } // coroutineScope 会等待 Bot 退出
* ```
*/
@ConfigurationDsl
@SinceMirai
(
"0.38.0"
)
suspend
fun
inheritCoroutineContext
()
{
parentCoroutineContext
=
coroutineContext
}
@SinceMirai
(
"0.38.0"
)
@DslMarker
annotation
class
ConfigurationDsl
}
}
@OptIn
(
ExperimentalMultiplatform
::
class
)
@OptIn
(
ExperimentalMultiplatform
::
class
)
...
...
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