Remove module-level opt-ins, add @OptIn explicit in use-sites;

added some opt-in markers on API which should have:

- `appendMiraiCodeTo`

Made API stable (otherwise they require too heavy opt-ins):
- MiraiConsoleImplementation$ConsoleLaunchOptions
- LowLevelApi
This commit is contained in:
Him188 2023-05-04 15:03:44 +01:00
parent 96a772c5ca
commit 363d1f7ece
No known key found for this signature in database
GPG Key ID: BA439CDDCF652375
171 changed files with 892 additions and 505 deletions

View File

@ -32,9 +32,19 @@ private fun Project.jvmVersion(): JavaVersion {
}
}
fun Project.optInForAllTargets(qualifiedClassname: String) {
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinCompile::class) {
kotlinOptions.freeCompilerArgs += "-Xopt-in=$qualifiedClassname"
fun Project.optInForAllSourceSets(qualifiedClassname: String) {
kotlinSourceSets!!.all {
languageSettings {
optIn(qualifiedClassname)
}
}
}
fun Project.optInForTestSourceSets(qualifiedClassname: String) {
kotlinSourceSets!!.matching { it.name.contains("test", ignoreCase = true) }.all {
languageSettings {
optIn(qualifiedClassname)
}
}
}
@ -167,26 +177,16 @@ val testExperimentalAnnotations = arrayOf(
"io.ktor.util.KtorExperimentalAPI",
"kotlin.io.path.ExperimentalPathApi",
"kotlinx.coroutines.ExperimentalCoroutinesApi",
"kotlinx.serialization.ExperimentalSerializationApi",
"net.mamoe.mirai.utils.TestOnly",
"net.mamoe.mirai.utils.MiraiInternalApi",
"net.mamoe.mirai.utils.MiraiExperimentalApi",
)
val experimentalAnnotations = arrayOf(
"kotlin.RequiresOptIn",
"kotlin.contracts.ExperimentalContracts",
"kotlin.experimental.ExperimentalTypeInference",
"kotlin.ExperimentalUnsignedTypes",
"kotlinx.serialization.ExperimentalSerializationApi",
"net.mamoe.mirai.utils.MiraiInternalApi",
"net.mamoe.mirai.utils.MiraiExperimentalApi",
"net.mamoe.mirai.LowLevelApi",
"net.mamoe.mirai.console.ConsoleFrontEndImplementation",
"net.mamoe.mirai.console.util.ConsoleInternalApi",
"net.mamoe.mirai.console.util.ConsoleExperimentalApi",
"io.ktor.utils.io.core.internal.DangerousInternalIoApi"
)
val testLanguageFeatures = listOf(

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -8,6 +8,7 @@
*/
@file:JvmName("IntegrationTestBootstrap")
@file:OptIn(ConsoleFrontEndImplementation::class, ConsoleExperimentalApi::class, ConsoleInternalApi::class)
package net.mamoe.console.integrationtest
@ -15,10 +16,13 @@ import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.runBlocking
import net.mamoe.console.integrationtest.AbstractTestPoint.Companion.internalBCS
import net.mamoe.console.integrationtest.AbstractTestPoint.Companion.internalOSS
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsole
import net.mamoe.mirai.console.terminal.ConsoleTerminalExperimentalApi
import net.mamoe.mirai.console.terminal.ConsoleTerminalSettings
import net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.console.util.ConsoleInternalApi
import net.mamoe.mirai.utils.cast
import net.mamoe.mirai.utils.sha1
import net.mamoe.mirai.utils.toUHexString

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -10,6 +10,7 @@
package net.mamoe.console.integrationtest
import net.mamoe.mirai.console.internal.plugin.ConsoleJvmPluginTestFailedError
import net.mamoe.mirai.utils.MiraiInternalApi
import org.junit.jupiter.api.fail
import org.objectweb.asm.ClassReader
import org.objectweb.asm.ClassWriter
@ -54,6 +55,7 @@ public fun assertClassSame(expected: Class<*>?, actually: Class<*>?) {
}
}
@OptIn(MiraiInternalApi::class)
public fun forceFail(
msg: String? = null,
cause: Throwable? = null,

View File

@ -29,6 +29,11 @@ description = "Mirai Console Backend"
kotlin {
explicitApiWarning()
optInForAllSourceSets("kotlinx.serialization.ExperimentalSerializationApi")
optInForTestSourceSets("net.mamoe.mirai.console.ConsoleFrontEndImplementation")
optInForTestSourceSets("net.mamoe.mirai.console.ConsoleExperimentalApi")
optInForTestSourceSets("net.mamoe.mirai.console.ConsoleInternalApi")
}

View File

@ -42,6 +42,11 @@ public abstract interface class net/mamoe/mirai/console/MiraiConsoleFrontEndDesc
public fun render ()Ljava/lang/String;
}
public final class net/mamoe/mirai/console/MiraiConsoleImplementation$ConsoleLaunchOptions {
public field crashWhenPluginLoadFailed Z
public fun <init> ()V
}
public final class net/mamoe/mirai/console/MiraiConsoleKt {
public static final fun getRootDir (Lnet/mamoe/mirai/console/MiraiConsole;)Ljava/io/File;
}
@ -105,13 +110,10 @@ public final class net/mamoe/mirai/console/command/BuiltInCommands {
public final class net/mamoe/mirai/console/command/BuiltInCommands$AutoLoginCommand : net/mamoe/mirai/console/command/CompositeCommand, net/mamoe/mirai/console/command/BuiltInCommandInternal {
public static final field INSTANCE Lnet/mamoe/mirai/console/command/BuiltInCommands$AutoLoginCommand;
public final fun add (Lnet/mamoe/mirai/console/command/CommandSender;JLjava/lang/String;Lnet/mamoe/mirai/console/internal/data/builtins/AutoLoginConfig$Account$PasswordKind;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun add$default (Lnet/mamoe/mirai/console/command/BuiltInCommands$AutoLoginCommand;Lnet/mamoe/mirai/console/command/CommandSender;JLjava/lang/String;Lnet/mamoe/mirai/console/internal/data/builtins/AutoLoginConfig$Account$PasswordKind;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun clear (Lnet/mamoe/mirai/console/command/CommandSender;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun list (Lnet/mamoe/mirai/console/command/CommandSender;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun remove (Lnet/mamoe/mirai/console/command/CommandSender;JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun removeConfig (Lnet/mamoe/mirai/console/command/CommandSender;JLnet/mamoe/mirai/console/internal/data/builtins/AutoLoginConfig$Account$ConfigurationKey;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun setConfig (Lnet/mamoe/mirai/console/command/CommandSender;JLnet/mamoe/mirai/console/internal/data/builtins/AutoLoginConfig$Account$ConfigurationKey;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class net/mamoe/mirai/console/command/BuiltInCommands$HelpCommand : net/mamoe/mirai/console/command/SimpleCommand, net/mamoe/mirai/console/command/BuiltInCommandInternal {
@ -2157,6 +2159,7 @@ public class net/mamoe/mirai/console/util/AnsiMessageBuilder : java/io/Serializa
public fun gray ()Lnet/mamoe/mirai/console/util/AnsiMessageBuilder;
public fun green ()Lnet/mamoe/mirai/console/util/AnsiMessageBuilder;
public fun hashCode ()I
public static final fun isAnsiSupported (Lnet/mamoe/mirai/console/command/CommandSender;)Z
public fun lightBlue ()Lnet/mamoe/mirai/console/util/AnsiMessageBuilder;
public fun lightCyan ()Lnet/mamoe/mirai/console/util/AnsiMessageBuilder;
public fun lightGreen ()Lnet/mamoe/mirai/console/util/AnsiMessageBuilder;
@ -2180,6 +2183,7 @@ public final class net/mamoe/mirai/console/util/AnsiMessageBuilder$Companion {
public final fun from (Ljava/lang/StringBuilder;)Lnet/mamoe/mirai/console/util/AnsiMessageBuilder;
public final fun from (Ljava/lang/StringBuilder;Z)Lnet/mamoe/mirai/console/util/AnsiMessageBuilder;
public static synthetic fun from$default (Lnet/mamoe/mirai/console/util/AnsiMessageBuilder$Companion;Ljava/lang/StringBuilder;ZILjava/lang/Object;)Lnet/mamoe/mirai/console/util/AnsiMessageBuilder;
public final fun isAnsiSupported (Lnet/mamoe/mirai/console/command/CommandSender;)Z
}
public final class net/mamoe/mirai/console/util/AnsiMessageBuilderKt {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -159,7 +159,10 @@ public interface MiraiConsole : CoroutineScope {
*
* 对象以 [bridge][MiraiConsoleImplementationBridge] 实现, 将会桥接特定前端实现的 [MiraiConsoleImplementation] [MiraiConsole].
*/
public companion object INSTANCE : MiraiConsole by dynamicDelegation({ MiraiConsoleImplementation.getBridge() }) {
public companion object INSTANCE : MiraiConsole by dynamicDelegation({
@OptIn(ConsoleFrontEndImplementation::class)
MiraiConsoleImplementation.getBridge()
}) {
/**
* 获取 [MiraiConsole] [Job]
*/ // MiraiConsole.INSTANCE.getJob()
@ -207,7 +210,7 @@ public interface MiraiConsole : CoroutineScope {
configuration: BotConfiguration.() -> Unit = {}
): Bot = addBotImpl(id, authorization, configuration)
@Suppress("UNREACHABLE_CODE")
@OptIn(ConsoleFrontEndImplementation::class)
private fun addBotImpl(id: Long, authorization: Any, configuration: BotConfiguration.() -> Unit = {}): Bot {
when (authorization) {
is String -> {}
@ -285,7 +288,7 @@ public interface MiraiConsole : CoroutineScope {
public fun shutdown() {
val consoleJob = job
if (!consoleJob.isActive) return
@OptIn(DelicateCoroutinesApi::class)
@OptIn(DelicateCoroutinesApi::class, ConsoleFrontEndImplementation::class)
GlobalScope.launch {
MiraiConsoleImplementation.shutdown()
}
@ -307,6 +310,7 @@ public interface MiraiConsole : CoroutineScope {
@ConsoleExperimentalApi
@JvmStatic
public fun newProcessProgress(): ProcessProgress {
@OptIn(ConsoleFrontEndImplementation::class)
return MiraiConsoleImplementation.getInstance().createNewProcessProgress()
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -37,6 +37,7 @@ import net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader
import net.mamoe.mirai.console.plugin.loader.PluginLoader
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.console.util.ConsoleInput
import net.mamoe.mirai.console.util.ConsoleInternalApi
import net.mamoe.mirai.message.data.Message
import net.mamoe.mirai.utils.*
import java.nio.file.Path
@ -171,9 +172,16 @@ public interface MiraiConsoleImplementation : CoroutineScope {
*/
public val commandManager: CommandManager
@ConsoleExperimentalApi
public val dataStorageForJvmPluginLoader: PluginDataStorage
@ConsoleExperimentalApi
public val configStorageForJvmPluginLoader: PluginDataStorage
@ConsoleExperimentalApi
public val dataStorageForBuiltIns: PluginDataStorage
@ConsoleExperimentalApi
public val configStorageForBuiltIns: PluginDataStorage
/**
@ -227,6 +235,7 @@ public interface MiraiConsoleImplementation : CoroutineScope {
/**
* 前端预先定义的 [LoggerController], 以允许前端使用自己的配置系统
*/
@ConsoleExperimentalApi
public val loggerController: LoggerController get() = LoggerControllerImpl()
///////////////////////////////////////////////////////////////////////////
@ -259,7 +268,10 @@ public interface MiraiConsoleImplementation : CoroutineScope {
@ConsoleFrontEndImplementation
@NotStableForInheritance
public interface ConsoleDataScope {
@ConsoleExperimentalApi
public val dataHolder: AutoSavePluginDataHolder
@ConsoleExperimentalApi
public val configHolder: AutoSavePluginDataHolder
public fun addAndReloadConfig(config: PluginConfig)
@ -291,6 +303,7 @@ public interface MiraiConsoleImplementation : CoroutineScope {
*/
public inline fun <reified T : PluginData> ConsoleDataScope.get(): T = get(T::class)
@ConsoleExperimentalApi
@JvmStatic
public fun createDefault(
coroutineContext: CoroutineContext,
@ -412,13 +425,11 @@ public interface MiraiConsoleImplementation : CoroutineScope {
* Console 启动参数, 修改参数会改变默认行为
* @since 2.10.0-RC
*/
@ConsoleExperimentalApi
public class ConsoleLaunchOptions {
@JvmField
public var crashWhenPluginLoadFailed: Boolean = false
}
@ConsoleExperimentalApi
public val consoleLaunchOptions: ConsoleLaunchOptions
get() = ConsoleLaunchOptions()
@ -453,7 +464,7 @@ public interface MiraiConsoleImplementation : CoroutineScope {
runBlocking {
shutdown()
}
} catch (_ : InterruptedException) {
} catch (_: InterruptedException) {
}
}
@ -483,6 +494,7 @@ public interface MiraiConsoleImplementation : CoroutineScope {
currentBridge ?: throw UninitializedPropertyAccessException()
/** 由前端调用, 初始化 [MiraiConsole] 实例并启动 */
@OptIn(ConsoleInternalApi::class)
@JvmStatic
@ConsoleFrontEndImplementation
@Throws(MalformedMiraiConsoleImplementationError::class)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,6 +7,8 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleFrontEndImplementation::class)
package net.mamoe.mirai.console.command
import kotlinx.coroutines.DelicateCoroutinesApi
@ -15,6 +17,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import net.mamoe.mirai.Bot
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsole
import net.mamoe.mirai.console.MiraiConsoleImplementation
import net.mamoe.mirai.console.MiraiConsoleImplementation.ConsoleDataScope.Companion.get
@ -51,6 +54,7 @@ import net.mamoe.mirai.console.plugin.version
import net.mamoe.mirai.console.util.*
import net.mamoe.mirai.event.events.EventCancelledException
import net.mamoe.mirai.utils.BotConfiguration
import net.mamoe.mirai.utils.MiraiExperimentalApi
import java.lang.management.ManagementFactory
import java.lang.management.MemoryMXBean
import java.lang.management.MemoryUsage
@ -64,6 +68,7 @@ import kotlin.system.exitProcess
public interface BuiltInCommand : Command
// for identification
@OptIn(ConsoleExperimentalApi::class)
internal interface BuiltInCommandInternal : Command, BuiltInCommand
/**
@ -126,7 +131,10 @@ public object BuiltInCommands {
private val closingLock = Mutex()
@OptIn(DelicateCoroutinesApi::class)
@OptIn(
DelicateCoroutinesApi::class, ConsoleFrontEndImplementation::class, ConsoleExperimentalApi::class,
ConsoleInternalApi::class
)
@Handler
public suspend fun CommandSender.handle() {
GlobalScope.launch {
@ -162,6 +170,7 @@ public object BuiltInCommands {
description = "登出一个账号",
), BuiltInCommandInternal {
@OptIn(ConsoleExperimentalApi::class)
@Handler
public suspend fun CommandSender.handle(
@Name("qq") id: Long
@ -181,6 +190,7 @@ public object BuiltInCommands {
description = loginCommandInstance.description,
), BuiltInCommandInternal {
@OptIn(ConsoleExperimentalApi::class)
@Handler
@JvmOverloads
public suspend fun CommandSender.handle(
@ -237,6 +247,7 @@ public object BuiltInCommands {
}
@OptIn(ConsoleExperimentalApi::class)
@Description("授权一个权限")
@SubCommand("permit", "grant", "add")
public suspend fun CommandSender.permit(
@ -247,6 +258,7 @@ public object BuiltInCommands {
sendMessage("OK")
}
@OptIn(ConsoleExperimentalApi::class)
@Description("撤销一个权限")
@SubCommand("cancel", "deny", "remove")
public suspend fun CommandSender.cancel(
@ -257,6 +269,7 @@ public object BuiltInCommands {
sendMessage("OK")
}
@OptIn(ConsoleExperimentalApi::class)
@Description("撤销一个权限及其所有子权限")
@SubCommand("cancelAll", "denyAll", "removeAll")
public suspend fun CommandSender.cancelAll(
@ -267,6 +280,7 @@ public object BuiltInCommands {
sendMessage("OK")
}
@OptIn(ConsoleExperimentalApi::class)
@Description("查看被授权权限列表")
@SubCommand("permittedPermissions", "pp", "grantedPermissions", "gp")
public suspend fun CommandSender.permittedPermissions(
@ -423,11 +437,13 @@ public object BuiltInCommands {
ConsoleCommandOwner, "autoLogin", "自动登录",
description = "自动登录设置",
overrideContext = buildCommandArgumentContext {
@OptIn(ConsoleExperimentalApi::class)
ConfigurationKey::class with ConfigurationKey.Parser
}
), BuiltInCommandInternal {
@Description("查看自动登录账号列表")
@SubCommand
@OptIn(ConsoleExperimentalApi::class)
public suspend fun CommandSender.list() {
val config = DataScope.get<AutoLoginConfig>()
sendMessage(buildString {
@ -454,6 +470,7 @@ public object BuiltInCommands {
@Description("添加自动登录, passwordKind 可选 PLAIN 或 MD5")
@SubCommand
@ConsoleExperimentalApi
public suspend fun CommandSender.add(account: Long, password: String, passwordKind: PasswordKind = PLAIN) {
val config = DataScope.get<AutoLoginConfig>()
val accountStr = account.toString()
@ -465,6 +482,7 @@ public object BuiltInCommands {
sendMessage("已成功添加 '$account'.")
}
@OptIn(ConsoleExperimentalApi::class)
@Description("清除所有配置")
@SubCommand
public suspend fun CommandSender.clear() {
@ -473,6 +491,7 @@ public object BuiltInCommands {
sendMessage("已清除所有自动登录配置.")
}
@OptIn(ConsoleExperimentalApi::class)
@Description("删除一个账号")
@SubCommand
public suspend fun CommandSender.remove(account: Long) {
@ -485,6 +504,7 @@ public object BuiltInCommands {
sendMessage("账号 '$account' 未配置自动登录.")
}
@ConsoleExperimentalApi
@Description("设置一个账号的一个配置项")
@SubCommand
public suspend fun CommandSender.setConfig(account: Long, configKey: ConfigurationKey, value: String) {
@ -509,6 +529,7 @@ public object BuiltInCommands {
}
@Description("删除一个账号的一个配置项")
@ConsoleExperimentalApi
@SubCommand
public suspend fun CommandSender.removeConfig(account: Long, configKey: ConfigurationKey) {
val config = DataScope.get<AutoLoginConfig>()
@ -583,6 +604,7 @@ public object BuiltInCommands {
val max: Long,
)
@OptIn(MiraiExperimentalApi::class)
@Handler
public suspend fun CommandSender.handle() {
sendAnsiMessage {
@ -668,9 +690,11 @@ public object BuiltInCommands {
v < e50 -> {
green()
}
v < e90 -> {
lightRed()
}
else -> {
red()
}

View File

@ -1,10 +1,10 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
* 此源代码的使用受 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
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:Suppress("NOTHING_TO_INLINE", "MemberVisibilityCanBePrivate")
@ -19,7 +19,6 @@ import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.COMMAND_NAME
import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.RESTRICTED_CONSOLE_COMMAND_OWNER
import net.mamoe.mirai.console.permission.Permission
import net.mamoe.mirai.console.permission.PermissionId
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
/**
* 指令
@ -54,7 +53,6 @@ public interface Command {
/**
* 指令可能的参数列表.
*/
@ConsoleExperimentalApi("Property name is experimental")
@ExperimentalCommandDescriptors
public val overloads: List<@JvmWildcard CommandSignature>
@ -86,7 +84,6 @@ public interface Command {
* 由于指令解析允许被扩展, 此属性可能不适用所有解析器, 因此还未决定是否保留.
*/
@ExperimentalCommandDescriptors
@ConsoleExperimentalApi
public val prefixOptional: Boolean
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -16,7 +16,6 @@ import net.mamoe.mirai.console.command.parse.CommandCall
import net.mamoe.mirai.console.command.parse.CommandValueArgument
import net.mamoe.mirai.console.command.resolve.InterceptedReason
import net.mamoe.mirai.console.command.resolve.ResolvedCommandCall
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import kotlin.contracts.contract
/**
@ -129,7 +128,6 @@ public sealed class CommandExecuteResult {
public override val call: CommandCall,
/** 尝试执行的指令 */
@ExperimentalCommandDescriptors
@ConsoleExperimentalApi
public val failureReasons: List<UnmatchedCommandSignature>,
) : Failure() {
/** 指令执行时发生的错误, 总是 `null` */
@ -141,14 +139,12 @@ public sealed class CommandExecuteResult {
}
@ExperimentalCommandDescriptors
@ConsoleExperimentalApi
public class UnmatchedCommandSignature(
public val signature: CommandSignature,
public val failureReason: FailureReason,
)
@ExperimentalCommandDescriptors
@ConsoleExperimentalApi
public sealed class FailureReason {
public class InapplicableReceiverArgument(
public override val parameter: CommandReceiverParameter<*>,

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -17,6 +17,7 @@ package net.mamoe.mirai.console.command
import me.him188.kotlin.dynamic.delegation.dynamicDelegation
import me.him188.kotlin.jvm.blocking.bridge.JvmBlockingBridge
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsoleImplementation
import net.mamoe.mirai.console.command.CommandManager.INSTANCE.executeCommand
import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors
@ -173,8 +174,12 @@ public interface CommandManager {
/**
* [CommandManager] 实例. 转发所有调用到 [MiraiConsoleImplementation.commandManager].
*/
public companion object INSTANCE :
CommandManager by (dynamicDelegation { MiraiConsoleImplementation.getInstance().commandManager }) {
CommandManager by (dynamicDelegation {
@OptIn(ConsoleFrontEndImplementation::class)
MiraiConsoleImplementation.getInstance().commandManager
}) {
/**
* @see CommandManager.getRegisteredCommands
@ -247,7 +252,9 @@ public suspend inline fun Command.execute(
sender: CommandSender,
vararg arguments: Message = emptyArray(),
checkPermission: Boolean = true,
): CommandExecuteResult = CommandManager.executeCommand(sender, this, arguments.toMessageChain(), checkPermission)
): CommandExecuteResult =
@OptIn(ConsoleExperimentalApi::class)
CommandManager.executeCommand(sender, this, arguments.toMessageChain(), checkPermission)
/**
* 执行一个确切的指令

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -15,6 +15,7 @@ import net.mamoe.mirai.console.permission.Permission
import net.mamoe.mirai.console.permission.PermissionId
import net.mamoe.mirai.console.permission.PermissionIdNamespace
import net.mamoe.mirai.console.plugin.jvm.JvmPlugin
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
/**
* 指令的所有者. [JvmPlugin] 是一个 [CommandOwner].
@ -35,6 +36,7 @@ public interface CommandOwner : PermissionIdNamespace {
* 插件注册指令时不应该使用 [ConsoleCommandOwner].
*/
public object ConsoleCommandOwner : CommandOwner {
@OptIn(ConsoleExperimentalApi::class)
public override val parentPermission: Permission get() = BuiltInCommands.parentPermission
public override fun permissionId(

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -17,6 +17,7 @@ package net.mamoe.mirai.console.command
import kotlinx.coroutines.CoroutineScope
import me.him188.kotlin.jvm.blocking.bridge.JvmBlockingBridge
import net.mamoe.mirai.Bot
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsole
import net.mamoe.mirai.console.MiraiConsoleImplementation
import net.mamoe.mirai.console.command.CommandSender.Companion.asCommandSender
@ -390,15 +391,18 @@ public object ConsoleCommandSender : AbstractCommandSender(), SystemCommandSende
public override val coroutineContext: CoroutineContext by lazy { MiraiConsole.childScopeContext(NAME) }
@OptIn(ConsoleFrontEndImplementation::class)
override val isAnsiSupported: Boolean
get() = MiraiConsoleImplementation.getInstance().isAnsiSupported
@OptIn(ConsoleFrontEndImplementation::class)
@JvmBlockingBridge
public override suspend fun sendMessage(message: Message): Nothing? {
MiraiConsoleImplementation.getInstance().consoleCommandSender.sendMessage(message)
return null
}
@OptIn(ConsoleFrontEndImplementation::class)
@JvmBlockingBridge
public override suspend fun sendMessage(message: String): Nothing? {
MiraiConsoleImplementation.getInstance().consoleCommandSender.sendMessage(message)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -60,6 +60,7 @@ public abstract class SimpleCommand(
private val reflector by lazy { CommandReflector(this, SimpleCommandSubCommandAnnotationResolver) }
@OptIn(ConsoleExperimentalApi::class)
@ExperimentalCommandDescriptors
public final override val overloads: List<@JvmWildcard CommandSignatureFromKFunction> by lazy {
reflector.findSubCommands().also {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -23,6 +23,7 @@ import net.mamoe.mirai.contact.*
import net.mamoe.mirai.message.data.Image
import net.mamoe.mirai.message.data.MessageContent
import net.mamoe.mirai.message.data.PlainText
import net.mamoe.mirai.utils.MiraiExperimentalApi
import java.time.*
import java.time.temporal.TemporalAccessor
import java.util.*
@ -98,6 +99,7 @@ public interface CommandArgumentContext {
private object TemporalCommandArgumentContext : CommandArgumentContext {
private val cache = HashMap<KClass<*>, CommandValueArgumentParser<*>>()
@OptIn(MiraiExperimentalApi::class)
private fun <T : TemporalAccessor> put(kClass: KClass<T>, now: () -> T, parse: (CharSequence) -> T) {
cache[kClass] = TemporalArgumentParser(kClass.java, now, parse)
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -112,10 +112,12 @@ public sealed class ArgumentAcceptance(
public object Impossible : ArgumentAcceptance(-1)
public companion object {
@OptIn(ConsoleExperimentalApi::class)
@JvmStatic
public val ArgumentAcceptance.isAcceptable: Boolean
get() = acceptanceLevel > 0
@OptIn(ConsoleExperimentalApi::class)
@JvmStatic
public val ArgumentAcceptance.isNotAcceptable: Boolean
get() = acceptanceLevel <= 0
@ -123,8 +125,7 @@ public sealed class ArgumentAcceptance(
}
@ExperimentalCommandDescriptors
public sealed class CommandReceiverParameter<T>(
) : CommandParameter<T>, AbstractCommandParameter<T>() {
public sealed class CommandReceiverParameter<T> : CommandParameter<T>, AbstractCommandParameter<T>() {
/**
* @since 2.12

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -11,7 +11,6 @@ package net.mamoe.mirai.console.command.descriptor
import net.mamoe.mirai.console.command.CommandSender
import net.mamoe.mirai.console.command.resolve.ResolvedCommandCall
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import kotlin.reflect.KFunction
/**
@ -24,7 +23,6 @@ public interface CommandSignature {
/**
* 接收者参数, [CommandSender] 子类
*/
@ConsoleExperimentalApi
public val receiverParameter: CommandReceiverParameter<*>?
/**
@ -43,7 +41,6 @@ public interface CommandSignature {
*
* @see CommandSignatureFromKFunctionImpl
*/
@ConsoleExperimentalApi
@ExperimentalCommandDescriptors
public interface CommandSignatureFromKFunction : CommandSignature {
public val originFunction: KFunction<*>
@ -76,7 +73,6 @@ public open class CommandSignatureImpl(
}
}
@ConsoleExperimentalApi
@ExperimentalCommandDescriptors
public open class CommandSignatureFromKFunctionImpl(
override val receiverParameter: CommandReceiverParameter<*>?,

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -9,7 +9,6 @@
package net.mamoe.mirai.console.command.descriptor
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import kotlin.annotation.AnnotationTarget.*
/**
@ -24,7 +23,6 @@ import kotlin.annotation.AnnotationTarget.*
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
@Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR)
@MustBeDocumented
@ConsoleExperimentalApi
@ExperimentalCommandDescriptors
public annotation class ExperimentalCommandDescriptors(
val message: String = "Command descriptors are an experimental API.",

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -15,7 +15,6 @@ import net.mamoe.mirai.console.command.resolve.CommandCallResolver
import net.mamoe.mirai.console.command.resolve.ResolvedCommandCall
import net.mamoe.mirai.console.extensions.CommandCallParserProvider
import net.mamoe.mirai.console.internal.extension.GlobalComponentStorage
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.message.data.MessageChain
/**
@ -26,7 +25,6 @@ import net.mamoe.mirai.message.data.MessageChain
*
* @see SpaceSeparatedCommandCallParser
*/
@ConsoleExperimentalApi
@ExperimentalCommandDescriptors
public interface CommandCallParser {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -102,6 +102,7 @@ public class ResolvedCommandCallImpl(
private val context: CommandArgumentContext,
override val originalMessage: MessageChain,
) : ResolvedCommandCall {
@ConsoleExperimentalApi
override val resolvedValueArguments: List<ResolvedCommandValueArgument<*>> by lazy {
calleeSignature.valueParameters.zip(rawValueArguments).map { (parameter, argument) ->
val value = argument.mapToTypeOrNull(parameter.type) { type, message ->

View File

@ -32,6 +32,7 @@ public abstract class AbstractPluginData : PluginData, PluginDataImpl() {
/**
* 这个 [PluginData] 保存时使用的名称.
*/
@ConsoleExperimentalApi
public abstract override val saveName: String
/**
@ -66,6 +67,7 @@ public abstract class AbstractPluginData : PluginData, PluginDataImpl() {
/**
* 使用 `by value()` 时自动调用此方法, 添加对 [Value] 的值修改的跟踪, 并创建 [ValueNode] 加入 [valueNodes]
*/
@OptIn(ConsoleExperimentalApi::class)
public operator fun <T : SerializerAwareValue<*>> T.provideDelegate(
thisRef: Any?,
property: KProperty<*>,

View File

@ -1,10 +1,10 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
* 此源代码的使用受 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
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:Suppress("unused", "PropertyName", "PrivatePropertyName")
@ -16,6 +16,7 @@ import net.mamoe.mirai.console.MiraiConsole
import net.mamoe.mirai.console.internal.data.qualifiedNameOrTip
import net.mamoe.mirai.console.internal.util.runIgnoreException
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.console.util.ConsoleInternalApi
import net.mamoe.mirai.console.util.TimedTask
import net.mamoe.mirai.console.util.launchTimedTask
import net.mamoe.mirai.utils.MiraiLogger
@ -35,20 +36,27 @@ public open class AutoSavePluginData private constructor(
// KEEP THIS PRIMARY CONSTRUCTOR FOR FUTURE USE: WE'LL SUPPORT SERIALIZERS_MODULE FOR POLYMORPHISM
@Suppress("UNUSED_PARAMETER") primaryConstructorMark: Any?,
) : AbstractPluginData() {
@OptIn(ConsoleExperimentalApi::class)
private lateinit var owner_: AutoSavePluginDataHolder
@OptIn(ConsoleExperimentalApi::class)
private val autoSaveIntervalMillis_: LongRange get() = owner_.autoSaveIntervalMillis
@OptIn(ConsoleExperimentalApi::class)
private lateinit var storage_: PluginDataStorage
@ConsoleExperimentalApi
public final override val saveName: String
get() = _saveName
@Suppress("JoinDeclarationAndAssignment") // bug
// bug
private lateinit var _saveName: String
public constructor(saveName: String) : this(null) {
_saveName = saveName
}
@OptIn(ConsoleInternalApi::class, ConsoleExperimentalApi::class)
private fun logException(e: Throwable) {
owner_.coroutineContext[CoroutineExceptionHandler]?.handleException(owner_.coroutineContext, e)
?.let { return }
@ -112,6 +120,7 @@ public open class AutoSavePluginData private constructor(
}
}
@OptIn(ConsoleExperimentalApi::class)
private fun doSave() {
debuggingLogger1.error { "doSave: ${this::class.qualifiedName}" }
storage_.store(owner_, this)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -277,7 +277,7 @@ public fun PluginData.value(default: String): SerializerAwareValue<String> = val
* - [MessageSerializers] 支持的所有类型, [MessageChain].
* - [PluginData.serializersModule] 自定义支持的类型
*/
@Suppress("UNCHECKED_CAST")
@OptIn(ConsoleExperimentalApi::class)
@LowPriorityInOverloadResolution
public inline fun <reified T> PluginData.value(
default: T,
@ -324,6 +324,7 @@ public inline fun <@ResolveContext(RESTRICTED_NO_ARG_CONSTRUCTOR) reified T>
PluginData.value(apply: T.() -> Unit = {}): SerializerAwareValue<@kotlin.internal.Exact T> =
valueImpl<T>(typeOf<T>(), T::class).also { it.value.apply() }
@OptIn(ConsoleExperimentalApi::class)
@Suppress("UNCHECKED_CAST")
@PublishedApi
internal fun <T> PluginData.valueImpl(type: KType, classifier: KClass<*>): SerializerAwareValue<T> =

View File

@ -1,10 +1,10 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
* 此源代码的使用受 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
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:Suppress("unused", "INAPPLICABLE_JVM_NAME", "INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@ -14,7 +14,6 @@ package net.mamoe.mirai.console.data
import net.mamoe.mirai.console.data.PluginDataExtensions.withDefault
import net.mamoe.mirai.console.internal.data.ShadowMap
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.utils.DeprecatedSinceMirai
import kotlin.internal.LowPriorityInOverloadResolution
/**
@ -39,6 +38,7 @@ public object PluginDataExtensions {
}
}
@OptIn(ConsoleExperimentalApi::class)
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") // as designed
public class NotNullMutableMap<K, V> internal constructor(
private val delegate: MutableMap<K, V>
@ -130,6 +130,7 @@ public object PluginDataExtensions {
/**
* 创建一个代理对象, [Map.get] 返回 `null` 时先调用 [defaultValueComputer] 并放入 [Map], 再返回调用的返回值
*/
@OptIn(ConsoleExperimentalApi::class)
@JvmStatic
@JvmName("withDefaultMapImmutableNotNull")
public fun <K, V : Any> SerializerAwareValue<Map<K, V>>.withDefault(defaultValueComputer: (K) -> V): SerializerAwareValue<NotNullMap<K, V>> {
@ -148,6 +149,7 @@ public object PluginDataExtensions {
return (this as SerializerAwareValue<MutableMap<K, V>>).withDefault(defaultValueComputer) as SerializerAwareValue<Map<K, V>>
}
@OptIn(ConsoleExperimentalApi::class)
@JvmStatic
@JvmName("withDefaultMapNotNull")
public fun <K, V : Any> SerializerAwareValue<MutableMap<K, V>>.withDefault(defaultValueComputer: (K) -> V): SerializerAwareValue<NotNullMutableMap<K, V>> {
@ -171,6 +173,7 @@ public object PluginDataExtensions {
/**
* 创建一个代理对象, [Map.get] 返回 `null` 时先调用 [defaultValueComputer] 并放入 [Map], 再返回调用的返回值
*/
@OptIn(ConsoleExperimentalApi::class)
@LowPriorityInOverloadResolution
@JvmStatic
@JvmName("withDefaultMap")
@ -218,6 +221,7 @@ public object PluginDataExtensions {
/**
* 替换 [MutableMap] key
*/
@OptIn(ConsoleExperimentalApi::class)
@JvmName("mapKeysNotNull")
@JvmStatic
public fun <OldK, NewK, V : Any> SerializerAwareValue<NotNullMutableMap<OldK, V>>.mapKeys(
@ -246,6 +250,7 @@ public object PluginDataExtensions {
/**
* 替换 [MutableMap] key
*/
@OptIn(ConsoleExperimentalApi::class)
@JvmName("mapKeys")
@JvmStatic
public fun <OldK, NewK, V> SerializerAwareValue<MutableMap<OldK, V>>.mapKeys(
@ -272,6 +277,7 @@ public object PluginDataExtensions {
/**
* 替换 [Map] key
*/
@OptIn(ConsoleExperimentalApi::class)
@JvmName("mapKeysImmutable")
@JvmStatic
public fun <OldK, NewK, V> SerializerAwareValue<Map<OldK, V>>.mapKeys(
@ -300,6 +306,7 @@ public object PluginDataExtensions {
/**
* 替换 [Map] key
*/
@OptIn(ConsoleExperimentalApi::class)
@JvmName("mapKeysImmutableNotNull")
@JvmStatic
public fun <OldK, NewK, V : Any> SerializerAwareValue<NotNullMap<OldK, V>>.mapKeys(

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -25,6 +25,7 @@ public open class ReadOnlyPluginData private constructor(
// KEEP THIS PRIMARY CONSTRUCTOR FOR FUTURE USE: WE'LL SUPPORT SERIALIZERS_MODULE FOR POLYMORPHISM
@Suppress("UNUSED_PARAMETER") primaryConstructorMark: Any?,
) : AbstractPluginData() {
@ConsoleExperimentalApi
public final override val saveName: String
get() = _saveName

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -230,6 +230,7 @@ public interface CompositeValue<T> : Value<T>
* @see [CompositeListValue]
* @see [PrimitiveListValue]
*/
@OptIn(ConsoleExperimentalApi::class)
public interface ListValue<E> : CompositeValue<List<E>>
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -8,6 +8,7 @@
*/
@file:Suppress("unused", "EXPOSED_SUPER_CLASS")
@file:OptIn(ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.data.java
@ -16,6 +17,7 @@ import net.mamoe.mirai.console.internal.data.cast
import net.mamoe.mirai.console.internal.data.setValueBySerializer
import net.mamoe.mirai.console.internal.data.valueImpl
import net.mamoe.mirai.console.plugin.jvm.JvmPlugin
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.console.util.JavaFriendlyApi
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentMap

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -13,9 +13,11 @@ import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors
import net.mamoe.mirai.console.command.resolve.CommandCallInterceptor
import net.mamoe.mirai.console.extension.AbstractInstanceExtensionPoint
import net.mamoe.mirai.console.extension.InstanceExtension
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
@ExperimentalCommandDescriptors
public interface CommandCallInterceptorProvider : InstanceExtension<CommandCallInterceptor> {
@OptIn(ConsoleExperimentalApi::class)
@ExperimentalCommandDescriptors
public companion object ExtensionPoint :
AbstractInstanceExtensionPoint<CommandCallInterceptorProvider, CommandCallInterceptor>(

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -13,12 +13,14 @@ import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors
import net.mamoe.mirai.console.command.parse.CommandCallParser
import net.mamoe.mirai.console.extension.AbstractInstanceExtensionPoint
import net.mamoe.mirai.console.extension.InstanceExtension
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
/**
* The provider of [CommandCallParser]
*/
@ExperimentalCommandDescriptors
public interface CommandCallParserProvider : InstanceExtension<CommandCallParser> {
@OptIn(ConsoleExperimentalApi::class)
@ExperimentalCommandDescriptors
public companion object ExtensionPoint :
AbstractInstanceExtensionPoint<CommandCallParserProvider, CommandCallParser>(CommandCallParserProvider::class)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -13,10 +13,12 @@ import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors
import net.mamoe.mirai.console.command.resolve.CommandCallResolver
import net.mamoe.mirai.console.extension.AbstractInstanceExtensionPoint
import net.mamoe.mirai.console.extension.InstanceExtension
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
@ExperimentalCommandDescriptors
public interface CommandCallResolverProvider : InstanceExtension<CommandCallResolver> {
@OptIn(ConsoleExperimentalApi::class)
@ExperimentalCommandDescriptors
public companion object ExtensionPoint :
AbstractInstanceExtensionPoint<CommandCallResolverProvider, CommandCallResolver>(CommandCallResolverProvider::class)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -12,6 +12,7 @@ package net.mamoe.mirai.console.extensions
import net.mamoe.mirai.console.extension.AbstractInstanceExtensionPoint
import net.mamoe.mirai.console.extension.InstanceExtension
import net.mamoe.mirai.console.permission.PermissionService
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.utils.DeprecatedSinceMirai
/**
@ -21,6 +22,7 @@ import net.mamoe.mirai.utils.DeprecatedSinceMirai
*/
public interface PermissionServiceProvider : InstanceExtension<PermissionService<*>> {
@OptIn(ConsoleExperimentalApi::class)
public companion object ExtensionPoint :
AbstractInstanceExtensionPoint<PermissionServiceProvider, PermissionService<*>>(PermissionServiceProvider::class)
// ! BREAKING CHANGE MADE IN 2.11: supertype changed from AbstractSingletonExtensionPoint to AbstractInstanceExtensionPoint

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -17,6 +17,7 @@ import net.mamoe.mirai.console.internal.extension.GlobalComponentStorage
import net.mamoe.mirai.console.internal.extension.SingletonExtensionSelectorImpl
import net.mamoe.mirai.console.plugin.Plugin
import net.mamoe.mirai.console.plugin.name
import net.mamoe.mirai.console.util.ConsoleInternalApi
import net.mamoe.mirai.utils.DeprecatedSinceMirai
import net.mamoe.mirai.utils.info
import kotlin.reflect.KClass
@ -66,6 +67,7 @@ public interface SingletonExtensionSelector : FunctionExtension {
internal val instance: SingletonExtensionSelector get() = instanceField ?: error("")
@OptIn(ConsoleInternalApi::class)
internal fun init() {
check(instanceField == null) { "Internal error: reinitialize SingletonExtensionSelector" }
val instances = GlobalComponentStorage.getExtensions<SingletonExtensionSelector>(ExtensionPoint).toList()

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,7 +7,10 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleExperimentalApi::class)
@file:OptIn(
ConsoleExperimentalApi::class, ConsoleFrontEndImplementation::class, ConsoleInternalApi::class,
MiraiInternalApi::class, MiraiExperimentalApi::class
)
package net.mamoe.mirai.console.internal
@ -17,6 +20,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import me.him188.kotlin.dynamic.delegation.dynamicDelegation
import net.mamoe.mirai.Bot
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MalformedMiraiConsoleImplementationError
import net.mamoe.mirai.console.MiraiConsole
import net.mamoe.mirai.console.MiraiConsoleImplementation
@ -57,10 +61,7 @@ import net.mamoe.mirai.console.permission.PermissionService.Companion.permit
import net.mamoe.mirai.console.permission.RootPermission
import net.mamoe.mirai.console.plugin.PluginManager
import net.mamoe.mirai.console.plugin.name
import net.mamoe.mirai.console.util.AnsiMessageBuilder
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.console.util.ConsoleInput
import net.mamoe.mirai.console.util.SemVersion
import net.mamoe.mirai.console.util.*
import net.mamoe.mirai.console.util.cast
import net.mamoe.mirai.event.broadcast
import net.mamoe.mirai.utils.*
@ -174,7 +175,6 @@ internal class MiraiConsoleImplementationBridge(
return MiraiLogger.Factory.create(MiraiConsole::class, identity)
}
@Suppress("RemoveRedundantBackticks")
internal fun doStart() {
externalImplementation.preStart()

View File

@ -13,6 +13,7 @@ import net.mamoe.mirai.auth.BotAuthInfo
import net.mamoe.mirai.auth.BotAuthResult
import net.mamoe.mirai.auth.BotAuthSession
import net.mamoe.mirai.auth.BotAuthorization
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsoleImplementation
import java.io.ByteArrayOutputStream
@ -24,6 +25,7 @@ internal class ConsoleBotAuthorization(
return delegate.invoke(session, info)
}
@OptIn(ConsoleFrontEndImplementation::class)
override fun calculateSecretsKey(bot: BotAuthInfo): ByteArray {
val calc = MiraiConsoleImplementation.getBridge().consoleSecretsCalculator

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,10 +7,13 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleFrontEndImplementation::class, ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.command
import kotlinx.atomicfu.locks.withLock
import kotlinx.coroutines.CoroutineScope
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsoleImplementation.ConsoleDataScope.Companion.get
import net.mamoe.mirai.console.command.*
import net.mamoe.mirai.console.command.Command.Companion.allNames
@ -24,9 +27,9 @@ import net.mamoe.mirai.console.command.resolve.getOrElse
import net.mamoe.mirai.console.internal.data.builtins.DataScope
import net.mamoe.mirai.console.internal.util.ifNull
import net.mamoe.mirai.console.permission.PermissionService.Companion.testPermission
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.message.data.Message
import net.mamoe.mirai.message.data.toMessageChain
import net.mamoe.mirai.utils.MiraiLogger
import net.mamoe.mirai.utils.childScope
import java.lang.reflect.InvocationTargetException
import java.util.concurrent.locks.ReentrantLock
@ -36,11 +39,8 @@ import kotlin.coroutines.CoroutineContext
internal class CommandManagerImpl(
parentCoroutineContext: CoroutineContext
) : CommandManager, CoroutineScope by parentCoroutineContext.childScope("CommandManagerImpl") {
private val logger: MiraiLogger by lazy {
MiraiLogger.Factory.create(CommandManager::class, "command")
}
@Suppress("ObjectPropertyName")
@Suppress("PropertyName")
@JvmField
internal val _registeredCommands: MutableList<Command> = mutableListOf()

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,6 +7,8 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.command
import net.mamoe.mirai.console.command.*

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,16 +7,20 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleFrontEndImplementation::class, ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.command.builtin
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.launch
import net.mamoe.mirai.Bot
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsole
import net.mamoe.mirai.console.MiraiConsoleImplementation.ConsoleDataScope.Companion.get
import net.mamoe.mirai.console.command.*
import net.mamoe.mirai.console.internal.data.builtins.AutoLoginConfig
import net.mamoe.mirai.console.internal.data.builtins.DataScope
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.console.util.scopeWith
import net.mamoe.mirai.message.nextMessageOrNull
import net.mamoe.mirai.utils.BotConfiguration
@ -36,7 +40,7 @@ internal open class LoginCommandImpl : SimpleCommand(
bot.login()
this
}.onFailure { bot.close() }.getOrThrow()
} // workaround since LoginCommand is object
} // workaround since LoginCommand is an object
@Handler
suspend fun CommandSender.handle(

View File

@ -1,17 +1,19 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
* 此源代码的使用受 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
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:Suppress("unused")
@file:OptIn(ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.data
import net.mamoe.mirai.console.data.*
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
// type inference bug

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,12 +7,15 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.data
import net.mamoe.mirai.console.data.MemoryPluginDataStorage
import net.mamoe.mirai.console.data.PluginData
import net.mamoe.mirai.console.data.PluginDataHolder
import net.mamoe.mirai.console.data.PluginDataStorage
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
internal class MemoryPluginDataStorageImpl : PluginDataStorage, MemoryPluginDataStorage,
MutableMap<Class<out PluginData>, PluginData> by mutableMapOf() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,6 +7,8 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.data
import kotlinx.serialization.json.Json

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -8,9 +8,11 @@
*/
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "EXPOSED_SUPER_CLASS")
@file:OptIn(ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.data
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.builtins.serializer
@ -23,6 +25,7 @@ import net.mamoe.mirai.console.data.AbstractPluginData.ValueNode
import net.mamoe.mirai.console.data.PluginData
import net.mamoe.mirai.console.data.ValueDescription
import net.mamoe.mirai.console.data.ValueName
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.yamlkt.Comment
import net.mamoe.yamlkt.YamlNullableDynamicSerializer
import java.lang.reflect.Constructor
@ -44,6 +47,7 @@ internal abstract class PluginDataImpl {
return valueNodes.firstOrNull { it.valueName == name }
}
@OptIn(ExperimentalSerializationApi::class)
internal open val updaterSerializer: KSerializer<Unit> = object : KSerializer<Unit> {
override val descriptor: SerialDescriptor by lazy {
check(this@PluginDataImpl is AbstractPluginData)
@ -54,11 +58,10 @@ internal abstract class PluginDataImpl {
}
}
@Suppress("UNCHECKED_CAST")
override fun deserialize(decoder: Decoder) {
val descriptor = descriptor
with(decoder.beginStructure(descriptor)) {
if (decodeSequentially()) {
if (runCatching { decodeSequentially() }.getOrElse { false }) {
var index = 0
repeat(decodeCollectionSize(descriptor)) {
val valueName = decodeSerializableElement(descriptor, index++, String.serializer())
@ -95,7 +98,6 @@ internal abstract class PluginDataImpl {
}
}
@Suppress("UNCHECKED_CAST")
override fun serialize(encoder: Encoder, value: Unit) {
check(this@PluginDataImpl is AbstractPluginData)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,12 +7,15 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.data
import kotlinx.serialization.builtins.serializer
import net.mamoe.mirai.console.data.PluginData
import net.mamoe.mirai.console.data.ReferenceValue
import net.mamoe.mirai.console.data.SerializerAwareValue
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import kotlin.reflect.KClass

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,6 +7,8 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.data
import kotlinx.serialization.KSerializer
@ -15,6 +17,7 @@ import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import net.mamoe.mirai.console.data.*
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
/**
* The super class to all ValueImpl

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,14 +7,18 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleFrontEndImplementation::class, ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.data.builtins
import kotlinx.coroutines.CoroutineScope
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsoleImplementation
import net.mamoe.mirai.console.data.AutoSavePluginDataHolder
import net.mamoe.mirai.console.data.PluginConfig
import net.mamoe.mirai.console.data.PluginData
import net.mamoe.mirai.console.data.PluginDataStorage
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.utils.TestOnly
import net.mamoe.mirai.utils.childScope
import net.mamoe.mirai.utils.minutesToMillis

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -15,11 +15,13 @@ import net.mamoe.mirai.console.data.ReadOnlyPluginConfig
import net.mamoe.mirai.console.data.ValueDescription
import net.mamoe.mirai.console.data.value
import net.mamoe.mirai.console.logging.AbstractLoggerController
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.utils.MiraiExperimentalApi
@ConsoleFrontEndImplementation
@MiraiExperimentalApi
public class LoggerConfig : ReadOnlyPluginConfig("Logger") {
@ConsoleExperimentalApi
@ValueDescription(
"""
默认日志输出等级
@ -28,6 +30,7 @@ public class LoggerConfig : ReadOnlyPluginConfig("Logger") {
)
public val defaultPriority: AbstractLoggerController.LogPriority by value(AbstractLoggerController.LogPriority.INFO)
@ConsoleExperimentalApi
@ValueDescription(
"""
特定日志记录器输出等级

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -11,6 +11,7 @@
package net.mamoe.mirai.console.internal.data
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.builtins.*
import kotlinx.serialization.descriptors.SerialDescriptor
@ -27,6 +28,7 @@ import kotlin.reflect.KClass
import kotlin.reflect.KType
@OptIn(ExperimentalSerializationApi::class)
@Suppress("UNCHECKED_CAST")
internal fun SerializersModule.serializerMirai(type: KType): KSerializer<Any?> {
fun serializerByKTypeImpl(type: KType): KSerializer<*> {
@ -69,6 +71,7 @@ internal fun SerializersModule.serializerMirai(type: KType): KSerializer<Any?> {
serializers[0],
serializers[1]
)
Map.Entry::class -> MapEntrySerializer(serializers[0], serializers[1])
Pair::class -> PairSerializer(serializers[0], serializers[1])
Triple::class -> TripleSerializer(serializers[0], serializers[1], serializers[2])
@ -102,11 +105,9 @@ internal fun SerializersModule.serializerMirai(type: KType): KSerializer<Any?> {
*/
@Suppress(
"UNCHECKED_CAST",
"NO_REFLECTION_IN_CLASS_PATH",
"UNSUPPORTED",
"INVISIBLE_MEMBER",
"INVISIBLE_REFERENCE",
"IMPLICIT_CAST_TO_ANY"
)
private fun <T : Any> KClass<T>.constructSerializerForGivenTypeArgs(vararg args: KSerializer<Any?>): KSerializer<T>? {
val jClass = this.java

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -8,6 +8,7 @@
*/
@file:Suppress("NOTHING_TO_INLINE", "INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@file:OptIn(ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.data
@ -16,6 +17,7 @@ import net.mamoe.mirai.console.data.PluginData
import net.mamoe.mirai.console.data.SerializableValue.Companion.serializableValueWith
import net.mamoe.mirai.console.data.SerializerAwareValue
import net.mamoe.mirai.console.data.valueFromKType
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.utils.createInstanceOrNull
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentMap

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,13 +7,17 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleFrontEndImplementation::class, ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.extension
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsoleImplementation
import net.mamoe.mirai.console.extension.*
import net.mamoe.mirai.console.internal.data.kClassQualifiedNameOrTip
import net.mamoe.mirai.console.plugin.Plugin
import net.mamoe.mirai.console.plugin.name
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import java.util.*
import java.util.concurrent.ConcurrentHashMap
import java.util.stream.Stream

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -8,6 +8,7 @@
*/
@file:Suppress("DEPRECATION_ERROR")
@file:OptIn(ConsoleInternalApi::class)
package net.mamoe.mirai.console.internal.extension
@ -20,6 +21,7 @@ import net.mamoe.mirai.console.extensions.SingletonExtensionSelector
import net.mamoe.mirai.console.internal.data.kClassQualifiedName
import net.mamoe.mirai.console.plugin.name
import net.mamoe.mirai.console.util.ConsoleInput
import net.mamoe.mirai.console.util.ConsoleInternalApi
import net.mamoe.mirai.utils.DeprecatedSinceMirai
import net.mamoe.mirai.utils.info
import kotlin.reflect.KClass

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,10 +7,15 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleFrontEndImplementation::class, MiraiExperimentalApi::class, ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.logging
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.internal.data.builtins.LoggerConfig
import net.mamoe.mirai.console.logging.AbstractLoggerController
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.utils.MiraiExperimentalApi
internal class LoggerControllerImpl : AbstractLoggerController.PathBased() {
// 防止 stack overflow (使用 logger 要加载 LoggerController, LoggerConfig 可能会使用 logger)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,9 +7,12 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.logging
import net.mamoe.mirai.console.logging.LoggerController
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.utils.MiraiLogger
import net.mamoe.mirai.utils.MiraiLoggerPlatformBase
import net.mamoe.mirai.utils.SimpleLogger

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,11 +7,15 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleFrontEndImplementation::class, MiraiExperimentalApi::class)
package net.mamoe.mirai.console.internal.logging.externalbind.slf4j
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsoleImplementation.ConsoleDataScope.Companion.get
import net.mamoe.mirai.console.internal.data.builtins.DataScope
import net.mamoe.mirai.console.internal.data.builtins.LoggerConfig
import net.mamoe.mirai.utils.MiraiExperimentalApi
import net.mamoe.mirai.utils.MiraiLogger
import net.mamoe.mirai.utils.safeCast
import org.slf4j.ILoggerFactory

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,6 +7,8 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.permission
import kotlinx.serialization.Serializable
@ -16,6 +18,7 @@ import net.mamoe.mirai.console.data.PluginDataExtensions.withDefault
import net.mamoe.mirai.console.data.value
import net.mamoe.mirai.console.extensions.PermissionServiceProvider
import net.mamoe.mirai.console.permission.*
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.CopyOnWriteArraySet
import kotlin.reflect.KClass

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,11 +7,14 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleFrontEndImplementation::class, ConsoleExperimentalApi::class, MiraiInternalApi::class)
package net.mamoe.mirai.console.internal.plugin
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ensureActive
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsole
import net.mamoe.mirai.console.MiraiConsoleImplementation
import net.mamoe.mirai.console.data.PluginDataStorage
@ -24,6 +27,7 @@ import net.mamoe.mirai.console.plugin.jvm.*
import net.mamoe.mirai.console.plugin.loader.AbstractFilePluginLoader
import net.mamoe.mirai.console.plugin.loader.PluginLoadException
import net.mamoe.mirai.console.plugin.name
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.utils.*
import java.io.File
import java.nio.file.Path
@ -45,7 +49,7 @@ internal class BuiltInJvmPluginLoaderImpl(
MiraiLogger.Factory.create(JvmPluginLoader::class)
}
fun pluginsFilesSequence(
private fun pluginsFilesSequence(
files: Sequence<File> = PluginManager.pluginsFolder.listFiles().orEmpty().asSequence()
): Sequence<File> {
val raw = files
@ -74,7 +78,7 @@ internal class BuiltInJvmPluginLoaderImpl(
get() = MiraiConsoleImplementation.getInstance().dataStorageForJvmPluginLoader
internal val jvmPluginLoadingCtx: JvmPluginsLoadingCtx by lazy {
private val jvmPluginLoadingCtx: JvmPluginsLoadingCtx by lazy {
val legacyCompatibilityLayerClassLoader = LegacyCompatibilityLayerClassLoader.newInstance(
BuiltInJvmPluginLoaderImpl::class.java.classLoader,
)
@ -166,7 +170,6 @@ internal class BuiltInJvmPluginLoaderImpl(
}
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // doesn't matter
override fun getPluginDescription(plugin: JvmPlugin): JvmPluginDescription = plugin.description
private val pluginFileToInstanceMap: MutableMap<File, JvmPlugin> = ConcurrentHashMap()

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,9 +7,12 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.plugin
import net.mamoe.mirai.console.plugin.jvm.ExportManager
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
internal class ExportManagerImpl(
private val rules: List<(String) -> Boolean?>

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,11 +7,13 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:Suppress("MemberVisibilityCanBePrivate")
@file:OptIn(ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.plugin
import net.mamoe.mirai.console.plugin.jvm.ExportManager
import net.mamoe.mirai.console.plugin.jvm.JvmPluginClasspath
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.utils.*
import org.eclipse.aether.artifact.Artifact
import org.eclipse.aether.graph.DependencyFilter
@ -22,7 +24,6 @@ import java.net.URLClassLoader
import java.util.*
import java.util.concurrent.atomic.AtomicBoolean
import java.util.zip.ZipFile
import kotlin.collections.LinkedHashSet
/*
Class resolving:

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,8 +7,11 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleFrontEndImplementation::class)
package net.mamoe.mirai.console.internal.plugin
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsoleImplementation
import net.mamoe.mirai.console.MiraiConsoleImplementation.ConsoleDataScope.Companion.get
import net.mamoe.mirai.console.fontend.ProcessProgress

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,12 +7,15 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(MiraiInternalApi::class, ConsoleFrontEndImplementation::class, ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.internal.plugin
import kotlinx.atomicfu.AtomicLong
import kotlinx.atomicfu.atomic
import kotlinx.atomicfu.locks.withLock
import kotlinx.coroutines.*
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsole
import net.mamoe.mirai.console.MiraiConsoleImplementation
import net.mamoe.mirai.console.data.runCatchingLog
@ -31,6 +34,8 @@ import net.mamoe.mirai.console.plugin.jvm.AbstractJvmPlugin
import net.mamoe.mirai.console.plugin.jvm.JvmPlugin
import net.mamoe.mirai.console.plugin.jvm.JvmPlugin.Companion.onLoad
import net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.utils.MiraiInternalApi
import net.mamoe.mirai.utils.MiraiLogger
import net.mamoe.mirai.utils.safeCast
import java.io.File

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,6 +7,8 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleInternalApi::class)
package net.mamoe.mirai.console.internal.shutdown
import kotlinx.coroutines.*
@ -14,6 +16,7 @@ import net.mamoe.mirai.console.MiraiConsole
import net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge
import net.mamoe.mirai.console.internal.pluginManagerImpl
import net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.description
import net.mamoe.mirai.console.util.ConsoleInternalApi
import net.mamoe.mirai.utils.debug
import java.io.File
import java.io.FileDescriptor

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,10 +7,13 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleFrontEndImplementation::class)
package net.mamoe.mirai.console.internal.util
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsoleImplementation
import net.mamoe.mirai.console.util.ConsoleInput

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -8,11 +8,13 @@
*/
@file:Suppress("unused")
@file:OptIn(MiraiInternalApi::class)
package net.mamoe.mirai.console.internal.util
import net.mamoe.mirai.console.internal.data.cast
import net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader
import net.mamoe.mirai.utils.MiraiInternalApi
import net.mamoe.mirai.utils.createInstanceOrNull
import java.lang.reflect.Modifier
import java.util.*

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,10 +7,11 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:Suppress("NOTHING_TO_INLINE", "unused", "MemberVisibilityCanBePrivate")
@file:Suppress("unused", "MemberVisibilityCanBePrivate")
package net.mamoe.mirai.console.permission
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsoleImplementation
import net.mamoe.mirai.console.compiler.common.ResolveContext
import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.COMMAND_NAME
@ -22,6 +23,7 @@ import net.mamoe.mirai.console.permission.Permission.Companion.parentsWithSelf
import net.mamoe.mirai.console.plugin.Plugin
import net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.description
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.utils.MiraiExperimentalApi
import kotlin.reflect.KClass
/**
@ -147,6 +149,7 @@ public interface PermissionService<P : Permission> {
*/
@get:JvmName("getInstance")
@JvmStatic
@OptIn(ConsoleFrontEndImplementation::class, MiraiExperimentalApi::class)
public val INSTANCE: PermissionService<out Permission>
get() {
if (!MiraiConsoleImplementation.getBridge().permissionSeviceLoaded) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -166,6 +166,7 @@ public interface PermitteeId {
* ExactTemp
* ```
*/
@OptIn(ConsoleExperimentalApi::class)
@Serializable(with = AsStringSerializer::class)
public sealed class AbstractPermitteeId(
public final override vararg val directParents: PermitteeId,

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -32,6 +32,7 @@ import kotlin.reflect.KClass
* @see JavaPlugin
* @see KotlinPlugin
*/
@OptIn(ConsoleExperimentalApi::class)
public abstract class AbstractJvmPlugin @JvmOverloads constructor(
parentCoroutineContext: CoroutineContext = EmptyCoroutineContext,
) : JvmPlugin, JvmPluginInternal(parentCoroutineContext), AutoSavePluginDataHolder {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -11,10 +11,12 @@ package net.mamoe.mirai.console.plugin.jvm
import kotlinx.coroutines.CoroutineScope
import me.him188.kotlin.dynamic.delegation.dynamicDelegation
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsoleImplementation
import net.mamoe.mirai.console.data.PluginDataStorage
import net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl
import net.mamoe.mirai.console.plugin.loader.FilePluginLoader
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.utils.MiraiInternalApi
import net.mamoe.mirai.utils.NotStableForInheritance
@ -31,11 +33,13 @@ public interface JvmPluginLoader : CoroutineScope, FilePluginLoader<JvmPlugin, J
/**
* [AbstractJvmPlugin.reloadPluginData] 默认使用的实例
*/
@ConsoleExperimentalApi
public val dataStorage: PluginDataStorage
/**
* [AbstractJvmPlugin.reloadPluginData] 默认使用的实例
*/
@ConsoleExperimentalApi
public val configStorage: PluginDataStorage
/**
@ -48,9 +52,11 @@ public interface JvmPluginLoader : CoroutineScope, FilePluginLoader<JvmPlugin, J
public fun findLoadedClass(name: String): Class<*>?
public companion object BuiltIn :
JvmPluginLoader by (dynamicDelegation { MiraiConsoleImplementation.getInstance().jvmPluginLoader }) {
JvmPluginLoader by (dynamicDelegation {
@OptIn(ConsoleFrontEndImplementation::class)
MiraiConsoleImplementation.getInstance().jvmPluginLoader
}) {
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
override fun getPluginDescription(plugin: JvmPlugin): JvmPluginDescription =
BuiltInJvmPluginLoaderImpl.run { plugin.description }
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -97,7 +97,6 @@ public open class AnsiMessageBuilder public constructor(
/**
* 判断 [sender] 是否支持带 ansi 控制符的正确显示
*/
@ConsoleExperimentalApi
@JvmStatic
public fun isAnsiSupported(sender: CommandSender): Boolean =
if (sender is SystemCommandSender) {
@ -117,8 +116,7 @@ public open class AnsiMessageBuilder public constructor(
if (other == null) return false
if (other::class.java != this::class.java) return false
other as AnsiMessageBuilder
if (other.delegate != this.delegate) return false
return true
return other.delegate == this.delegate
}
/////////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -579,6 +579,7 @@ internal fun MessageScope.asSequence(): Sequence<MessageScope> {
} else sequenceOf(this)
}
@OptIn(ConsoleExperimentalApi::class)
private class CombinedScope(
val first: MessageScope,
val second: MessageScope,
@ -602,6 +603,7 @@ private class CombinedScope(
}
}
@OptIn(ConsoleExperimentalApi::class)
private class CommandSenderAsMessageScope(
private val sender: CommandSender,
) : MessageScope {
@ -621,6 +623,7 @@ private class CommandSenderAsMessageScope(
}
}
@OptIn(ConsoleExperimentalApi::class)
private class ContactAsMessageScope(
private val sender: Contact,
) : MessageScope {
@ -636,6 +639,7 @@ private class ContactAsMessageScope(
}
}
@OptIn(ConsoleExperimentalApi::class)
private object NoopMessageScope : MessageScope {
override val realTarget: Any?
get() = null

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -10,6 +10,7 @@
package net.mamoe.mirai.console.frontendbase
import kotlinx.coroutines.*
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsole
import net.mamoe.mirai.console.MiraiConsoleImplementation
import net.mamoe.mirai.console.command.CommandManager
@ -17,6 +18,9 @@ import net.mamoe.mirai.console.data.MultiFilePluginDataStorage
import net.mamoe.mirai.console.data.PluginDataStorage
import net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader
import net.mamoe.mirai.console.plugin.loader.PluginLoader
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.console.util.ConsoleInternalApi
import net.mamoe.mirai.utils.MiraiInternalApi
import net.mamoe.mirai.utils.MiraiLogger
import net.mamoe.mirai.utils.PlatformLogger
import kotlin.coroutines.CoroutineContext
@ -27,11 +31,13 @@ import kotlin.coroutines.CoroutineContext
* @param frontendCoroutineName 该前端的名字, `"MiraiConsoleImplementationTerminal"`
* @see FrontendBase
*/
@OptIn(ConsoleFrontEndImplementation::class)
public abstract class AbstractMiraiConsoleFrontendImplementation(
frontendCoroutineName: String,
) : MiraiConsoleImplementation, CoroutineScope {
// region 此 region 的 字段 / 方法 为 console 默认/内部 实现, 如无必要不建议修改
@OptIn(ConsoleInternalApi::class)
private val delegateCoroutineScope by lazy {
CoroutineScope(
SupervisorJob() +
@ -51,19 +57,28 @@ public abstract class AbstractMiraiConsoleFrontendImplementation(
override val jvmPluginLoader: JvmPluginLoader by lazy { backendAccess.createDefaultJvmPluginLoader(coroutineContext) }
override val commandManager: CommandManager by lazy { backendAccess.createDefaultCommandManager(coroutineContext) }
override val consoleDataScope: MiraiConsoleImplementation.ConsoleDataScope by lazy {
@OptIn(ConsoleExperimentalApi::class)
MiraiConsoleImplementation.ConsoleDataScope.createDefault(
coroutineContext, dataStorageForBuiltIns, configStorageForBuiltIns
)
}
@ConsoleExperimentalApi
override val dataStorageForJvmPluginLoader: PluginDataStorage by lazy {
MultiFilePluginDataStorage(rootPath.resolve("data"))
}
@ConsoleExperimentalApi
override val dataStorageForBuiltIns: PluginDataStorage by lazy {
MultiFilePluginDataStorage(rootPath.resolve("data"))
}
@ConsoleExperimentalApi
override val configStorageForJvmPluginLoader: PluginDataStorage by lazy {
MultiFilePluginDataStorage(rootPath.resolve("config"))
}
@ConsoleExperimentalApi
override val configStorageForBuiltIns: PluginDataStorage by lazy {
MultiFilePluginDataStorage(rootPath.resolve("config"))
}
@ -75,6 +90,7 @@ public abstract class AbstractMiraiConsoleFrontendImplementation(
// region Logging
@OptIn(MiraiInternalApi::class)
override fun createLoggerFactory(context: MiraiConsoleImplementation.FrontendLoggingInitContext): MiraiLogger.Factory {
@Suppress("INVISIBLE_MEMBER")
frontendBase.initScreen_forwardStdToScreen()

View File

@ -19,6 +19,11 @@ plugins {
val shadow: Configuration = project.configurations.create("shadow")
kotlin {
optInForTestSourceSets("net.mamoe.mirai.console.util.ConsoleExperimentalApi")
optInForTestSourceSets("net.mamoe.mirai.console.ConsoleFrontEndImplementation")
}
dependencies {
api(project(":mirai-core-api"))
api(project(":mirai-console"))

View File

@ -1,10 +1,10 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
* 此源代码的使用受 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
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
/*
* @author Karlatemp <karlatemp@vip.qq.com> <https://github.com/Karlatemp>
@ -12,6 +12,7 @@
package net.mamoe.mirai.console.terminal
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsoleImplementation
@Retention(AnnotationRetention.BINARY)
@ -29,8 +30,11 @@ annotation class ConsoleTerminalExperimentalApi
@ConsoleTerminalExperimentalApi
object ConsoleTerminalSettings {
@ConsoleFrontEndImplementation
@JvmField
var launchOptions: MiraiConsoleImplementation.ConsoleLaunchOptions = MiraiConsoleImplementation.ConsoleLaunchOptions()
var launchOptions: MiraiConsoleImplementation.ConsoleLaunchOptions =
MiraiConsoleImplementation.ConsoleLaunchOptions()
@JvmField
var setupAnsi: Boolean = System.getProperty("os.name")

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,7 +7,7 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ExperimentalCommandDescriptors::class)
@file:OptIn(ExperimentalCommandDescriptors::class, ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.terminal
@ -22,7 +22,7 @@ import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors
import net.mamoe.mirai.console.command.parse.CommandCall
import net.mamoe.mirai.console.command.parse.CommandValueArgument
import net.mamoe.mirai.console.terminal.noconsole.NoConsole
import net.mamoe.mirai.console.util.ConsoleInternalApi
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.console.util.cast
import net.mamoe.mirai.console.util.safeCast
import net.mamoe.mirai.utils.MiraiLogger
@ -34,7 +34,7 @@ import kotlin.reflect.full.isSubclassOf
val consoleLogger by lazy { MiraiLogger.Factory.create(MiraiConsole::class, "console") }
@OptIn(ConsoleInternalApi::class, ConsoleTerminalExperimentalApi::class, ExperimentalCommandDescriptors::class)
@OptIn(ExperimentalCommandDescriptors::class)
internal fun startupConsoleThread() {
if (terminal is NoConsole) return
@ -43,7 +43,7 @@ internal fun startupConsoleThread() {
delay(2000)
}
}.invokeOnCompletion {
runCatching<Unit> {
runCatching {
// 应该仅关闭用户输入
terminal.reader().shutdown()
}.exceptionOrNull()?.printStackTrace()

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -7,6 +7,8 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:OptIn(ConsoleExperimentalApi::class)
package net.mamoe.mirai.console.terminal
import kotlinx.coroutines.CancellableContinuation
@ -14,6 +16,7 @@ import kotlinx.coroutines.Runnable
import kotlinx.coroutines.isActive
import kotlinx.coroutines.suspendCancellableCoroutine
import net.mamoe.mirai.console.terminal.noconsole.NoConsole
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.utils.ConcurrentLinkedDeque
import net.mamoe.mirai.utils.cast
import org.jline.reader.MaskingCallback

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -15,11 +15,12 @@
"INVISIBLE_GETTER",
"INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER",
)
@file:OptIn(ConsoleInternalApi::class, ConsoleTerminalExperimentalApi::class)
@file:OptIn(ConsoleInternalApi::class, ConsoleTerminalExperimentalApi::class, ConsoleFrontEndImplementation::class)
package net.mamoe.mirai.console.terminal
import kotlinx.coroutines.*
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
import net.mamoe.mirai.console.MiraiConsole
import net.mamoe.mirai.console.MiraiConsoleImplementation
import net.mamoe.mirai.console.MiraiConsoleImplementation.Companion.start
@ -28,7 +29,10 @@ import net.mamoe.mirai.console.terminal.noconsole.SystemOutputPrintStream
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import net.mamoe.mirai.console.util.ConsoleInternalApi
import net.mamoe.mirai.message.data.Message
import net.mamoe.mirai.utils.*
import net.mamoe.mirai.utils.childScope
import net.mamoe.mirai.utils.debug
import net.mamoe.mirai.utils.info
import net.mamoe.mirai.utils.verbose
import org.jline.utils.Signals
import java.io.FileDescriptor
import java.io.FileOutputStream
@ -48,6 +52,7 @@ object MiraiConsoleTerminalLoader {
// Note: Do not run this in IDEA, as you will get invalid classpath and `java.lang.NoClassDefFoundError`.
// Run `RunTerminal.kt` under `test` source set instead.
@OptIn(ConsoleExperimentalApi::class)
@JvmStatic
fun main(args: Array<String>) {
parse(args, exitProcess = true)
@ -179,6 +184,7 @@ object MiraiConsoleTerminalLoader {
}
}
@OptIn(ConsoleExperimentalApi::class)
internal object ConsoleDataHolder : AutoSavePluginDataHolder,
CoroutineScope by MiraiConsole.childScope("ConsoleDataHolder") {
@ConsoleExperimentalApi
@ -194,6 +200,8 @@ private val shutdownSignals = arrayOf(
)
internal val signalHandler: (String) -> Unit = initSignalHandler()
@OptIn(ConsoleExperimentalApi::class)
private fun initSignalHandler(): (String) -> Unit {
val shutdownMonitorLock = AtomicBoolean(false)
val lastSignalTimestamp = AtomicLong(0)
@ -223,7 +231,7 @@ private fun initSignalHandler(): (String) -> Unit {
if (signalName !in shutdownSignals) return@handler
MiraiConsole.mainLogger.debug { "Handled signal $signalName" }
kotlin.run multiSignalHandler@{
run multiSignalHandler@{
val crtTime = System.currentTimeMillis()
val last = lastSignalTimestamp.getAndSet(crtTime)
if (crtTime - last < 1000L) {

View File

@ -131,6 +131,9 @@ public abstract interface class net/mamoe/mirai/IMirai : net/mamoe/mirai/LowLeve
public abstract fun setFileCacheStrategy (Lnet/mamoe/mirai/utils/FileCacheStrategy;)V
}
public abstract interface annotation class net/mamoe/mirai/LowLevelApi : java/lang/annotation/Annotation {
}
public abstract interface class net/mamoe/mirai/LowLevelApiAccessor {
public fun getGroupVoiceDownloadUrl (Lnet/mamoe/mirai/Bot;[BJJ)Ljava/lang/String;
public abstract fun getGroupVoiceDownloadUrl (Lnet/mamoe/mirai/Bot;[BJJLkotlin/coroutines/Continuation;)Ljava/lang/Object;
@ -3919,7 +3922,6 @@ public final class net/mamoe/mirai/message/data/Face$Companion {
public abstract interface class net/mamoe/mirai/message/data/FileMessage : net/mamoe/mirai/message/code/CodableMessage, net/mamoe/mirai/message/data/ConstrainSingle, net/mamoe/mirai/message/data/MessageContent {
public static final field Key Lnet/mamoe/mirai/message/data/FileMessage$Key;
public static final field SERIAL_NAME Ljava/lang/String;
public fun appendMiraiCodeTo (Ljava/lang/StringBuilder;)V
public fun contentToString ()Ljava/lang/String;
public static fun create (Ljava/lang/String;ILjava/lang/String;J)Lnet/mamoe/mirai/message/data/FileMessage;
public abstract fun getId ()Ljava/lang/String;
@ -4719,7 +4721,6 @@ public final class net/mamoe/mirai/message/data/MusicShare : net/mamoe/mirai/mes
public synthetic fun <init> (ILnet/mamoe/mirai/message/data/MusicKind;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Lnet/mamoe/mirai/message/data/MusicKind;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public fun <init> (Lnet/mamoe/mirai/message/data/MusicKind;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public fun appendMiraiCodeTo (Ljava/lang/StringBuilder;)V
public final fun component1 ()Lnet/mamoe/mirai/message/data/MusicKind;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
@ -5323,14 +5324,12 @@ public class net/mamoe/mirai/message/data/Voice : net/mamoe/mirai/message/data/P
public synthetic fun <init> (ILjava/lang/String;[BJILjava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;[BJILjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun contentToString ()Ljava/lang/String;
public fun equals (Ljava/lang/Object;)Z
public static final fun fromAudio (Lnet/mamoe/mirai/message/data/Audio;)Lnet/mamoe/mirai/message/data/Voice;
public fun getFileName ()Ljava/lang/String;
public fun getFileSize ()J
public fun getMd5 ()[B
public fun getUrl ()Ljava/lang/String;
public final fun get_codec ()I
public fun hashCode ()I
public final fun toAudio ()Lnet/mamoe/mirai/message/data/Audio;
public fun toString ()Ljava/lang/String;
public static final fun write$Self (Lnet/mamoe/mirai/message/data/Voice;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V

View File

@ -131,6 +131,9 @@ public abstract interface class net/mamoe/mirai/IMirai : net/mamoe/mirai/LowLeve
public abstract fun setFileCacheStrategy (Lnet/mamoe/mirai/utils/FileCacheStrategy;)V
}
public abstract interface annotation class net/mamoe/mirai/LowLevelApi : java/lang/annotation/Annotation {
}
public abstract interface class net/mamoe/mirai/LowLevelApiAccessor {
public fun getGroupVoiceDownloadUrl (Lnet/mamoe/mirai/Bot;[BJJ)Ljava/lang/String;
public abstract fun getGroupVoiceDownloadUrl (Lnet/mamoe/mirai/Bot;[BJJLkotlin/coroutines/Continuation;)Ljava/lang/Object;
@ -3919,7 +3922,6 @@ public final class net/mamoe/mirai/message/data/Face$Companion {
public abstract interface class net/mamoe/mirai/message/data/FileMessage : net/mamoe/mirai/message/code/CodableMessage, net/mamoe/mirai/message/data/ConstrainSingle, net/mamoe/mirai/message/data/MessageContent {
public static final field Key Lnet/mamoe/mirai/message/data/FileMessage$Key;
public static final field SERIAL_NAME Ljava/lang/String;
public fun appendMiraiCodeTo (Ljava/lang/StringBuilder;)V
public fun contentToString ()Ljava/lang/String;
public static fun create (Ljava/lang/String;ILjava/lang/String;J)Lnet/mamoe/mirai/message/data/FileMessage;
public abstract fun getId ()Ljava/lang/String;
@ -4719,7 +4721,6 @@ public final class net/mamoe/mirai/message/data/MusicShare : net/mamoe/mirai/mes
public synthetic fun <init> (ILnet/mamoe/mirai/message/data/MusicKind;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Lnet/mamoe/mirai/message/data/MusicKind;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public fun <init> (Lnet/mamoe/mirai/message/data/MusicKind;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public fun appendMiraiCodeTo (Ljava/lang/StringBuilder;)V
public final fun component1 ()Lnet/mamoe/mirai/message/data/MusicKind;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
@ -5323,14 +5324,12 @@ public class net/mamoe/mirai/message/data/Voice : net/mamoe/mirai/message/data/P
public synthetic fun <init> (ILjava/lang/String;[BJILjava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;[BJILjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun contentToString ()Ljava/lang/String;
public fun equals (Ljava/lang/Object;)Z
public static final fun fromAudio (Lnet/mamoe/mirai/message/data/Audio;)Lnet/mamoe/mirai/message/data/Voice;
public fun getFileName ()Ljava/lang/String;
public fun getFileSize ()J
public fun getMd5 ()[B
public fun getUrl ()Ljava/lang/String;
public final fun get_codec ()I
public fun hashCode ()I
public final fun toAudio ()Lnet/mamoe/mirai/message/data/Audio;
public fun toString ()Ljava/lang/String;
public static final fun write$Self (Lnet/mamoe/mirai/message/data/Voice;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -72,6 +72,7 @@ public val Mirai: IMirai
*
* @see Mirai 获取实例
*/
@OptIn(LowLevelApi::class, MiraiExperimentalApi::class)
@NotStableForInheritance
public interface IMirai : LowLevelApiAccessor {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -14,7 +14,9 @@ package net.mamoe.mirai
import kotlinx.coroutines.Job
import me.him188.kotlin.jvm.blocking.bridge.JvmBlockingBridge
import net.mamoe.mirai.contact.*
import net.mamoe.mirai.data.*
import net.mamoe.mirai.data.FriendInfo
import net.mamoe.mirai.data.MemberInfo
import net.mamoe.mirai.data.StrangerInfo
import net.mamoe.mirai.utils.MiraiExperimentalApi
import net.mamoe.mirai.utils.NotStableForInheritance
import kotlin.annotation.AnnotationTarget.*
@ -26,7 +28,7 @@ import kotlin.annotation.AnnotationTarget.*
* 使用低级的 API 无法带来任何安全和便捷保障.
* 仅在某些使用结构化 API 可能影响性能的情况下使用这些低级 API.
*/
@MiraiExperimentalApi
@LowLevelApi
@RequiresOptIn
@Retention(AnnotationRetention.BINARY)
@Target(CLASS, FUNCTION, PROPERTY, CONSTRUCTOR)

View File

@ -59,6 +59,7 @@ public interface BotAuthorization {
/**
* 计算 `cache/account.secrets` 的加密秘钥
*/
@OptIn(MiraiInternalApi::class)
public fun calculateSecretsKey(
bot: BotAuthInfo,
): ByteArray = bot.deviceInfo.guid + bot.id.toByteArray()

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -32,7 +32,10 @@ public class ContactList<out C : Contact>
/**
* 获取一个 [Contact.id] [id] 的元素. 在不存在时返回 `null`.
*/
public operator fun get(id: Long): C? = delegate.firstOrNull { it.id == id }
public operator fun get(id: Long): C? {
@OptIn(MiraiInternalApi::class)
return delegate.firstOrNull { it.id == id }
}
/**
* 获取一个 [Contact.id] [id] 的元素. 在不存在时抛出 [NoSuchElementException].
@ -42,14 +45,28 @@ public class ContactList<out C : Contact>
/**
* 删除 [Contact.id] [id] 的元素.
*/
public fun remove(id: Long): Boolean = delegate.removeAll { it.id == id }
public fun remove(id: Long): Boolean {
@OptIn(MiraiInternalApi::class)
return delegate.removeAll { it.id == id }
}
/**
* 当存在 [Contact.id] [id] 的元素时返回 `true`.
*/
public operator fun contains(id: Long): Boolean = get(id) != null
override fun toString(): String = delegate.joinToString(separator = ", ", prefix = "ContactList(", postfix = ")")
override fun equals(other: Any?): Boolean = other is ContactList<*> && delegate == other.delegate
override fun hashCode(): Int = delegate.hashCode()
override fun toString(): String {
@OptIn(MiraiInternalApi::class)
return delegate.joinToString(separator = ", ", prefix = "ContactList(", postfix = ")")
}
override fun equals(other: Any?): Boolean {
@OptIn(MiraiInternalApi::class)
return other is ContactList<*> && delegate == other.delegate
}
override fun hashCode(): Int {
@OptIn(MiraiInternalApi::class)
return delegate.hashCode()
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -11,6 +11,7 @@ package net.mamoe.mirai.contact
import kotlinx.coroutines.CoroutineScope
import net.mamoe.mirai.Bot
import net.mamoe.mirai.utils.MiraiInternalApi
import net.mamoe.mirai.utils.NotStableForInheritance
import kotlin.jvm.JvmName
@ -49,5 +50,8 @@ public interface ContactOrBot : CoroutineScope {
*/
@Suppress("INAPPLICABLE_JVM_NAME")
@JvmName("getAvatarUrl")
public fun avatarUrl(spec: AvatarSpec): String = "http://q.qlogo.cn/g?b=qq&nk=${id}&s=${spec.size}"
public fun avatarUrl(spec: AvatarSpec): String {
@OptIn(MiraiInternalApi::class)
return "http://q.qlogo.cn/g?b=qq&nk=${id}&s=${spec.size}"
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -23,7 +23,8 @@ import net.mamoe.mirai.utils.millisToHumanReadableString
*
* @see Contact.sendMessage
*/
public class MessageTooLargeException constructor(
@OptIn(MiraiInternalApi::class)
public class MessageTooLargeException(
public override val target: Contact,
/**
* 原发送消息
@ -43,6 +44,7 @@ public class MessageTooLargeException constructor(
*
* @see Group.sendMessage
*/
@OptIn(MiraiInternalApi::class)
public class BotIsBeingMutedException @MiraiInternalApi constructor(
// this constructor is since 2.9.0-RC
public override val target: Group,

View File

@ -7,7 +7,7 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:Suppress("EXPERIMENTAL_API_USAGE", "unused", "UnusedImport", "NOTHING_TO_INLINE")
@file:Suppress("EXPERIMENTAL_API_USAGE", "unused", "UnusedImport")
@file:JvmBlockingBridge
package net.mamoe.mirai.contact
@ -23,10 +23,7 @@ import net.mamoe.mirai.contact.roaming.RoamingSupported
import net.mamoe.mirai.event.events.*
import net.mamoe.mirai.message.MessageReceipt
import net.mamoe.mirai.message.data.*
import net.mamoe.mirai.utils.DeprecatedSinceMirai
import net.mamoe.mirai.utils.ExternalResource
import net.mamoe.mirai.utils.MiraiExperimentalApi
import net.mamoe.mirai.utils.NotStableForInheritance
import net.mamoe.mirai.utils.*
import kotlin.jvm.JvmStatic
import kotlin.jvm.JvmSynthetic
@ -125,7 +122,10 @@ public interface Group : Contact, CoroutineScope, FileSupported, AudioSupported,
* @param spec 头像的规格.
* @since 2.11
*/
public override fun avatarUrl(spec: AvatarSpec): String = "http://p.qlogo.cn/gh/${id}/${id}/${spec.size}"
public override fun avatarUrl(spec: AvatarSpec): String {
@OptIn(MiraiInternalApi::class)
return "http://p.qlogo.cn/gh/${id}/${id}/${spec.size}"
}
/**
* 群成员列表, 不含机器人自己, 含群主.
@ -211,7 +211,7 @@ public interface Group : Contact, CoroutineScope, FileSupported, AudioSupported,
/**
* 上传一个语音消息以备发送. 该方法已弃用且将在未来版本删除, 请使用 [uploadAudio].
*/
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"use uploadAudio",
replaceWith = ReplaceWith("uploadAudio(resource)"),
@ -312,13 +312,13 @@ public interface GroupSettings {
* [get]. 在一些不适合使用 [get] 的情境下使用 [getMember].
*/
@JvmSynthetic
public inline fun Group.getMember(id: Long): NormalMember? = get(id)
public fun Group.getMember(id: Long): NormalMember? = get(id)
/**
* [getMemberOrFail]. 在一些不适合使用 [getOrFail] 的情境下使用 [getMemberOrFail].
*/
@JvmSynthetic
public inline fun Group.getMemberOrFail(id: Long): NormalMember = getOrFail(id)
public fun Group.getMemberOrFail(id: Long): NormalMember = getOrFail(id)
/**
@ -326,5 +326,5 @@ public inline fun Group.getMemberOrFail(id: Long): NormalMember = getOrFail(id)
*
* @see Group.botMuteRemaining 剩余禁言时间
*/
public inline val Group.isBotMuted: Boolean get() = this.botMuteRemaining != 0
public val Group.isBotMuted: Boolean get() = this.botMuteRemaining != 0

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -40,7 +40,11 @@ public interface OtherClient : Contact {
*
* id 由其他客户端控制, 重启可能会变化.
*/
public override val id: Long get() = info.appId.toLongUnsigned()
public override val id: Long
get() {
@OptIn(MiraiInternalApi::class)
return info.appId.toLongUnsigned()
}
override suspend fun sendMessage(message: Message): MessageReceipt<OtherClient> {
throw UnsupportedOperationException("OtherClientImpl.sendMessage is not yet supported.")

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -15,6 +15,7 @@ import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import me.him188.kotlin.jvm.blocking.bridge.JvmBlockingBridge
import net.mamoe.mirai.Bot
import net.mamoe.mirai.LowLevelApi
import net.mamoe.mirai.Mirai
import net.mamoe.mirai.event.events.BotInvitedJoinGroupRequestEvent
import net.mamoe.mirai.event.events.MemberJoinRequestEvent
@ -48,6 +49,7 @@ public sealed class RequestEventData {
public val message: String,
) : RequestEventData() {
@OptIn(LowLevelApi::class)
override suspend fun accept(bot: Bot) {
Mirai.solveNewFriendRequestEvent(
bot,
@ -64,6 +66,7 @@ public sealed class RequestEventData {
}
@JvmBlockingBridge
@OptIn(LowLevelApi::class)
public suspend fun reject(bot: Bot, blackList: Boolean) {
Mirai.solveNewFriendRequestEvent(
bot,
@ -93,6 +96,7 @@ public sealed class RequestEventData {
public val groupName: String,
) : RequestEventData() {
override suspend fun accept(bot: Bot) {
@OptIn(LowLevelApi::class)
Mirai.solveBotInvitedJoinGroupRequestEvent(
bot,
eventId = eventId,
@ -103,6 +107,7 @@ public sealed class RequestEventData {
}
override suspend fun reject(bot: Bot) {
@OptIn(LowLevelApi::class)
Mirai.solveBotInvitedJoinGroupRequestEvent(
bot,
eventId = eventId,
@ -134,6 +139,7 @@ public sealed class RequestEventData {
public val message: String,
) : RequestEventData() {
override suspend fun accept(bot: Bot) {
@OptIn(LowLevelApi::class)
Mirai.solveMemberJoinRequestEvent(
bot,
eventId = eventId,
@ -158,6 +164,7 @@ public sealed class RequestEventData {
@JvmBlockingBridge
@JvmOverloads
public suspend fun reject(bot: Bot, blackList: Boolean, message: String = "") {
@OptIn(LowLevelApi::class)
Mirai.solveMemberJoinRequestEvent(
bot,
eventId = eventId,
@ -181,6 +188,7 @@ public sealed class RequestEventData {
@JvmStatic
@JvmName("from")
public fun NewFriendRequestEvent.toRequestEventData(): NewFriendRequest {
@OptIn(MiraiExperimentalApi::class)
return NewFriendRequest(
eventId = eventId,
message = message,
@ -193,6 +201,7 @@ public sealed class RequestEventData {
@JvmStatic
@JvmName("from")
public fun BotInvitedJoinGroupRequestEvent.toRequestEventData(): BotInvitedJoinGroupRequest {
@OptIn(MiraiExperimentalApi::class)
return BotInvitedJoinGroupRequest(
eventId = eventId,
invitor = invitorId,
@ -205,6 +214,7 @@ public sealed class RequestEventData {
@JvmStatic
@JvmName("from")
public fun MemberJoinRequestEvent.toRequestEventData(): MemberJoinRequest {
@OptIn(MiraiExperimentalApi::class)
return MemberJoinRequest(
eventId = eventId,
requester = fromId,

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -10,7 +10,9 @@
package net.mamoe.mirai.data
import net.mamoe.mirai.LowLevelApi
import net.mamoe.mirai.utils.MiraiExperimentalApi
@OptIn(MiraiExperimentalApi::class)
@LowLevelApi
public interface StrangerInfo : UserInfo {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -93,12 +93,16 @@ public abstract class AbstractEvent : Event {
* @see Event.isIntercepted
*/
public override val isIntercepted: Boolean
get() = _intercepted
get() {
@OptIn(MiraiInternalApi::class)
return _intercepted
}
/**
* @see Event.intercept
*/
public override fun intercept() {
@OptIn(MiraiInternalApi::class)
_intercepted = true
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -508,6 +508,7 @@ public expect abstract class EventChannel<out BaseEvent : Event> @MiraiInternalA
// used by mirai-core
@OptIn(MiraiInternalApi::class)
internal open class FilterEventChannel<BaseEvent : Event>(
private val delegate: EventChannel<BaseEvent>,
private val filter: suspend (event: BaseEvent) -> Boolean,

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -29,6 +29,7 @@ import kotlin.reflect.KClass
*
* @see EventChannel
*/
@OptIn(MiraiInternalApi::class)
public object GlobalEventChannel : EventChannel<Event>(Event::class, EmptyCoroutineContext) {
private val instance by lazy {
loadService(InternalGlobalEventChannelProvider::class).getInstance()

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -23,6 +23,7 @@ import net.mamoe.mirai.utils.MiraiInternalApi
*
* @see MessageSubscribersBuilder 查看上层 API
*/
@OptIn(MiraiInternalApi::class)
public expect abstract class MessageSelectBuilderUnit<M : MessageEvent, R> @PublishedApi internal constructor(
ownerMessagePacket: M,
stub: Any?,
@ -50,7 +51,6 @@ public abstract class CommonMessageSelectBuilderUnit<M : MessageEvent, R> protec
/**
* 限制本次 select 的最长等待时间, 当超时后抛出 [TimeoutCancellationException]
*/
@Suppress("NOTHING_TO_INLINE")
@MessageDsl
public fun timeoutException(
timeoutMillis: Long,

View File

@ -35,6 +35,7 @@ import kotlin.jvm.JvmName
*
* @see Contact.uploadImage 上传图片. 为广播这个事件的唯一途径
*/
@OptIn(MiraiInternalApi::class)
public data class BeforeImageUploadEvent @MiraiInternalApi constructor(
public val target: Contact,
public val source: ExternalResource
@ -54,6 +55,7 @@ public data class BeforeImageUploadEvent @MiraiInternalApi constructor(
* @see Succeed
* @see Failed
*/
@OptIn(MiraiInternalApi::class)
public sealed class ImageUploadEvent : BotEvent, BotActiveEvent, AbstractEvent(), VerboseEvent {
public abstract val target: Contact
public abstract val source: ExternalResource

View File

@ -45,6 +45,7 @@ import kotlin.jvm.JvmName
*
* 使用 [MessageEvent.isContextIdenticalWith] 可判断两个 [MessageEvent] 的语境是否相同. 有关"语境"的定义可查看 [MessageEvent.isContextIdenticalWith].
*/
@OptIn(MiraiInternalApi::class)
public sealed interface MessageEvent : Event, Packet, BotPassiveEvent {
/**
* 与这个消息事件相关的 [Bot]
@ -109,7 +110,8 @@ public sealed interface UserMessageEvent : MessageEvent {
*
* @see MessageEvent
*/
public class FriendMessageEvent constructor(
@OptIn(MiraiInternalApi::class)
public class FriendMessageEvent(
public override val sender: Friend,
public override val message: MessageChain,
public override val time: Int
@ -134,7 +136,8 @@ public class FriendMessageEvent constructor(
*
* @see MessageEvent
*/
public class OtherClientMessageEvent constructor(
@OptIn(MiraiInternalApi::class)
public class OtherClientMessageEvent(
public override val client: OtherClient,
public override val message: MessageChain,
public override val time: Int
@ -173,6 +176,7 @@ public sealed interface GroupAwareMessageEvent : MessageEvent {
*
* @see MessageEvent
*/
@OptIn(MiraiInternalApi::class)
public class GroupMessageEvent(
public override val senderName: String,
/**
@ -205,13 +209,14 @@ public class GroupMessageEvent(
*
* @see MessageEvent
*/
@OptIn(MiraiInternalApi::class)
@Deprecated(
"mirai 正计划支持其他渠道发起的临时会话, 届时此事件会变动. 原 TempMessageEvent 已更改为 GroupTempMessageEvent",
replaceWith = ReplaceWith("GroupTempMessageEvent", "net.mamoe.mirai.event.events.GroupTempMessageEvent"),
DeprecationLevel.HIDDEN
)
@DeprecatedSinceMirai(hiddenSince = "2.0") // maybe 2.0
public sealed class TempMessageEvent constructor(
public sealed class TempMessageEvent(
public override val sender: NormalMember,
public override val message: MessageChain,
public override val time: Int
@ -254,7 +259,8 @@ public class GroupTempMessageEvent(
*
* @see MessageEvent
*/
public class StrangerMessageEvent constructor(
@OptIn(MiraiInternalApi::class)
public class StrangerMessageEvent(
public override val sender: Stranger,
public override val message: MessageChain,
public override val time: Int

View File

@ -37,6 +37,7 @@ import kotlin.jvm.JvmSynthetic
* @see Contact.sendMessage 发送消息. 为广播这个事件的唯一途径
* @see MessagePreSendEvent
*/
@OptIn(MiraiInternalApi::class)
public sealed class MessagePostSendEvent<C : Contact> : BotEvent, BotActiveEvent, AbstractEvent(), VerboseEvent {
/** 发信目标. */
public abstract val target: C
@ -184,6 +185,7 @@ public sealed class TempMessagePostSendEvent @MiraiInternalApi constructor(
* 在群临时会话消息发送后广播的事件.
* @see MessagePostSendEvent
*/
@OptIn(MiraiInternalApi::class)
public data class GroupTempMessagePostSendEvent @MiraiInternalApi constructor(
/** 发信目标. */
public override val target: NormalMember,

View File

@ -36,6 +36,7 @@ import kotlin.jvm.JvmName
*
* @see Contact.sendMessage 发送消息. 为广播这个事件的唯一途径
*/
@OptIn(MiraiInternalApi::class)
public sealed class MessagePreSendEvent : BotEvent, BotActiveEvent, AbstractEvent(), CancellableEvent, VerboseEvent {
/** 发信目标. */
public abstract val target: Contact
@ -102,6 +103,7 @@ public sealed class TempMessagePreSendEvent @MiraiInternalApi constructor(
* 在发送群临时会话消息前广播的事件.
* @see MessagePreSendEvent
*/
@OptIn(MiraiInternalApi::class)
public data class GroupTempMessagePreSendEvent @MiraiInternalApi constructor(
/** 发信目标. */
public override val target: NormalMember,

View File

@ -59,6 +59,7 @@ public sealed class MessageRecallEvent : BotEvent, AbstractEvent() {
/**
* 好友消息撤回事件
*/
@OptIn(MiraiInternalApi::class)
public data class FriendRecall @MiraiInternalApi public constructor(
public override val bot: Bot,
public override val messageIds: IntArray,
@ -88,9 +89,7 @@ public sealed class MessageRecallEvent : BotEvent, AbstractEvent() {
if (!messageInternalIds.contentEquals(other.messageInternalIds)) return false
if (messageTime != other.messageTime) return false
if (operatorId != other.operatorId) return false
if (operator != other.operator) return false
return true
return operator == other.operator
}
override fun hashCode(): Int {
@ -107,6 +106,7 @@ public sealed class MessageRecallEvent : BotEvent, AbstractEvent() {
/**
* 群消息撤回事件.
*/
@OptIn(MiraiInternalApi::class)
public data class GroupRecall @MiraiInternalApi constructor(
public override val bot: Bot,
public override val authorId: Long,
@ -133,9 +133,7 @@ public sealed class MessageRecallEvent : BotEvent, AbstractEvent() {
if (messageTime != other.messageTime) return false
if (operator != other.operator) return false
if (group != other.group) return false
if (author != other.author) return false
return true
return author == other.author
}
override fun hashCode(): Int {

View File

@ -19,6 +19,7 @@ import net.mamoe.mirai.message.data.MessageSource
import net.mamoe.mirai.message.data.OnlineMessageSource
import net.mamoe.mirai.message.data.source
import net.mamoe.mirai.utils.DeprecatedSinceMirai
import net.mamoe.mirai.utils.MiraiInternalApi
import kotlin.jvm.JvmMultifileClass
import kotlin.jvm.JvmName
@ -40,12 +41,13 @@ public interface MessageSyncEvent : MessageEvent, OtherClientEvent {
*
* @see MessageSyncEvent
*/
@OptIn(MiraiInternalApi::class)
public class GroupTempMessageSyncEvent private constructor(
private val _client: OtherClient?,
public override val sender: NormalMember,
public override val message: MessageChain,
public override val time: Int,
@Suppress("UNUSED_PARAMETER") _primaryConstructorMark: Any?
@Suppress("UNUSED_PARAMETER", "LocalVariableName") _primaryConstructorMark: Any?
) : AbstractMessageEvent(), GroupAwareMessageEvent, MessageSyncEvent {
/**
* @since 2.13
@ -93,12 +95,13 @@ public class GroupTempMessageSyncEvent private constructor(
*
* @see MessageSyncEvent
*/
@OptIn(MiraiInternalApi::class)
public class FriendMessageSyncEvent private constructor(
private val _client: OtherClient?,
public override val sender: Friend,
public override val message: MessageChain,
public override val time: Int,
@Suppress("UNUSED_PARAMETER") _primaryConstructorMark: Any?
@Suppress("UNUSED_PARAMETER", "LocalVariableName") _primaryConstructorMark: Any?
) : AbstractMessageEvent(), FriendEvent, MessageSyncEvent {
/**
* @since 2.13
@ -147,12 +150,13 @@ public class FriendMessageSyncEvent private constructor(
*
* @see MessageSyncEvent
*/
@OptIn(MiraiInternalApi::class)
public class StrangerMessageSyncEvent private constructor(
private val _client: OtherClient?,
public override val sender: Stranger,
public override val message: MessageChain,
public override val time: Int,
@Suppress("UNUSED_PARAMETER") _primaryConstructorMark: Any?,
@Suppress("UNUSED_PARAMETER", "LocalVariableName") _primaryConstructorMark: Any?,
) : AbstractMessageEvent(), StrangerEvent, MessageSyncEvent {
/**
* @since 2.13
@ -201,6 +205,7 @@ public class StrangerMessageSyncEvent private constructor(
*
* @see MessageSyncEvent
*/
@OptIn(MiraiInternalApi::class)
public class GroupMessageSyncEvent private constructor(
private val _client: OtherClient?,
public override val group: Group,
@ -208,7 +213,7 @@ public class GroupMessageSyncEvent private constructor(
public override val sender: Member,
public override val senderName: String,
public override val time: Int,
@Suppress("UNUSED_PARAMETER") _primaryConstructorMark: Any?,
@Suppress("UNUSED_PARAMETER", "LocalVariableName") _primaryConstructorMark: Any?,
) : AbstractMessageEvent(), GroupAwareMessageEvent, MessageSyncEvent {
/**
* @since 2.13

View File

@ -9,6 +9,7 @@
@file:JvmMultifileClass
@file:JvmName("BotEventsKt")
@file:OptIn(MiraiInternalApi::class)
package net.mamoe.mirai.event.events

View File

@ -9,11 +9,14 @@
@file:JvmMultifileClass
@file:JvmName("BotEventsKt")
@file:OptIn(MiraiInternalApi::class)
package net.mamoe.mirai.event.events
import net.mamoe.mirai.Bot
import net.mamoe.mirai.contact.*
import net.mamoe.mirai.contact.Friend
import net.mamoe.mirai.contact.Member
import net.mamoe.mirai.contact.UserOrBot
import net.mamoe.mirai.event.AbstractEvent
import net.mamoe.mirai.internal.network.Packet
import net.mamoe.mirai.utils.MiraiInternalApi

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -10,6 +10,7 @@
@file:Suppress("unused", "FunctionName")
@file:JvmMultifileClass
@file:JvmName("BotEventsKt")
@file:OptIn(MiraiInternalApi::class)
package net.mamoe.mirai.event.events
@ -47,6 +48,7 @@ public sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
*
* 主动广播这个事件也可以让 [Bot] 离线, 但不建议这么做. 建议调用 [Bot.close].
*/
@OptIn(MiraiExperimentalApi::class)
public data class Active(
public override val bot: Bot,
public override val cause: Throwable?
@ -76,6 +78,7 @@ public sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
/**
* 被服务器断开
*/
@OptIn(MiraiExperimentalApi::class)
@MiraiInternalApi("This is very experimental and might be changed")
public data class MsfOffline @MiraiInternalApi public constructor(
public override val bot: Bot,
@ -91,7 +94,9 @@ public sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
/**
* 因网络问题而掉线
*/
public data class Dropped @MiraiInternalApi public constructor(
@OptIn(MiraiExperimentalApi::class)
public data class Dropped
@MiraiInternalApi public constructor(
public override val bot: Bot,
public override val cause: Throwable?
) : BotOfflineEvent(), Packet, BotPassiveEvent, CauseAware {
@ -105,6 +110,7 @@ public sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
/**
* 服务器主动要求更换另一个服务器
*/
@OptIn(MiraiExperimentalApi::class)
@MiraiInternalApi
public data class RequireReconnect @MiraiInternalApi public constructor(
public override val bot: Bot, override val cause: Throwable?,

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 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.
@ -10,11 +10,10 @@
@file:JvmMultifileClass
@file:JvmName("BotEventsKt")
@file:Suppress("FunctionName", "unused", "DEPRECATION_ERROR")
@file:OptIn(MiraiInternalApi::class)
package net.mamoe.mirai.event.events
import kotlinx.atomicfu.AtomicBoolean
import kotlinx.atomicfu.atomic
import me.him188.kotlin.jvm.blocking.bridge.JvmBlockingBridge
import net.mamoe.mirai.Bot
import net.mamoe.mirai.Mirai
@ -62,7 +61,6 @@ public data class FriendDeleteEvent @MiraiInternalApi public constructor(
/**
* 一个账号请求添加机器人为好友的事件
*/
@Suppress("DEPRECATION")
public data class NewFriendRequestEvent @MiraiInternalApi public constructor(
public override val bot: Bot,
/**

Some files were not shown because too many files have changed in this diff Show More