BotConfiguration

expect open class BotConfiguration

Bot 配置. 用于 BotFactory.newBot

Kotlin 使用方法:

val bot = BotFactory.newBot(...) {
// 在这里配置 Bot

bogLoggerSupplier = { bot -> ... }
fileBasedDeviceInfo()
inheritCoroutineContext() // 使用 `coroutineScope` 的 Job 作为父 Job
}

Java 使用方法:

Bot bot = BotFactory.newBot(..., new BotConfiguration() {{
setBogLoggerSupplier((Bot bot) -> { ... })
fileBasedDeviceInfo()
...
}})
actual open class BotConfiguration

Bot 配置. 用于 BotFactory.newBot

Kotlin 使用方法:

val bot = BotFactory.newBot(...) {
// 在这里配置 Bot

bogLoggerSupplier = { bot -> ... }
fileBasedDeviceInfo()
inheritCoroutineContext() // 使用 `coroutineScope` 的 Job 作为父 Job
}

Java 使用方法:

Bot bot = BotFactory.newBot(..., new BotConfiguration() {{
setBogLoggerSupplier((Bot bot) -> { ... })
fileBasedDeviceInfo()
...
}})
actual open class BotConfiguration

Bot 配置. 用于 BotFactory.newBot

Kotlin 使用方法:

val bot = BotFactory.newBot(...) {
// 在这里配置 Bot

bogLoggerSupplier = { bot -> ... }
fileBasedDeviceInfo()
inheritCoroutineContext() // 使用 `coroutineScope` 的 Job 作为父 Job
}

Java 使用方法:

Bot bot = BotFactory.newBot(..., new BotConfiguration() {{
setBogLoggerSupplier((Bot bot) -> { ... })
fileBasedDeviceInfo()
...
}})

Constructors

Link copied to clipboard
expect fun BotConfiguration()
fun BotConfiguration()
fun BotConfiguration()

Types

Link copied to clipboard
expect object Companion
actual object Companion
actual object Companion
Link copied to clipboard
expect annotation class ConfigurationDsl

标注一个配置 DSL 函数

actual annotation class ConfigurationDsl

标注一个配置 DSL 函数

actual annotation class ConfigurationDsl

标注一个配置 DSL 函数

Link copied to clipboard
expect class ContactListCache

联系人信息缓存配置

actual class ContactListCache

联系人信息缓存配置

actual class ContactListCache

联系人信息缓存配置

Link copied to clipboard
expect enum HeartbeatStrategy : Enum<BotConfiguration.HeartbeatStrategy>

心跳策略.

actual enum HeartbeatStrategy : Enum<BotConfiguration.HeartbeatStrategy>

心跳策略.

actual enum HeartbeatStrategy : Enum<BotConfiguration.HeartbeatStrategy>

心跳策略.

Link copied to clipboard
expect enum MiraiProtocol : Enum<BotConfiguration.MiraiProtocol>
actual enum MiraiProtocol : Enum<BotConfiguration.MiraiProtocol>
actual enum MiraiProtocol : Enum<BotConfiguration.MiraiProtocol>

Functions

Link copied to clipboard
expect fun autoReconnectOnForceOffline()

设置 autoReconnectOnForceOfflinetrue, 即在被挤下线时自动重连.

actual fun autoReconnectOnForceOffline()

设置 autoReconnectOnForceOfflinetrue, 即在被挤下线时自动重连.

actual fun autoReconnectOnForceOffline()

设置 autoReconnectOnForceOfflinetrue, 即在被挤下线时自动重连.

Link copied to clipboard
expect inline fun contactListCache(action: BotConfiguration.ContactListCache.() -> Unit)
actual inline fun contactListCache(action: BotConfiguration.ContactListCache.() -> Unit)
actual inline fun contactListCache(action: BotConfiguration.ContactListCache.() -> Unit)
Link copied to clipboard
expect fun copy(): BotConfiguration
actual fun copy(): BotConfiguration
actual fun copy(): BotConfiguration
Link copied to clipboard
expect fun disableAccountSecretes()

禁止保存 account.secrets.

actual fun disableAccountSecretes()

禁止保存 account.secrets.

actual fun disableAccountSecretes()

禁止保存 account.secrets.

Link copied to clipboard
expect fun disableContactCache()

禁用好友列表和群成员列表的缓存.

actual fun disableContactCache()

禁用好友列表和群成员列表的缓存.

actual fun disableContactCache()

禁用好友列表和群成员列表的缓存.

Link copied to clipboard
expect fun enableContactCache()

启用好友列表和群成员列表的缓存.

actual fun enableContactCache()

启用好友列表和群成员列表的缓存.

actual fun enableContactCache()

启用好友列表和群成员列表的缓存.

Link copied to clipboard
expect fun fileBasedDeviceInfo(filepath: String = "device.json")

使用文件存储设备信息.

actual fun fileBasedDeviceInfo(filepath: String)

使用文件存储设备信息.

actual fun fileBasedDeviceInfo(filepath: String)

使用文件存储设备信息.

