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

Commit

Permalink
Update to mirai-core 0.39.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Apr 24, 2020
1 parent 3f1c4ad commit 0d66a99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import org.gradle.kotlin.dsl.DependencyHandlerScope

object Versions {
object Mirai {
const val core = "0.39.0"
const val console = "0.4.10"
const val core = "0.39.1"
const val console = "0.4.11"
const val consoleGraphical = "0.0.7"
const val consoleWrapper = "0.2.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import net.mamoe.mirai.console.command.DefaultCommands
import net.mamoe.mirai.console.plugins.PluginManager
import net.mamoe.mirai.console.utils.MiraiConsoleUI
import net.mamoe.mirai.utils.SimpleLogger.LogPriority
import net.mamoe.mirai.utils.WeakRef
import java.io.ByteArrayOutputStream
import java.io.PrintStream

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

fun getBotOrNull(uin: Long): Bot? {
return bots.firstOrNull { it.id == uin }
return Bot.botInstances.firstOrNull { it.id == uin }
}

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

fun getBotOrThrow(uin: Long): Bot {
return bots.firstOrNull { it.id == uin } ?: throw BotNotFoundException(uin)
return Bot.botInstances.firstOrNull { it.id == uin } ?: throw BotNotFoundException(uin)
}

/**
Expand Down Expand Up @@ -107,7 +111,7 @@ object MiraiConsole {
PluginManager.disablePlugins()
CommandManager.cancel()
try {
bots.forEach {
Bot.botInstances.forEach {
it.close()
}
} catch (ignored: Exception) {
Expand Down

0 comments on commit 0d66a99

Please sign in to comment.