Introduce UserOrBot

This commit is contained in:
Him188 2020-12-14 12:25:15 +08:00
parent 115fc63890
commit afd1ee30fb
4 changed files with 24 additions and 2 deletions

View File

@ -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]))

View File

@ -16,6 +16,8 @@ import net.mamoe.mirai.Bot
* 拥有 [id] 的对象.
* 此为 [Contact] [Bot] 的唯一公共接口.
*
* @see UserOrBot
*
* @see Contact
* @see Bot
*/

View File

@ -36,7 +36,7 @@ import net.mamoe.mirai.utils.OverFileSizeMaxException
*
* 对于同一个 [Bot] 任何一个人的 [User] 实例都是单一的.
*/
public interface User : Contact, CoroutineScope {
public interface User : Contact, UserOrBot, CoroutineScope {
/**
* QQ 号码
*/

View 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