Link copied to clipboard
expect inline suspend fun inheritCoroutineContext()

使用当前协程的 coroutineContext 作为 parentCoroutineContext.

actual inline suspend fun inheritCoroutineContext()

使用当前协程的 coroutineContext 作为 parentCoroutineContext.

actual inline suspend fun inheritCoroutineContext()

使用当前协程的 coroutineContext 作为 parentCoroutineContext.

Link copied to clipboard
expect fun loadDeviceInfoJson(json: String)

使用特定由 DeviceInfo 序列化产生的 JSON 的设备信息

actual fun loadDeviceInfoJson(json: String)

使用特定由 DeviceInfo 序列化产生的 JSON 的设备信息

actual fun loadDeviceInfoJson(json: String)

使用特定由 DeviceInfo 序列化产生的 JSON 的设备信息

Link copied to clipboard
expect fun noBotLog()

不显示 Bot 日志. 不推荐.

actual fun noBotLog()

不显示 Bot 日志. 不推荐.

actual fun noBotLog()

不显示 Bot 日志. 不推荐.

Link copied to clipboard
expect fun noNetworkLog()

不显示网络日志. 不推荐.

actual fun noNetworkLog()

不显示网络日志. 不推荐.

actual fun noNetworkLog()

不显示网络日志. 不推荐.

Link copied to clipboard
expect fun randomDeviceInfo()

使用随机设备信息.

actual fun randomDeviceInfo()

使用随机设备信息.

actual fun randomDeviceInfo()

使用随机设备信息.

Link copied to clipboard
fun redirectBotLogToDirectory(    dir: File = File("logs"),     retain: Long = 1.weeksToMillis,     identity: (bot: Bot) -> String = { "Bot ${it.id}" })

重定向 Bot 日志 到指定目录. 若目录不存在将会自动创建 (File.mkdirs)

Link copied to clipboard
fun redirectBotLogToFile(file: File = File("mirai.log"), identity: (bot: Bot) -> String = { "Bot ${it.id}" })

重定向 Bot 日志 到指定文件. 日志将会逐行追加到此文件. 若文件不存在将会自动创建 (File.createNewFile)

Link copied to clipboard
fun redirectNetworkLogToDirectory(    dir: File = File("logs"),     retain: Long = 1.weeksToMillis,     identity: (bot: Bot) -> String = { "Net ${it.id}" })

重定向 网络日志 到指定目录. 若目录不存在将会自动创建 (File.mkdirs) 默认目录路径为 "$workingDir/logs/".

Link copied to clipboard
fun redirectNetworkLogToFile(file: File = File("mirai.log"), identity: (bot: Bot) -> String = { "Net ${it.id}" })

重定向 网络日志 到指定文件. 默认文件路径为 "$workingDir/mirai.log". 日志将会逐行追加到此文件. 若文件不存在将会自动创建 (File.createNewFile)

Properties

Link copied to clipboard
expect var autoReconnectOnForceOffline: Boolean

在被挤下线时 (BotOfflineEvent.Force) 自动重连. 默认为 false.

actual var autoReconnectOnForceOffline: Boolean = false

在被挤下线时 (BotOfflineEvent.Force) 自动重连. 默认为 false.

actual var autoReconnectOnForceOffline: Boolean = false

在被挤下线时 (BotOfflineEvent.Force) 自动重连. 默认为 false.

Link copied to clipboard
expect var botLoggerSupplier: (Bot) -> MiraiLogger

日志记录器

actual var botLoggerSupplier: (Bot) -> MiraiLogger

日志记录器

actual var botLoggerSupplier: (Bot) -> MiraiLogger

日志记录器

Link copied to clipboard
var cacheDir: File

缓存数据目录, 相对于 workingDir.

var cacheDir: String

缓存数据目录路径. 若 cacheDir 为绝对路径, 将解析该绝对路径, 否则作为相对于 workingDir 的路径解析. 例如, cache 将会解析为 $workingDir/cache, 而 /Users/Chisato/Desktop/bot/cache 指代绝对路径, 将解析为绝对路径.

Link copied to clipboard
expect var contactListCache: BotConfiguration.ContactListCache

联系人信息缓存配置. 将会保存在 cacheDir 中 contacts 目录

actual var contactListCache: BotConfiguration.ContactListCache

联系人信息缓存配置. 将会保存在 cacheDircontacts 目录

actual var contactListCache: BotConfiguration.ContactListCache

联系人信息缓存配置. 将会保存在 cacheDircontacts 目录

Link copied to clipboard
@get:JvmName(name = "isConvertLineSeparator")
expect var convertLineSeparator: Boolean

是否处理接受到的特殊换行符, 默认为 true

@get:JvmName(name = "isConvertLineSeparator")
actual var convertLineSeparator: Boolean = true

是否处理接受到的特殊换行符, 默认为 true

actual var convertLineSeparator: Boolean = true

是否处理接受到的特殊换行符, 默认为 true

Link copied to clipboard
expect var deviceInfo: (Bot) -> DeviceInfo?

