Skip to content

Commit

Permalink
migrate two wrap with the same JVM signature
Browse files Browse the repository at this point in the history
  • Loading branch information
MrXiaoM committed Aug 14, 2024
1 parent c70c8eb commit 24d5865
Showing 1 changed file with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,21 @@ internal class BotWrapper private constructor(
override fun toString(): String = "Bot($id)"

companion object {
internal suspend fun wrap(
impl: Bot,
botConfiguration: BotConfiguration? = null,
internal suspend fun Bot.wrap(
configuration: BotConfiguration? = null,
workingDir: (Long.() -> File)? = null
): BotWrapper {
// also refresh bot id
val loginInfo = impl.getLoginInfo().data ?: throw IllegalStateException("无法获取机器人账号信息")
return (net.mamoe.mirai.Bot.getInstanceOrNull(impl.id) as? BotWrapper)?.apply {
val loginInfo = getLoginInfo().data ?: throw IllegalStateException("无法获取机器人账号信息")
return (net.mamoe.mirai.Bot.getInstanceOrNull(id) as? BotWrapper)?.apply {
implBot = impl
updateContacts()
} ?: run {
val configuration = botConfiguration ?: impl.defaultBotConfiguration
val configuration = configuration ?: defaultBotConfiguration
if (workingDir != null) {
configuration.workingDir = workingDir.invoke(impl.id)
configuration.workingDir = workingDir.invoke(id)
}
BotWrapper(impl, loginInfo, configuration).apply {
BotWrapper(this, loginInfo, configuration).apply {
updateContacts()

//updateOtherClients()
Expand All @@ -223,12 +222,6 @@ internal class BotWrapper private constructor(
}
}
}
internal suspend fun Bot.wrap(
configuration: BotConfiguration? = null,
workingDir: (Long.() -> File)? = null
): BotWrapper {
return wrap(this, configuration, workingDir)
}

private val Bot.defaultBotConfiguration: BotConfiguration
get() = BotConfiguration {
Expand Down

0 comments on commit 24d5865

Please sign in to comment.