Commit 00f33120 authored by Him188's avatar Him188

Add easier shortcuts

parent f925aa21
...@@ -84,6 +84,18 @@ suspend inline fun Bot.login(): LoginResult = this.network.login(BotConfiguratio ...@@ -84,6 +84,18 @@ suspend inline fun Bot.login(): LoginResult = this.network.login(BotConfiguratio
*/ */
suspend inline fun Bot.alsoLogin(): Bot = apply { login().requireSuccess() } suspend inline fun Bot.alsoLogin(): Bot = apply { login().requireSuccess() }
/**
* 使用在默认配置基础上修改的配置进行登录, 返回 [this]
*/
@UseExperimental(ExperimentalContracts::class)
suspend inline fun Bot.alsoLogin(noinline configuration: BotConfiguration.() -> Unit): Bot {
contract {
callsInPlace(configuration, InvocationKind.EXACTLY_ONCE)
}
this.network.login(BotConfiguration().apply(configuration)).requireSuccess()
return this
}
/** /**
* 使用默认的配置 ([BotConfiguration.Default]) 登录, 返回 [this] * 使用默认的配置 ([BotConfiguration.Default]) 登录, 返回 [this]
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment