mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-10 06:36:57 +08:00
Introduce UserOrBot
This commit is contained in:
parent
115fc63890
commit
afd1ee30fb
@ -42,7 +42,7 @@ public suspend inline fun <B : Bot> B.alsoLogin(): B = also { login() }
|
||||
*/
|
||||
public abstract class Bot internal constructor(
|
||||
public val configuration: BotConfiguration
|
||||
) : CoroutineScope, ContactOrBot {
|
||||
) : CoroutineScope, ContactOrBot, UserOrBot {
|
||||
public final override val coroutineContext: CoroutineContext = // for id
|
||||
configuration.parentCoroutineContext
|
||||
.plus(SupervisorJob(configuration.parentCoroutineContext[Job]))
|
||||
|
@ -16,6 +16,8 @@ import net.mamoe.mirai.Bot
|
||||
* 拥有 [id] 的对象.
|
||||
* 此为 [Contact] 与 [Bot] 的唯一公共接口.
|
||||
*
|
||||
* @see UserOrBot
|
||||
*
|
||||
* @see Contact
|
||||
* @see Bot
|
||||
*/
|
||||
|
@ -36,7 +36,7 @@ import net.mamoe.mirai.utils.OverFileSizeMaxException
|
||||
*
|
||||
* 对于同一个 [Bot] 任何一个人的 [User] 实例都是单一的.
|
||||
*/
|
||||
public interface User : Contact, CoroutineScope {
|
||||
public interface User : Contact, UserOrBot, CoroutineScope {
|
||||
/**
|
||||
* QQ 号码
|
||||
*/
|
||||
|
20
mirai-core-api/src/commonMain/kotlin/contact/UserOrBot.kt
Normal file
20
mirai-core-api/src/commonMain/kotlin/contact/UserOrBot.kt
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.contact
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
|
||||
/**
|
||||
* @see User
|
||||
* @see Bot
|
||||
*
|
||||
* @see ContactOrBot
|
||||
*/
|
||||
public interface UserOrBot : ContactOrBot
|
Loading…
Reference in New Issue
Block a user