mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-06 00:50:13 +08:00
Add @JvmStatic and @JvmOverloads
This commit is contained in:
parent
dd9e59aabe
commit
98de5893d7
@ -27,6 +27,7 @@ import net.mamoe.mirai.network.BotNetworkHandler
|
||||
import net.mamoe.mirai.network.LoginFailedException
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.io.transferTo
|
||||
import kotlin.jvm.JvmStatic
|
||||
|
||||
/**
|
||||
* 机器人对象. 一个机器人实例登录一个 QQ 账号.
|
||||
@ -42,6 +43,7 @@ abstract class Bot : CoroutineScope {
|
||||
/**
|
||||
* 复制一份此时的 [Bot] 实例列表.
|
||||
*/
|
||||
@JvmStatic
|
||||
val instances: List<WeakRef<Bot>> get() = BotImpl.instances.toList()
|
||||
|
||||
/**
|
||||
@ -52,6 +54,7 @@ abstract class Bot : CoroutineScope {
|
||||
/**
|
||||
* 获取一个 [Bot] 实例, 找不到则 [NoSuchElementException]
|
||||
*/
|
||||
@JvmStatic
|
||||
fun instanceWhose(qq: Long): Bot = BotImpl.instanceWhose(qq = qq)
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ internal val factory: BotFactory = run {
|
||||
/**
|
||||
* 加载现有协议的 [BotFactory], 并使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
@JvmOverloads
|
||||
fun Bot(context: Context, qq: Long, password: String, configuration: BotConfiguration = BotConfiguration.Default): Bot =
|
||||
factory.Bot(context, qq, password, configuration)
|
||||
|
||||
@ -57,6 +58,7 @@ inline fun Bot(context: Context, qq: Long, password: String, configuration: (Bot
|
||||
/**
|
||||
* 加载现有协议的 [BotFactory], 并使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
@JvmOverloads
|
||||
fun Bot(qq: Long, password: String, configuration: BotConfiguration = BotConfiguration.Default): Bot =
|
||||
factory.Bot(ContextImpl(), qq, password, configuration)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user