mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-22 05:10:09 +08:00
Close #450: add BotConfiguration.loadDeviceInfoJson
This commit is contained in:
parent
ac91e77b5f
commit
5607301244
@ -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}" }
|
||||
|
Loading…
Reference in New Issue
Block a user