mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-25 04:50:26 +08:00
Add more builders for Bot
This commit is contained in:
parent
6a324d4ab7
commit
28c0530268
mirai-core-qqandroid/src
androidMain/kotlin/net/mamoe/mirai/qqandroid
commonMain/kotlin/net/mamoe/mirai/qqandroid
jvmMain/kotlin/net/mamoe/mirai/qqandroid
mirai-core/src
@ -24,4 +24,15 @@ actual object QQAndroid : BotFactory {
|
||||
actual override fun Bot(context: Context, qq: Long, password: String, configuration: BotConfiguration): Bot {
|
||||
return QQAndroidBot(context, BotAccount(qq, password), configuration)
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
actual override fun Bot(
|
||||
context: Context,
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
configuration: BotConfiguration
|
||||
): Bot = QQAndroidBot(context, BotAccount(qq, passwordMd5), configuration)
|
||||
}
|
@ -11,6 +11,7 @@ package net.mamoe.mirai.qqandroid
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.BotFactory
|
||||
import net.mamoe.mirai.qqandroid.QQAndroid.Bot
|
||||
import net.mamoe.mirai.utils.BotConfiguration
|
||||
import net.mamoe.mirai.utils.Context
|
||||
|
||||
@ -23,4 +24,14 @@ expect object QQAndroid : BotFactory {
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
override fun Bot(context: Context, qq: Long, password: String, configuration: BotConfiguration): Bot
|
||||
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
override fun Bot(
|
||||
context: Context,
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
configuration: BotConfiguration
|
||||
): Bot
|
||||
}
|
@ -14,6 +14,7 @@ package net.mamoe.mirai.qqandroid
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.BotAccount
|
||||
import net.mamoe.mirai.BotFactory
|
||||
import net.mamoe.mirai.qqandroid.QQAndroid.Bot
|
||||
import net.mamoe.mirai.utils.BotConfiguration
|
||||
import net.mamoe.mirai.utils.Context
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
@ -24,12 +25,37 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
actual object QQAndroid : BotFactory {
|
||||
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
actual override fun Bot(context: Context, qq: Long, password: String, configuration: BotConfiguration): Bot {
|
||||
return QQAndroidBot(context, BotAccount(qq, password), configuration)
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
fun Bot(qq: Long, password: String, configuration: BotConfiguration = BotConfiguration.Default): Bot =
|
||||
QQAndroidBot(BotAccount(qq, password), configuration)
|
||||
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
actual override fun Bot(
|
||||
context: Context,
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
configuration: BotConfiguration
|
||||
): Bot = QQAndroidBot(context, BotAccount(qq, passwordMd5), configuration)
|
||||
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
fun Bot(
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
configuration: BotConfiguration
|
||||
): Bot = QQAndroidBot(BotAccount(qq, passwordMd5), configuration)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,8 +13,6 @@ package net.mamoe.mirai
|
||||
|
||||
import net.mamoe.mirai.utils.BotConfiguration
|
||||
import net.mamoe.mirai.utils.Context
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmOverloads
|
||||
|
||||
/**
|
||||
* 构造 [Bot] 的工厂.
|
||||
@ -27,11 +25,42 @@ interface BotFactory {
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
fun Bot(context: Context, qq: Long, password: String, configuration: BotConfiguration = BotConfiguration.Default): Bot
|
||||
fun Bot(
|
||||
context: Context,
|
||||
qq: Long,
|
||||
password: String,
|
||||
configuration: BotConfiguration = BotConfiguration.Default
|
||||
): Bot
|
||||
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
fun Bot(
|
||||
context: Context,
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
configuration: BotConfiguration = BotConfiguration.Default
|
||||
): Bot
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
inline fun BotFactory.Bot(context: Context, qq: Long, password: String, configuration: (BotConfiguration.() -> Unit)): Bot =
|
||||
this.Bot(context, qq, password, BotConfiguration().apply(configuration))
|
||||
inline fun BotFactory.Bot(
|
||||
context: Context,
|
||||
qq: Long,
|
||||
password: String,
|
||||
configuration: (BotConfiguration.() -> Unit)
|
||||
): Bot =
|
||||
this.Bot(context, qq, password, BotConfiguration().apply(configuration))
|
||||
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
inline fun BotFactory.Bot(
|
||||
context: Context,
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
configuration: (BotConfiguration.() -> Unit)
|
||||
): Bot =
|
||||
this.Bot(context, qq, passwordMd5, BotConfiguration().apply(configuration))
|
@ -71,4 +71,41 @@ fun Bot(qq: Long, password: String, configuration: BotConfiguration = BotConfigu
|
||||
*/
|
||||
@JvmSynthetic
|
||||
inline fun Bot(qq: Long, password: String, configuration: (BotConfiguration.() -> Unit)): Bot =
|
||||
factory.Bot(ContextImpl(), qq, password, configuration)
|
||||
factory.Bot(ContextImpl(), qq, password, configuration)
|
||||
|
||||
|
||||
/**
|
||||
* 加载现有协议的 [BotFactory], 并使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
@JvmName("newBot")
|
||||
@JvmOverloads
|
||||
fun Bot(
|
||||
context: Context,
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
configuration: BotConfiguration = BotConfiguration.Default
|
||||
): Bot =
|
||||
factory.Bot(context, qq, passwordMd5, configuration)
|
||||
|
||||
/**
|
||||
* 加载现有协议的 [BotFactory], 并使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
@JvmSynthetic
|
||||
inline fun Bot(context: Context, qq: Long, passwordMd5: ByteArray, configuration: (BotConfiguration.() -> Unit)): Bot =
|
||||
factory.Bot(context, qq, passwordMd5, BotConfiguration().apply(configuration))
|
||||
|
||||
|
||||
/**
|
||||
* 加载现有协议的 [BotFactory], 并使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
@JvmName("newBot")
|
||||
@JvmOverloads
|
||||
fun Bot(qq: Long, passwordMd5: ByteArray, configuration: BotConfiguration = BotConfiguration.Default): Bot =
|
||||
factory.Bot(ContextImpl(), qq, passwordMd5, configuration)
|
||||
|
||||
/**
|
||||
* 加载现有协议的 [BotFactory], 并使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
@JvmSynthetic
|
||||
inline fun Bot(qq: Long, passwordMd5: ByteArray, configuration: (BotConfiguration.() -> Unit)): Bot =
|
||||
factory.Bot(ContextImpl(), qq, passwordMd5, BotConfiguration().apply(configuration))
|
Loading…
Reference in New Issue
Block a user