设备信息覆盖. 在没有手动指定时将会通过日志警告, 并使用随机设备信息.

actual var deviceInfo: (Bot) -> DeviceInfo?

设备信息覆盖. 在没有手动指定时将会通过日志警告, 并使用随机设备信息.

actual var deviceInfo: (Bot) -> DeviceInfo?

设备信息覆盖. 在没有手动指定时将会通过日志警告, 并使用随机设备信息.

Link copied to clipboard
expect var heartbeatPeriodMillis: Long

连接心跳包周期. 过长会导致被服务器断开连接.

actual var heartbeatPeriodMillis: Long

连接心跳包周期. 过长会导致被服务器断开连接.

actual var heartbeatPeriodMillis: Long

连接心跳包周期. 过长会导致被服务器断开连接.

Link copied to clipboard
expect var heartbeatStrategy: BotConfiguration.HeartbeatStrategy

心跳策略.

actual var heartbeatStrategy: BotConfiguration.HeartbeatStrategy

心跳策略.

actual var heartbeatStrategy: BotConfiguration.HeartbeatStrategy

心跳策略.

Link copied to clipboard
expect var heartbeatTimeoutMillis: Long

每次心跳时等待结果的时间. 一旦心跳超时, 整个网络服务将会重启 (将消耗约 1s). 除正在进行的任务 (如图片上传) 会被中断外, 事件和插件均不受影响.

actual var heartbeatTimeoutMillis: Long

每次心跳时等待结果的时间. 一旦心跳超时, 整个网络服务将会重启 (将消耗约 1s). 除正在进行的任务 (如图片上传) 会被中断外, 事件和插件均不受影响.

actual var heartbeatTimeoutMillis: Long

每次心跳时等待结果的时间. 一旦心跳超时, 整个网络服务将会重启 (将消耗约 1s). 除正在进行的任务 (如图片上传) 会被中断外, 事件和插件均不受影响.

Link copied to clipboard
expect var highwayUploadCoroutineCount: Int

Highway 通道上传图片, 语音, 文件等资源时的协程数量.

actual var highwayUploadCoroutineCount: Int

Highway 通道上传图片, 语音, 文件等资源时的协程数量.

actual var highwayUploadCoroutineCount: Int

Highway 通道上传图片, 语音, 文件等资源时的协程数量.

Link copied to clipboard
expect var isShowingVerboseEventLog: Boolean

是否显示过于冗长的事件日志

actual var isShowingVerboseEventLog: Boolean = false

是否显示过于冗长的事件日志

actual var isShowingVerboseEventLog: Boolean = false

是否显示过于冗长的事件日志

Link copied to clipboard
expect var loginCacheEnabled: Boolean

登录缓存.

actual var loginCacheEnabled: Boolean = true

登录缓存.

actual var loginCacheEnabled: Boolean = true

登录缓存.

Link copied to clipboard
expect var loginSolver: LoginSolver?

验证码处理器

actual var loginSolver: LoginSolver?

验证码处理器

actual var loginSolver: LoginSolver?

验证码处理器

Link copied to clipboard
expect var networkLoggerSupplier: (Bot) -> MiraiLogger

网络层日志构造器

actual var networkLoggerSupplier: (Bot) -> MiraiLogger

网络层日志构造器

actual var networkLoggerSupplier: (Bot) -> MiraiLogger

网络层日志构造器

Link copied to clipboard
expect var parentCoroutineContext: CoroutineContext

CoroutineContext. Bot 创建后会使用 SupervisorJob 覆盖其 Job, 但会将这个 Job 作为父 Job

actual var parentCoroutineContext: CoroutineContext

CoroutineContext. Bot 创建后会使用 SupervisorJob 覆盖其 Job, 但会将这个 Job 作为父 Job

actual var parentCoroutineContext: CoroutineContext

CoroutineContext. Bot 创建后会使用 SupervisorJob 覆盖其 Job, 但会将这个 Job 作为父 Job

Link copied to clipboard
expect var protocol: BotConfiguration.MiraiProtocol

使用协议类型

actual var protocol: BotConfiguration.MiraiProtocol

使用协议类型

actual var protocol: BotConfiguration.MiraiProtocol

使用协议类型

Link copied to clipboard
expect var reconnectionRetryTimes: Int

最多尝试多少次重连

actual var reconnectionRetryTimes: Int

最多尝试多少次重连

actual var reconnectionRetryTimes: Int

最多尝试多少次重连

Link copied to clipboard
expect var statHeartbeatPeriodMillis: Long

状态心跳包周期. 过长会导致掉线. 该值会在登录时根据服务器下发的配置自动进行更新.

actual var statHeartbeatPeriodMillis: Long

状态心跳包周期. 过长会导致掉线. 该值会在登录时根据服务器下发的配置自动进行更新.

actual var statHeartbeatPeriodMillis: Long

状态心跳包周期. 过长会导致掉线. 该值会在登录时根据服务器下发的配置自动进行更新.

Link copied to clipboard
var workingDir: File

工作目录. 默认为 "."

var workingDir: String

工作目录. 默认为当前目录