mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-08 17:20:11 +08:00
Add constructor-like BotConfiguration builder
This commit is contained in:
parent
8c88f0e44f
commit
f76e573b49
@ -15,6 +15,7 @@ import kotlinx.coroutines.Job
|
|||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import net.mamoe.mirai.Bot
|
import net.mamoe.mirai.Bot
|
||||||
|
import net.mamoe.mirai.BotFactory
|
||||||
import net.mamoe.mirai.event.events.BotOfflineEvent
|
import net.mamoe.mirai.event.events.BotOfflineEvent
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
@ -22,7 +23,7 @@ import kotlin.coroutines.EmptyCoroutineContext
|
|||||||
import kotlin.coroutines.coroutineContext
|
import kotlin.coroutines.coroutineContext
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [Bot] 配置.
|
* [Bot] 配置. 用于 [BotFactory.newBot]
|
||||||
*
|
*
|
||||||
* Kotlin 使用方法:
|
* Kotlin 使用方法:
|
||||||
* ```
|
* ```
|
||||||
@ -387,6 +388,15 @@ public open class BotConfiguration { // open for Java
|
|||||||
public annotation class ConfigurationDsl
|
public annotation class ConfigurationDsl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建一个 [BotConfiguration].
|
||||||
|
*
|
||||||
|
* @see BotConfiguration
|
||||||
|
*/
|
||||||
|
public inline fun BotConfiguration(block: BotConfiguration.() -> Unit): BotConfiguration {
|
||||||
|
return BotConfiguration().apply(block)
|
||||||
|
}
|
||||||
|
|
||||||
internal val deviceInfoStub: (Bot) -> DeviceInfo = {
|
internal val deviceInfoStub: (Bot) -> DeviceInfo = {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
MiraiLogger.TopLevel.warning("未指定设备信息, 已使用随机设备信息. 请查看 BotConfiguration.deviceInfo 以获取更多信息.")
|
MiraiLogger.TopLevel.warning("未指定设备信息, 已使用随机设备信息. 请查看 BotConfiguration.deviceInfo 以获取更多信息.")
|
||||||
|
Loading…
Reference in New Issue
Block a user