mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-24 23:20:09 +08:00
Add instance getters
This commit is contained in:
parent
d71bac77f9
commit
5ca07d3749
@ -169,8 +169,11 @@ class Bot(val account: BotAccount, val logger: MiraiLogger) : CoroutineScope {
|
||||
private val _instances: MutableList<Bot> = mutableListOf()
|
||||
private val instanceLock: Mutex = Mutex()
|
||||
|
||||
val instances: List<Bot> get() = _instances
|
||||
private val instances: List<Bot> get() = _instances
|
||||
|
||||
suspend fun instanceWhose(qq: UInt) = instanceLock.withLock {
|
||||
instances.first { it.qqAccount == qq }
|
||||
}
|
||||
|
||||
internal suspend fun addInstance(bot: Bot) = instanceLock.withLock {
|
||||
_instances += bot
|
||||
|
Loading…
Reference in New Issue
Block a user