Add shortcuts for creating BotAccount and Bot

This commit is contained in:
Him188 2019-11-29 21:29:57 +08:00
parent 6817d8b94c
commit e42f925b2c

View File

@ -21,9 +21,12 @@ import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.coroutineContext import kotlin.coroutines.coroutineContext
import kotlin.jvm.JvmOverloads import kotlin.jvm.JvmOverloads
@Suppress("NOTHING_TO_INLINE", "FunctionName")
inline fun BotAccount(id: Long, password: String): BotAccount = BotAccount(id.toUInt(), password)
data class BotAccount( data class BotAccount(
val id: UInt, val id: UInt,
val password: String//todo 不保存 password? val password: String
) )
@Suppress("FunctionName") @Suppress("FunctionName")
@ -35,6 +38,9 @@ suspend inline fun Bot(account: BotAccount): Bot = Bot(account, coroutineContext
@Suppress("FunctionName") @Suppress("FunctionName")
suspend inline fun Bot(qq: UInt, password: String): Bot = Bot(qq, password, coroutineContext) suspend inline fun Bot(qq: UInt, password: String): Bot = Bot(qq, password, coroutineContext)
@Suppress("FunctionName")
suspend inline fun Bot(qq: Long, password: String): Bot = Bot(qq.toUInt(), password, coroutineContext)
/** /**
* Mirai 的机器人. 一个机器人实例登录一个 QQ 账号. * Mirai 的机器人. 一个机器人实例登录一个 QQ 账号.
* Mirai 为多账号设计, 可同时维护多个机器人. * Mirai 为多账号设计, 可同时维护多个机器人.