Add BotConfiguration.disableAccountSecretes

This commit is contained in:
Him188 2022-05-02 14:01:44 +01:00
parent 115c987c2d
commit 4fa853065c
4 changed files with 27 additions and 7 deletions

View File

@ -5698,6 +5698,7 @@ public class net/mamoe/mirai/utils/BotConfiguration {
public final fun autoReconnectOnForceOffline ()V
public final synthetic fun contactListCache (Lkotlin/jvm/functions/Function1;)V
public final fun copy ()Lnet/mamoe/mirai/utils/BotConfiguration;
public final fun disableAccountSecretes ()V
public final fun disableContactCache ()V
public final fun enableContactCache ()V
public final fun fileBasedDeviceInfo ()V

View File

@ -5698,6 +5698,7 @@ public class net/mamoe/mirai/utils/BotConfiguration {
public final fun autoReconnectOnForceOffline ()V
public final synthetic fun contactListCache (Lkotlin/jvm/functions/Function1;)V
public final fun copy ()Lnet/mamoe/mirai/utils/BotConfiguration;
public final fun disableAccountSecretes ()V
public final fun disableContactCache ()V
public final fun enableContactCache ()V
public final fun fileBasedDeviceInfo ()V

View File

@ -300,6 +300,21 @@ public open class BotConfiguration { // open for Java
// Device
///////////////////////////////////////////////////////////////////////////
@JvmField
internal var accountSecrets: Boolean = true
/**
* 禁止保存 `account.secrets`.
*
* `account.secrets` 保存账号的会话信息
* 它可加速登录过程也可能可以减少出现验证码的次数如果遇到一段时间后无法接收消息通知等同步问题时可尝试禁用
*
* @since 2.11
*/
public fun disableAccountSecretes() {
accountSecrets = false
}
/**
* 设备信息覆盖. 在没有手动指定时将会通过日志警告, 并使用随机设备信息.
* @see fileBasedDeviceInfo 使用指定文件存储设备信息
@ -598,6 +613,7 @@ public open class BotConfiguration { // open for Java
new.loginSolver = loginSolver
new.protocol = protocol
new.highwayUploadCoroutineCount = highwayUploadCoroutineCount
new.accountSecrets = accountSecrets
new.deviceInfo = deviceInfo
new.botLoggerSupplier = botLoggerSupplier
new.networkLoggerSupplier = networkLoggerSupplier

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2022 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -250,11 +250,13 @@ internal class CombinedAccountSecretsManager(
* Create a [CombinedAccountSecretsManager] with [MemoryAccountSecretsManager] as primary and [FileCacheAccountSecretsManager] as an alternative.
*/
internal fun BotConfiguration.createAccountsSecretsManager(logger: MiraiLogger): AccountSecretsManager {
return CombinedAccountSecretsManager(
MemoryAccountSecretsManager(),
FileCacheAccountSecretsManager(
accountSecretsFile(),
logger
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
return if (accountSecrets) {
CombinedAccountSecretsManager(
MemoryAccountSecretsManager(),
FileCacheAccountSecretsManager(accountSecretsFile(), logger)
)
)
} else {
MemoryAccountSecretsManager()
}
}