Commit 56073012 authored by Him188's avatar Him188

Close #450: add `BotConfiguration.loadDeviceInfoJson`

parent ac91e77b
......@@ -52,6 +52,12 @@ public expect open class BotConfiguration() : BotConfigurationBase {
@ConfigurationDsl
public fun randomDeviceInfo()
/**
* 使用特定由 [DeviceInfoData] 序列化产生的 JSON 的设备信息
*/
@SinceMirai("1.2.0")
public fun loadDeviceInfoJson(json: String)
/**
* 协议类型, 服务器仅允许使用不同协议同时登录.
*/
......
......@@ -51,10 +51,20 @@ public actual open class BotConfiguration : BotConfigurationBase() { // open for
* @see deviceInfo
*/
@ConfigurationDsl
public actual fun randomDeviceInfo() {
public actual fun randomDeviceInfo() {
deviceInfo = null
}
/**
* 使用特定由 [DeviceInfoData] 序列化产生的 JSON 的设备信息
*/
@SinceMirai("1.2.0")
public actual fun loadDeviceInfoJson(json: String) {
deviceInfo = { context ->
this.json.parse(DeviceInfoData.serializer(), json).also { it.context = context }
}
}
/**
* 重定向 [网络日志][networkLoggerSupplier] 到指定目录. 若目录不存在将会自动创建 ([File.mkdirs])
* @see DirectoryLogger
......@@ -63,7 +73,7 @@ public actual open class BotConfiguration : BotConfigurationBase() { // open for
@JvmOverloads
@ConfigurationDsl
@SinceMirai("1.1.0")
public fun redirectNetworkLogToDirectory(
public fun redirectNetworkLogToDirectory(
dir: File = File("logs"),
retain: Long = 1.weeksToMillis,
identity: (bot: Bot) -> String = { "Net ${it.id}" }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment