Skip to content
This repository was archived by the owner on Feb 10, 2023. It is now read-only.

Commit 0d66a99

Browse files
committed
Update to mirai-core 0.39.1
1 parent 3f1c4ad commit 0d66a99

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

buildSrc/src/main/kotlin/versions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import org.gradle.kotlin.dsl.DependencyHandlerScope
1111

1212
object Versions {
1313
object Mirai {
14-
const val core = "0.39.0"
15-
const val console = "0.4.10"
14+
const val core = "0.39.1"
15+
const val console = "0.4.11"
1616
const val consoleGraphical = "0.0.7"
1717
const val consoleWrapper = "0.2.0"
1818
}

mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsole.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import net.mamoe.mirai.console.command.DefaultCommands
1616
import net.mamoe.mirai.console.plugins.PluginManager
1717
import net.mamoe.mirai.console.utils.MiraiConsoleUI
1818
import net.mamoe.mirai.utils.SimpleLogger.LogPriority
19+
import net.mamoe.mirai.utils.WeakRef
1920
import java.io.ByteArrayOutputStream
2021
import java.io.PrintStream
2122

@@ -31,16 +32,19 @@ object MiraiConsole {
3132
/**
3233
* 获取从Console登陆上的Bot, Bots
3334
* */
34-
val bots: List<Bot> get() = Bot.instances
35+
@Suppress("DEPRECATION")
36+
@Deprecated("use Bot.instances from mirai-core", replaceWith = ReplaceWith("Bot.instances", "net.mamoe.mirai.Bot"))
37+
val bots: List<WeakRef<Bot>>
38+
get() = Bot.instances
3539

3640
fun getBotOrNull(uin: Long): Bot? {
37-
return bots.firstOrNull { it.id == uin }
41+
return Bot.botInstances.firstOrNull { it.id == uin }
3842
}
3943

4044
class BotNotFoundException(uin: Long) : Exception("Bot $uin Not Found")
4145

4246
fun getBotOrThrow(uin: Long): Bot {
43-
return bots.firstOrNull { it.id == uin } ?: throw BotNotFoundException(uin)
47+
return Bot.botInstances.firstOrNull { it.id == uin } ?: throw BotNotFoundException(uin)
4448
}
4549

4650
/**
@@ -107,7 +111,7 @@ object MiraiConsole {
107111
PluginManager.disablePlugins()
108112
CommandManager.cancel()
109113
try {
110-
bots.forEach {
114+
Bot.botInstances.forEach {
111115
it.close()
112116
}
113117
} catch (ignored: Exception) {

0 commit comments

Comments
 (0)