mirror of
https://github.com/mamoe/mirai.git
synced 2024-12-29 10:00:13 +08:00
Add migration helpers for BotFactory
This commit is contained in:
parent
b63df48729
commit
5737dc7463
@ -7,9 +7,12 @@
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("unused", "NOTHING_TO_INLINE")
|
||||
|
||||
package net.mamoe.mirai
|
||||
|
||||
import net.mamoe.mirai.utils.BotConfiguration
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
|
||||
/**
|
||||
* 构造 [Bot] 的工厂. 这是 [Bot] 唯一的构造方式.
|
||||
@ -37,6 +40,35 @@ public interface BotFactory {
|
||||
*/
|
||||
public fun newBot(qq: Long, passwordMd5: ByteArray): Bot = newBot(qq, passwordMd5, BotConfiguration.Default)
|
||||
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use newBot(qq, password, configuration)",
|
||||
ReplaceWith("newBot(qq, password, configuration)"),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public fun Bot(
|
||||
context: Any?,
|
||||
qq: Long,
|
||||
password: String,
|
||||
configuration: BotConfiguration = BotConfiguration.Default
|
||||
): Bot = newBot(qq, password, configuration)
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use newBot(qq, password, configuration)",
|
||||
ReplaceWith("newBot(qq, password, configuration)"),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public fun Bot(
|
||||
context: Any?,
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
configuration: BotConfiguration = BotConfiguration.Default
|
||||
): Bot = newBot(qq, passwordMd5, configuration)
|
||||
|
||||
public companion object INSTANCE : BotFactory {
|
||||
override fun newBot(qq: Long, password: String, configuration: BotConfiguration): Bot {
|
||||
return Mirai.BotFactory.newBot(qq, password, configuration)
|
||||
@ -51,11 +83,332 @@ public interface BotFactory {
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public inline fun BotFactory.newBot(qq: Long, password: String, configuration: (BotConfiguration.() -> Unit)): Bot =
|
||||
this.newBot(qq, password, BotConfiguration().apply(configuration))
|
||||
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public inline fun BotFactory.newBot(qq: Long, password: ByteArray, configuration: (BotConfiguration.() -> Unit)): Bot =
|
||||
this.newBot(qq, password, BotConfiguration().apply(configuration))
|
||||
this.newBot(qq, password, BotConfiguration().apply(configuration))
|
||||
|
||||
|
||||
// deprecated:
|
||||
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, password, configuration)",
|
||||
ReplaceWith(
|
||||
"BotFactory.newBot(qq, password, configuration)",
|
||||
"net.mamoe.mirai.BotFactory",
|
||||
"net.mamoe.mirai.newBot"
|
||||
),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun BotFactory.Bot(
|
||||
context: Any?,
|
||||
qq: Long,
|
||||
password: String,
|
||||
configuration: (BotConfiguration.() -> Unit)
|
||||
): Bot = this.newBot(qq, password, BotConfiguration().apply(configuration))
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, passwordMd5, configuration)",
|
||||
ReplaceWith("BotFactory.newBot(qq, passwordMd5, configuration)", "net.mamoe.mirai.BotFactory"),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun BotFactory.Bot(
|
||||
context: Any?,
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
configuration: (BotConfiguration.() -> Unit)
|
||||
): Bot = this.newBot(qq, passwordMd5, BotConfiguration().apply(configuration))
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, password, configuration)",
|
||||
ReplaceWith(
|
||||
"BotFactory.newBot(qq, password, configuration)",
|
||||
"net.mamoe.mirai.BotFactory",
|
||||
"net.mamoe.mirai.newBot"
|
||||
),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun Bot(
|
||||
context: Any?,
|
||||
qq: Long,
|
||||
password: String,
|
||||
configuration: (BotConfiguration.() -> Unit)
|
||||
): Bot = BotFactory.newBot(qq, password, BotConfiguration().apply(configuration))
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, password, configuration)",
|
||||
ReplaceWith(
|
||||
"BotFactory.newBot(qq, password, configuration)",
|
||||
"net.mamoe.mirai.BotFactory",
|
||||
),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun Bot(
|
||||
context: Any?,
|
||||
qq: Long,
|
||||
password: String,
|
||||
configuration: BotConfiguration
|
||||
): Bot = BotFactory.newBot(qq, password, configuration)
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, passwordMd5, configuration)",
|
||||
ReplaceWith("BotFactory.newBot(qq, passwordMd5, configuration)", "net.mamoe.mirai.BotFactory"),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun Bot(
|
||||
context: Any?,
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
configuration: (BotConfiguration.() -> Unit)
|
||||
): Bot = BotFactory.newBot(qq, passwordMd5, BotConfiguration().apply(configuration))
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, passwordMd5, configuration)",
|
||||
ReplaceWith("BotFactory.newBot(qq, passwordMd5, configuration)", "net.mamoe.mirai.BotFactory"),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun Bot(
|
||||
context: Any?,
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
configuration: BotConfiguration
|
||||
): Bot = BotFactory.newBot(qq, passwordMd5, configuration)
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, password, configuration)",
|
||||
ReplaceWith(
|
||||
"BotFactory.newBot(qq, password, configuration)",
|
||||
"net.mamoe.mirai.BotFactory",
|
||||
"net.mamoe.mirai.newBot"
|
||||
),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun BotFactory.Bot(
|
||||
qq: Long,
|
||||
password: String,
|
||||
configuration: (BotConfiguration.() -> Unit)
|
||||
): Bot = this.newBot(qq, password, BotConfiguration().apply(configuration))
|
||||
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, passwordMd5, configuration)",
|
||||
ReplaceWith("BotFactory.newBot(qq, passwordMd5, configuration)", "net.mamoe.mirai.BotFactory"),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun BotFactory.Bot(
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
configuration: (BotConfiguration.() -> Unit)
|
||||
): Bot = this.newBot(qq, passwordMd5, BotConfiguration().apply(configuration))
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, password, configuration)",
|
||||
ReplaceWith(
|
||||
"BotFactory.newBot(qq, password, configuration)",
|
||||
"net.mamoe.mirai.BotFactory",
|
||||
"net.mamoe.mirai.newBot"
|
||||
),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun Bot(
|
||||
qq: Long,
|
||||
password: String,
|
||||
configuration: (BotConfiguration.() -> Unit)
|
||||
): Bot = BotFactory.newBot(qq, password, BotConfiguration().apply(configuration))
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, password, configuration)",
|
||||
ReplaceWith(
|
||||
"BotFactory.newBot(qq, password, configuration)",
|
||||
"net.mamoe.mirai.BotFactory",
|
||||
),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun Bot(
|
||||
qq: Long,
|
||||
password: String,
|
||||
configuration: BotConfiguration
|
||||
): Bot = BotFactory.newBot(qq, password, configuration)
|
||||
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, passwordMd5, configuration)",
|
||||
ReplaceWith("BotFactory.newBot(qq, passwordMd5, configuration)", "net.mamoe.mirai.BotFactory"),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun Bot(
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
configuration: (BotConfiguration.() -> Unit)
|
||||
): Bot = BotFactory.newBot(qq, passwordMd5, BotConfiguration().apply(configuration))
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, passwordMd5, configuration)",
|
||||
ReplaceWith("BotFactory.newBot(qq, passwordMd5, configuration)", "net.mamoe.mirai.BotFactory"),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun Bot(
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
configuration: BotConfiguration
|
||||
): Bot = BotFactory.newBot(qq, passwordMd5, configuration)
|
||||
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, password)",
|
||||
ReplaceWith(
|
||||
"BotFactory.newBot(qq, password)",
|
||||
"net.mamoe.mirai.BotFactory",
|
||||
),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun BotFactory.Bot(
|
||||
context: Any?,
|
||||
qq: Long,
|
||||
password: String,
|
||||
): Bot = this.newBot(qq, password)
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, passwordMd5)",
|
||||
ReplaceWith(
|
||||
"BotFactory.newBot(qq, passwordMd5)",
|
||||
"net.mamoe.mirai.BotFactory",
|
||||
),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun BotFactory.Bot(
|
||||
context: Any?,
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
): Bot = this.newBot(qq, passwordMd5)
|
||||
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, password)",
|
||||
ReplaceWith(
|
||||
"BotFactory.newBot(qq, password)",
|
||||
"net.mamoe.mirai.BotFactory",
|
||||
),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun BotFactory.Bot(
|
||||
qq: Long,
|
||||
password: String,
|
||||
): Bot = this.newBot(qq, password)
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, passwordMd5)",
|
||||
ReplaceWith(
|
||||
"BotFactory.newBot(qq, passwordMd5)",
|
||||
"net.mamoe.mirai.BotFactory",
|
||||
),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun BotFactory.Bot(
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
): Bot = this.newBot(qq, passwordMd5)
|
||||
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, password)",
|
||||
ReplaceWith(
|
||||
"BotFactory.newBot(qq, password)",
|
||||
"net.mamoe.mirai.BotFactory",
|
||||
),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun Bot(
|
||||
context: Any?,
|
||||
qq: Long,
|
||||
password: String,
|
||||
): Bot = BotFactory.newBot(qq, password)
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, passwordMd5)",
|
||||
ReplaceWith(
|
||||
"BotFactory.newBot(qq, passwordMd5)",
|
||||
"net.mamoe.mirai.BotFactory",
|
||||
),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun Bot(
|
||||
context: Any?,
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
): Bot = BotFactory.newBot(qq, passwordMd5)
|
||||
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, password)",
|
||||
ReplaceWith(
|
||||
"BotFactory.newBot(qq, password)",
|
||||
"net.mamoe.mirai.BotFactory",
|
||||
),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun Bot(
|
||||
qq: Long,
|
||||
password: String,
|
||||
): Bot = BotFactory.newBot(qq, password)
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@PlannedRemoval("2.0-M2")
|
||||
@Deprecated(
|
||||
"For migration. Use BotFactory.newBot(qq, passwordMd5)",
|
||||
ReplaceWith(
|
||||
"BotFactory.newBot(qq, passwordMd5)",
|
||||
"net.mamoe.mirai.BotFactory",
|
||||
),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
public inline fun Bot(
|
||||
qq: Long,
|
||||
passwordMd5: ByteArray,
|
||||
): Bot = BotFactory.newBot(qq, passwordMd5)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user