Commit 93068d25 authored by Him188's avatar Him188

Add alsoLogin()

parent 271b9f57
...@@ -73,12 +73,17 @@ suspend inline fun Bot.login(noinline configuration: BotConfiguration.() -> Unit ...@@ -73,12 +73,17 @@ suspend inline fun Bot.login(noinline configuration: BotConfiguration.() -> Unit
} }
/** /**
* 使用默认的配置 ([BotConfiguration.Default]) 登录 * 使用默认的配置 ([BotConfiguration.Default]) 登录, 返回登录结果
*/ */
suspend inline fun Bot.login(): LoginResult = this.network.login(BotConfiguration.Default) suspend inline fun Bot.login(): LoginResult = this.network.login(BotConfiguration.Default)
/** /**
* 使用默认的配置 ([BotConfiguration.Default]) 登录 * 使用默认的配置 ([BotConfiguration.Default]) 登录, 返回 [this]
*/
suspend inline fun Bot.alsoLogin(): Bot = apply { login().requireSuccess() }
/**
* 使用默认的配置 ([BotConfiguration.Default]) 登录, 返回 [this]
*/ */
@UseExperimental(ExperimentalContracts::class) @UseExperimental(ExperimentalContracts::class)
suspend inline fun Bot.alsoLogin(lazyMessageWhenLoginFailed: (LoginResult) -> String): Bot { suspend inline fun Bot.alsoLogin(lazyMessageWhenLoginFailed: (LoginResult) -> String): Bot {
...@@ -95,7 +100,7 @@ suspend inline fun Bot.alsoLogin(lazyMessageWhenLoginFailed: (LoginResult) -> St ...@@ -95,7 +100,7 @@ suspend inline fun Bot.alsoLogin(lazyMessageWhenLoginFailed: (LoginResult) -> St
*/ */
@UseExperimental(ExperimentalContracts::class) @UseExperimental(ExperimentalContracts::class)
@JvmOverloads @JvmOverloads
suspend inline fun Bot.addFriend(id: UInt, noinline lazyMessage: () -> String = { "" }, noinline lazyRemark: () -> String = { "" }): AddFriendResult { suspend inline fun Bot.addFriend(id: UInt, lazyMessage: () -> String = { "" }, noinline lazyRemark: () -> String = { "" }): AddFriendResult {
contract { contract {
callsInPlace(lazyMessage, InvocationKind.AT_MOST_ONCE) callsInPlace(lazyMessage, InvocationKind.AT_MOST_ONCE)
} }
......
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