mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-20 14:59:29 +08:00
Optimize experimental API usages
This commit is contained in:
parent
904513667c
commit
90c0c5c549
@ -5,7 +5,7 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
internal class CombinedMessageTest {
|
||||
|
||||
|
||||
|
@ -40,6 +40,13 @@ kotlin {
|
||||
all {
|
||||
languageSettings.enableLanguageFeature("InlineClasses")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.Experimental")
|
||||
languageSettings.useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiInternalAPI")
|
||||
languageSettings.useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiExperimentalAPI")
|
||||
languageSettings.useExperimentalAnnotation("net.mamoe.mirai.LowLevelAPI")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.time.ExperimentalTime")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
||||
languageSettings.progressiveMode = true
|
||||
|
||||
dependencies {
|
||||
|
@ -22,7 +22,6 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
actual object QQAndroid : BotFactory {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@JvmName("newBot")
|
||||
actual override fun Bot(context: Context, qq: Long, password: String, configuration: BotConfiguration): Bot {
|
||||
return QQAndroidBot(context, BotAccount(qq, password), configuration)
|
||||
@ -31,7 +30,6 @@ actual object QQAndroid : BotFactory {
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@JvmName("newBot")
|
||||
actual override fun Bot(
|
||||
context: Context,
|
||||
|
@ -21,7 +21,6 @@ import net.mamoe.mirai.qqandroid.utils.toReadPacket
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@Suppress("DEPRECATION")
|
||||
internal actual fun ByteReadChannel.toKotlinByteReadChannel(): kotlinx.coroutines.io.ByteReadChannel {
|
||||
return object : kotlinx.coroutines.io.ByteReadChannel {
|
||||
|
@ -85,7 +85,6 @@ internal actual class ECDH actual constructor(actual val keyPair: ECDHKeyPair) {
|
||||
.genKeyPair())
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
actual fun calculateShareKey(
|
||||
privateKey: ECDHPrivateKey,
|
||||
publicKey: ECDHPublicKey
|
||||
|
@ -26,8 +26,6 @@ internal data class BotAccount(
|
||||
val passwordMd5: ByteArray // md5
|
||||
) {
|
||||
constructor(id: Long, passwordPlainText: String) : this(id, MiraiPlatformUtils.md5(passwordPlainText.toByteArray()))
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other == null || this::class != other::class) return false
|
||||
@ -40,7 +38,7 @@ internal data class BotAccount(
|
||||
return true
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = id.hashCode()
|
||||
result = 31 * result + passwordMd5.contentHashCode()
|
||||
|
@ -70,7 +70,6 @@ internal fun Bot.asQQAndroidBot(): QQAndroidBot {
|
||||
}
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "BooleanLiteralArgument")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal class QQAndroidBot constructor(
|
||||
context: Context,
|
||||
account: BotAccount,
|
||||
@ -232,7 +231,7 @@ internal class QQAndroidBot constructor(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class, MiraiExperimentalAPI::class)
|
||||
|
||||
internal abstract class QQAndroidBotBase constructor(
|
||||
context: Context,
|
||||
private val account: BotAccount,
|
||||
@ -771,11 +770,9 @@ internal abstract class QQAndroidBotBase constructor(
|
||||
internal val EMPTY_BYTE_ARRAY = ByteArray(0)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal expect fun io.ktor.utils.io.ByteReadChannel.toKotlinByteReadChannel(): ByteReadChannel
|
||||
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
private fun RichMessage.Templates.longMessage(brief: String, resId: String, timeSeconds: Long): RichMessage {
|
||||
val limited: String = if (brief.length > 30) {
|
||||
brief.take(30) + "…"
|
||||
|
@ -41,7 +41,6 @@ import kotlin.contracts.contract
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.time.ExperimentalTime
|
||||
import kotlin.time.measureTime
|
||||
|
||||
internal inline class FriendInfoImpl(
|
||||
@ -85,7 +84,7 @@ internal class FriendImpl(
|
||||
}
|
||||
|
||||
@JvmSynthetic
|
||||
@OptIn(MiraiInternalAPI::class, ExperimentalStdlibApi::class, ExperimentalTime::class)
|
||||
|
||||
override suspend fun uploadImage(image: ExternalImage): Image = try {
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
if (image.input is net.mamoe.mirai.utils.internal.DeferredReusableInput) {
|
||||
|
@ -36,13 +36,11 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.MessageSvc
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.list.ProfileService
|
||||
import net.mamoe.mirai.qqandroid.utils.estimateLength
|
||||
import net.mamoe.mirai.utils.*
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
internal fun GroupImpl.Companion.checkIsInstance(instance: Group) {
|
||||
contract {
|
||||
returns() implies (instance is GroupImpl)
|
||||
@ -50,7 +48,6 @@ internal fun GroupImpl.Companion.checkIsInstance(instance: Group) {
|
||||
check(instance is GroupImpl) { "group is not an instanceof GroupImpl!! DO NOT interlace two or more protocol implementations!!" }
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
internal fun Group.checkIsGroupImpl() {
|
||||
contract {
|
||||
returns() implies (this@checkIsGroupImpl is GroupImpl)
|
||||
@ -58,7 +55,6 @@ internal fun Group.checkIsGroupImpl() {
|
||||
GroupImpl.checkIsInstance(this)
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class, LowLevelAPI::class)
|
||||
@Suppress("PropertyName")
|
||||
internal class GroupImpl(
|
||||
bot: QQAndroidBot,
|
||||
@ -249,10 +245,8 @@ internal class GroupImpl(
|
||||
return true
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
override fun newMember(memberInfo: MemberInfo): Member {
|
||||
return MemberImpl(
|
||||
@OptIn(LowLevelAPI::class)
|
||||
bot._lowLevelNewFriend(memberInfo) as FriendImpl,
|
||||
this,
|
||||
this.coroutineContext,
|
||||
@ -290,7 +284,6 @@ internal class GroupImpl(
|
||||
return members.firstOrNull { it.id == id }
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class, LowLevelAPI::class)
|
||||
@JvmSynthetic
|
||||
override suspend fun sendMessage(message: Message): MessageReceipt<Group> {
|
||||
require(message.isContentNotEmpty()) { "message is empty" }
|
||||
@ -301,7 +294,6 @@ internal class GroupImpl(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
private suspend fun sendMessageImpl(message: Message, isForward: Boolean): MessageReceipt<Group> {
|
||||
if (message is MessageChain) {
|
||||
if (message.anyIsInstance<ForwardMessage>()) {
|
||||
|
@ -33,7 +33,10 @@ import net.mamoe.mirai.qqandroid.message.MessageSourceToTempImpl
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.StTroopMemberInfo
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.TroopManagement
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.MessageSvcPbSendMsg
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.ExternalImage
|
||||
import net.mamoe.mirai.utils.currentTimeSeconds
|
||||
import net.mamoe.mirai.utils.getValue
|
||||
import net.mamoe.mirai.utils.unsafeWeakRef
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
@ -189,7 +192,7 @@ internal class MemberImpl constructor(
|
||||
net.mamoe.mirai.event.events.MemberUnmuteEvent(this@MemberImpl, null).broadcast()
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
@JvmSynthetic
|
||||
override suspend fun kick(message: String) {
|
||||
checkBotPermissionHigherThanThis()
|
||||
|
@ -24,11 +24,8 @@ import net.mamoe.mirai.qqandroid.message.ensureSequenceIdAvailable
|
||||
import net.mamoe.mirai.qqandroid.message.firstIsInstanceOrNull
|
||||
import net.mamoe.mirai.qqandroid.network.QQAndroidBotNetworkHandler
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.MessageSvcPbSendMsg
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.verbose
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal suspend fun <T : Contact> Friend.sendMessageImpl(generic: T, message: Message): MessageReceipt<T> {
|
||||
val event = MessageSendEvent.FriendMessageSendEvent(this, message.asMessageChain()).broadcast()
|
||||
if (event.isCancelled) {
|
||||
@ -50,7 +47,6 @@ internal suspend fun <T : Contact> Friend.sendMessageImpl(generic: T, message: M
|
||||
return MessageReceipt(source, generic, null)
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class, MiraiExperimentalAPI::class)
|
||||
internal fun Contact.logMessageSent(message: Message) {
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
if (message !is net.mamoe.mirai.message.data.LongMessage) {
|
||||
@ -58,7 +54,6 @@ internal fun Contact.logMessageSent(message: Message) {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class, MiraiExperimentalAPI::class)
|
||||
internal fun MessageEvent.logMessageReceived() {
|
||||
when (this) {
|
||||
is GroupMessageEvent -> bot.logger.verbose {
|
||||
|
@ -36,7 +36,6 @@ private val UNSUPPORTED_POKE_MESSAGE_PLAIN = PlainText("[戳一戳]请使用最
|
||||
private val UNSUPPORTED_FLASH_MESSAGE_PLAIN = PlainText("[闪照]请使用新版手机QQ查看闪照。")
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
@OptIn(MiraiInternalAPI::class, MiraiExperimentalAPI::class)
|
||||
internal fun MessageChain.toRichTextElems(forGroup: Boolean, withGeneralFlags: Boolean): MutableList<ImMsgBody.Elem> {
|
||||
val elements = ArrayList<ImMsgBody.Elem>(this.size)
|
||||
|
||||
@ -302,7 +301,6 @@ internal inline fun <reified R> Iterable<*>.firstIsInstanceOrNull(): R? {
|
||||
internal val MIRAI_CUSTOM_ELEM_TYPE = "mirai".hashCode() // 103904510
|
||||
|
||||
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
|
||||
@OptIn(MiraiInternalAPI::class, LowLevelAPI::class, ExperimentalStdlibApi::class)
|
||||
internal fun List<ImMsgBody.Elem>.joinToMessageChain(groupIdOrZero: Long, bot: Bot, list: MessageChainBuilder) {
|
||||
// (this._miraiContentToString())
|
||||
this.forEach { element ->
|
||||
|
@ -20,7 +20,6 @@ import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.buildPacket
|
||||
import kotlinx.io.core.use
|
||||
import net.mamoe.mirai.event.*
|
||||
import net.mamoe.mirai.event.Listener.EventPriority.MONITOR
|
||||
import net.mamoe.mirai.event.events.BotOfflineEvent
|
||||
import net.mamoe.mirai.event.events.BotOnlineEvent
|
||||
import net.mamoe.mirai.event.events.BotReloginEvent
|
||||
@ -50,10 +49,8 @@ import net.mamoe.mirai.utils.*
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.jvm.JvmField
|
||||
import kotlin.jvm.Volatile
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bot: QQAndroidBot) : BotNetworkHandler() {
|
||||
override val bot: QQAndroidBot by bot.unsafeWeakRef()
|
||||
override val supervisor: CompletableJob = SupervisorJob(coroutineContext[Job])
|
||||
@ -114,7 +111,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
|
||||
}.also { heartbeatJob = it }
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
|
||||
override suspend fun closeEverythingAndRelogin(host: String, port: Int, cause: Throwable?) {
|
||||
heartbeatJob?.cancel(CancellationException("relogin", cause))
|
||||
heartbeatJob?.join()
|
||||
@ -314,7 +311,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
|
||||
initGroupOk = true
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class, ExperimentalTime::class)
|
||||
|
||||
override suspend fun init(): Unit = coroutineScope {
|
||||
check(bot.isActive) { "bot is dead therefore network can't init" }
|
||||
check(this@QQAndroidBotNetworkHandler.isActive) { "network is dead therefore can't init" }
|
||||
@ -390,7 +387,8 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
|
||||
}
|
||||
|
||||
init {
|
||||
val listener = bot.subscribeAlways<BotReloginEvent>(priority = MONITOR) {
|
||||
@Suppress("RemoveRedundantQualifierName")
|
||||
val listener = bot.subscribeAlways<BotReloginEvent>(priority = Listener.EventPriority.MONITOR) {
|
||||
if (bot != this.bot) return@subscribeAlways
|
||||
this@QQAndroidBotNetworkHandler.launch { syncMessageSvc() }
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ internal val DeviceInfo.guid: ByteArray get() = generateGuid(androidId, macAddre
|
||||
* Defaults "%4;7t>;28<fc.5*6".toByteArray()
|
||||
*/
|
||||
@Suppress("RemoveRedundantQualifierName") // bug
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
private fun generateGuid(androidId: ByteArray, macAddress: ByteArray): ByteArray =
|
||||
net.mamoe.mirai.qqandroid.utils.MiraiPlatformUtils.md5(androidId + macAddress)
|
||||
|
||||
@ -68,7 +67,6 @@ internal object DefaultServerList : Set<Pair<String, Int>> by setOf(
|
||||
DOMAINS
|
||||
Pskey: "openmobile.qq.com"
|
||||
*/
|
||||
@OptIn(MiraiExperimentalAPI::class, MiraiInternalAPI::class)
|
||||
@PublishedApi
|
||||
internal open class QQAndroidClient(
|
||||
context: Context,
|
||||
@ -270,7 +268,6 @@ internal open class QQAndroidClient(
|
||||
}
|
||||
|
||||
@Suppress("RemoveRedundantQualifierName") // bug
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal fun generateTgtgtKey(guid: ByteArray): ByteArray =
|
||||
net.mamoe.mirai.qqandroid.utils.MiraiPlatformUtils.md5(getRandomByteArray(16) + guid)
|
||||
|
||||
|
@ -26,7 +26,6 @@ import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.withTimeoutOrNull
|
||||
import kotlinx.io.core.discardExact
|
||||
import kotlinx.io.core.use
|
||||
import kotlinx.serialization.InternalSerializationApi
|
||||
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
||||
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.CSDataHighwayHead
|
||||
@ -36,8 +35,6 @@ import net.mamoe.mirai.qqandroid.utils.addSuppressedMirai
|
||||
import net.mamoe.mirai.qqandroid.utils.io.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.qqandroid.utils.io.withUse
|
||||
import net.mamoe.mirai.qqandroid.utils.toIpV4AddressString
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.internal.ReusableInput
|
||||
import net.mamoe.mirai.utils.verbose
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
@ -45,7 +42,7 @@ import kotlin.math.roundToInt
|
||||
import kotlin.time.ExperimentalTime
|
||||
import kotlin.time.measureTime
|
||||
|
||||
@OptIn(MiraiInternalAPI::class, InternalSerializationApi::class)
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
internal suspend fun HttpClient.postImage(
|
||||
htcmd: String,
|
||||
@ -77,7 +74,7 @@ internal suspend fun HttpClient.postImage(
|
||||
override val contentType: ContentType = ContentType.Image.Any
|
||||
override val contentLength: Long = imageInput.size
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
|
||||
override suspend fun writeTo(channel: ByteWriteChannel) {
|
||||
imageInput.writeTo(channel)
|
||||
|
||||
@ -85,7 +82,7 @@ internal suspend fun HttpClient.postImage(
|
||||
}
|
||||
} == HttpStatusCode.OK
|
||||
|
||||
@OptIn(MiraiInternalAPI::class, InternalSerializationApi::class)
|
||||
|
||||
internal object HighwayHelper {
|
||||
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
|
||||
suspend fun uploadImageToServers(
|
||||
|
@ -14,20 +14,18 @@ package net.mamoe.mirai.qqandroid.network.highway
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.buildPacket
|
||||
import kotlinx.io.core.writeFully
|
||||
import kotlinx.serialization.InternalSerializationApi
|
||||
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.CSDataHighwayHead
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.qqandroid.utils.ByteArrayPool
|
||||
import net.mamoe.mirai.qqandroid.utils.MiraiPlatformUtils
|
||||
import net.mamoe.mirai.qqandroid.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.internal.ChunkedFlowSession
|
||||
import net.mamoe.mirai.utils.internal.ChunkedInput
|
||||
import net.mamoe.mirai.utils.internal.ReusableInput
|
||||
import net.mamoe.mirai.utils.internal.map
|
||||
|
||||
@OptIn(MiraiInternalAPI::class, InternalSerializationApi::class)
|
||||
|
||||
internal fun createImageDataPacketSequence(
|
||||
// RequestDataTrans
|
||||
client: QQAndroidClient,
|
||||
|
@ -19,7 +19,6 @@ import net.mamoe.mirai.qqandroid.utils.cryptor.ECDHKeyPair
|
||||
import net.mamoe.mirai.qqandroid.utils.io.encryptAndWrite
|
||||
import net.mamoe.mirai.qqandroid.utils.io.writeShortLVByteArray
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
internal interface EncryptMethod {
|
||||
val id: Int
|
||||
|
||||
|
@ -35,7 +35,6 @@ internal val KEY_16_ZEROS = ByteArray(16)
|
||||
internal val EMPTY_BYTE_ARRAY = ByteArray(0)
|
||||
|
||||
@Suppress("DuplicatedCode")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal inline fun OutgoingPacketFactory<*>.buildOutgoingUniPacket(
|
||||
client: QQAndroidClient,
|
||||
bodyType: Byte = 1, // 1: PB?
|
||||
@ -67,7 +66,6 @@ internal inline fun OutgoingPacketFactory<*>.buildOutgoingUniPacket(
|
||||
}
|
||||
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal inline fun IncomingPacketFactory<*>.buildResponseUniPacket(
|
||||
client: QQAndroidClient,
|
||||
bodyType: Byte = 1, // 1: PB?
|
||||
@ -98,7 +96,7 @@ internal inline fun IncomingPacketFactory<*>.buildResponseUniPacket(
|
||||
})
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
private inline fun BytePacketBuilder.writeUniPacket(
|
||||
commandName: String,
|
||||
unknownData: ByteArray,
|
||||
@ -131,7 +129,6 @@ internal val NO_ENCRYPT: ByteArray = ByteArray(0)
|
||||
/**
|
||||
* com.tencent.qphone.base.util.CodecWarpper#encodeRequest(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, byte[], int, int, java.lang.String, byte, byte, byte, byte[], byte[], boolean)
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal inline fun OutgoingPacketFactory<*>.buildLoginOutgoingPacket(
|
||||
client: QQAndroidClient,
|
||||
bodyType: Byte,
|
||||
@ -169,7 +166,7 @@ internal inline fun OutgoingPacketFactory<*>.buildLoginOutgoingPacket(
|
||||
|
||||
private inline val BRP_STUB get() = ByteReadPacket.Empty
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
internal inline fun BytePacketBuilder.writeSsoPacket(
|
||||
client: QQAndroidClient,
|
||||
subAppId: Long,
|
||||
|
@ -54,7 +54,6 @@ internal sealed class PacketFactory<TPacket : Packet?> {
|
||||
*
|
||||
* @param TPacket 服务器回复包解析结果
|
||||
*/
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
internal abstract class OutgoingPacketFactory<TPacket : Packet?>(
|
||||
/**
|
||||
* 命令名. 如 `wtlogin.login`, `ConfigPushSvc.PushDomain`
|
||||
@ -125,7 +124,6 @@ internal typealias PacketConsumer<T> = suspend (packetFactory: PacketFactory<T>,
|
||||
@PublishedApi
|
||||
internal val PacketLogger: MiraiLoggerWithSwitch = DefaultLogger("Packet").withSwitch(false)
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
internal object KnownPacketFactories {
|
||||
object OutgoingFactories : List<OutgoingPacketFactory<*>> by mutableListOf(
|
||||
WtLogin.Login,
|
||||
@ -174,7 +172,6 @@ internal object KnownPacketFactories {
|
||||
}
|
||||
|
||||
// do not inline. Exceptions thrown will not be reported correctly
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun <T : Packet?> parseIncomingPacket(
|
||||
bot: QQAndroidBot,
|
||||
@ -235,7 +232,6 @@ internal object KnownPacketFactories {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal suspend fun <T : Packet?> handleIncomingPacket(
|
||||
it: IncomingPacket<T>,
|
||||
bot: QQAndroidBot,
|
||||
@ -296,7 +292,6 @@ internal object KnownPacketFactories {
|
||||
lateinit var consumer: PacketConsumer<T>
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
|
||||
private fun parseSsoFrame(bot: QQAndroidBot, input: ByteReadPacket): IncomingPacket<*> {
|
||||
val commandName: String
|
||||
val ssoSequenceId: Int
|
||||
@ -355,7 +350,6 @@ internal object KnownPacketFactories {
|
||||
return IncomingPacket(packetFactory, ssoSequenceId, packet, commandName)
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
private suspend fun <T : Packet?> ByteReadPacket.parseOicqResponse(
|
||||
bot: QQAndroidBot,
|
||||
packetFactory: OutgoingPacketFactory<T>,
|
||||
|
@ -20,7 +20,6 @@ import net.mamoe.mirai.qqandroid.utils.MiraiPlatformUtils
|
||||
import net.mamoe.mirai.qqandroid.utils.NetworkType
|
||||
import net.mamoe.mirai.qqandroid.utils.io.*
|
||||
import net.mamoe.mirai.qqandroid.utils.toByteArray
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.currentTimeMillis
|
||||
import kotlin.random.Random
|
||||
|
||||
@ -80,7 +79,7 @@ internal fun BytePacketBuilder.t18(
|
||||
} shouldEqualsTo 22
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
internal fun BytePacketBuilder.t106(
|
||||
appId: Long = 16L,
|
||||
subAppId: Long,
|
||||
@ -326,7 +325,7 @@ internal fun BytePacketBuilder.t144(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
internal fun BytePacketBuilder.t109(
|
||||
androidId: ByteArray
|
||||
) {
|
||||
@ -562,7 +561,7 @@ internal fun BytePacketBuilder.t400(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
internal fun BytePacketBuilder.t187(
|
||||
macAddress: ByteArray
|
||||
) {
|
||||
@ -572,7 +571,7 @@ internal fun BytePacketBuilder.t187(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
internal fun BytePacketBuilder.t188(
|
||||
androidId: ByteArray
|
||||
) {
|
||||
|
@ -31,9 +31,8 @@ import net.mamoe.mirai.qqandroid.utils._miraiContentToString
|
||||
import net.mamoe.mirai.qqandroid.utils.io.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.qqandroid.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.qqandroid.utils.io.serialization.writeProtoBuf
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
|
||||
internal class MessageValidationData @OptIn(MiraiInternalAPI::class) constructor(
|
||||
internal class MessageValidationData(
|
||||
val data: ByteArray,
|
||||
val md5: ByteArray = MiraiPlatformUtils.md5(data)
|
||||
) {
|
||||
@ -44,8 +43,6 @@ internal class MessageValidationData @OptIn(MiraiInternalAPI::class) constructor
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
internal inline fun Int.toLongUnsigned(): Long = this.toLong().and(0xFFFF_FFFF)
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal fun Collection<ForwardMessage.INode>.calculateValidationDataForGroup(
|
||||
sequenceId: Int,
|
||||
random: Int,
|
||||
|
@ -14,7 +14,6 @@ import kotlinx.coroutines.FlowPreview
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.discardExact
|
||||
import net.mamoe.mirai.LowLevelAPI
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.contact.MemberPermission
|
||||
import net.mamoe.mirai.data.MemberInfo
|
||||
@ -48,13 +47,15 @@ import net.mamoe.mirai.qqandroid.utils.io.serialization.writeProtoBuf
|
||||
import net.mamoe.mirai.qqandroid.utils.read
|
||||
import net.mamoe.mirai.qqandroid.utils.soutv
|
||||
import net.mamoe.mirai.qqandroid.utils.toUHexString
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.currentTimeSeconds
|
||||
import net.mamoe.mirai.utils.debug
|
||||
import net.mamoe.mirai.utils.warning
|
||||
|
||||
|
||||
/**
|
||||
* 获取好友消息和消息记录
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Response>("MessageSvc.PbGetMsg") {
|
||||
@Suppress("SpellCheckingInspection")
|
||||
operator fun invoke(
|
||||
@ -86,7 +87,6 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
open class GetMsgSuccess(delegate: List<Packet>) : Response(MsgSvc.SyncFlag.STOP, delegate), Event,
|
||||
Packet.NoLog {
|
||||
override fun toString(): String = "MessageSvcPbGetMsg.GetMsgSuccess(messages=<Iterable>))"
|
||||
@ -143,7 +143,6 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(LowLevelAPI::class)
|
||||
private fun MsgComm.Msg.getNewMemberInfo(): MemberInfo {
|
||||
return object : MemberInfo {
|
||||
override val nameCard: String get() = ""
|
||||
@ -156,7 +155,7 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class, MiraiExperimentalAPI::class, FlowPreview::class, LowLevelAPI::class)
|
||||
@OptIn(FlowPreview::class)
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response {
|
||||
// 00 00 01 0F 08 00 12 00 1A 34 08 FF C1 C4 F1 05 10 FF C1 C4 F1 05 18 E6 ED B9 C3 02 20 89 FE BE A4 06 28 8A CA 91 D1 0C 48 9B A5 BD 9B 0A 58 DE 9D 99 F8 08 60 1D 68 FF C1 C4 F1 05 70 00 20 02 2A 9D 01 08 F3 C1 C4 F1 05 10 A2 FF 8C F0 03 18 01 22 8A 01 0A 2A 08 A2 FF 8C F0 03 10 DD F1 92 B7 07 18 A6 01 20 0B 28 AE F9 01 30 F4 C1 C4 F1 05 38 A7 E3 D8 D4 84 80 80 80 01 B8 01 CD B5 01 12 08 08 01 10 00 18 00 20 00 1A 52 0A 50 0A 27 08 00 10 F4 C1 C4 F1 05 18 A7 E3 D8 D4 04 20 00 28 0C 30 00 38 86 01 40 22 4A 0C E5 BE AE E8 BD AF E9 9B 85 E9 BB 91 12 08 0A 06 0A 04 4E 4D 53 4C 12 15 AA 02 12 9A 01 0F 80 01 01 C8 01 00 F0 01 00 F8 01 00 90 02 00 12 04 4A 02 08 00 30 01 2A 15 08 97 A2 C1 F1 05 10 95 A6 F5 E5 0C 18 01 30 01 40 01 48 81 01 2A 10 08 D3 F7 B5 F1 05 10 DD F1 92 B7 07 18 01 30 01 38 00 42 00 48 00
|
||||
val resp = readProtoBuf(MsgSvc.PbGetMsgResp.serializer())
|
||||
@ -179,9 +178,7 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
|
||||
.filterNot { it.msg == null }
|
||||
.flatMapConcat { it.msg!!.asFlow() }
|
||||
.also {
|
||||
MessageSvcPbDeleteMsg.delete(
|
||||
bot,
|
||||
it)
|
||||
MessageSvcPbDeleteMsg.delete(bot, it)
|
||||
} // 删除消息
|
||||
.mapNotNull<MsgComm.Msg, Packet> { msg ->
|
||||
|
||||
@ -375,12 +372,9 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
|
||||
|
||||
val list: List<Packet> = messages.toList()
|
||||
if (resp.syncFlag == MsgSvc.SyncFlag.STOP) {
|
||||
return GetMsgSuccess(
|
||||
list)
|
||||
return GetMsgSuccess(list)
|
||||
}
|
||||
return Response(
|
||||
resp.syncFlag,
|
||||
list)
|
||||
return Response(resp.syncFlag, list)
|
||||
}
|
||||
|
||||
override suspend fun QQAndroidBot.handle(packet: Response) {
|
||||
@ -388,20 +382,14 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
|
||||
MsgSvc.SyncFlag.STOP -> return
|
||||
MsgSvc.SyncFlag.START -> {
|
||||
network.run {
|
||||
MessageSvcPbGetMsg(
|
||||
client,
|
||||
MsgSvc.SyncFlag.CONTINUE,
|
||||
currentTimeSeconds).sendAndExpect<Packet>()
|
||||
MessageSvcPbGetMsg(client, MsgSvc.SyncFlag.CONTINUE, currentTimeSeconds).sendAndExpect<Packet>()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
MsgSvc.SyncFlag.CONTINUE -> {
|
||||
network.run {
|
||||
MessageSvcPbGetMsg(
|
||||
client,
|
||||
MsgSvc.SyncFlag.CONTINUE,
|
||||
currentTimeSeconds).sendAndExpect<Packet>()
|
||||
MessageSvcPbGetMsg(client, MsgSvc.SyncFlag.CONTINUE, currentTimeSeconds).sendAndExpect<Packet>()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
internal object OnlinePushPbPushTransMsg :
|
||||
IncomingPacketFactory<Packet?>("OnlinePush.PbPushTransMsg", "OnlinePush.RespPush") {
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot, sequenceId: Int): Packet? {
|
||||
val content = this.readProtoBuf(OnlinePushTrans.PbMsgInfo.serializer())
|
||||
|
||||
|
@ -23,7 +23,6 @@ import kotlinx.io.core.readBytes
|
||||
import kotlinx.io.core.readUInt
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.JavaFriendlyAPI
|
||||
import net.mamoe.mirai.LowLevelAPI
|
||||
import net.mamoe.mirai.data.FriendInfo
|
||||
import net.mamoe.mirai.event.events.*
|
||||
import net.mamoe.mirai.getFriendOrNull
|
||||
@ -352,7 +351,6 @@ internal inline fun lambda528(crossinline block: MsgType0x210.(QQAndroidBot) ->
|
||||
/**
|
||||
* @see MsgType0x210
|
||||
*/
|
||||
@OptIn(LowLevelAPI::class, MiraiInternalAPI::class)
|
||||
internal object Transformers528 : Map<Long, Lambda528> by mapOf(
|
||||
|
||||
// Network(1994701021) 16:03:54 : unknown group 528 type 0x0000000000000026, data: 08 01 12 40 0A 06 08 F4 EF BB 8F 04 10 E7 C1 AD B8 02 18 01 22 2C 10 01 1A 1A 18 B4 DC F8 9B 0C 20 E7 C1 AD B8 02 28 06 30 02 A2 01 04 08 93 D6 03 A8 01 08 20 00 28 00 32 08 18 01 20 FE AF AF F5 05 28 00
|
||||
|
@ -28,7 +28,6 @@ import net.mamoe.mirai.qqandroid.utils.NetworkType
|
||||
import net.mamoe.mirai.qqandroid.utils.encodeToString
|
||||
import net.mamoe.mirai.qqandroid.utils.io.serialization.*
|
||||
import net.mamoe.mirai.qqandroid.utils.toReadPacket
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
|
||||
@Suppress("EnumEntryName", "unused")
|
||||
internal enum class RegPushReason {
|
||||
@ -89,7 +88,7 @@ internal class StatSvc {
|
||||
override fun toString(): String = "Response(StatSvc.register)"
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
operator fun invoke(
|
||||
client: QQAndroidClient,
|
||||
regPushReason: RegPushReason = RegPushReason.appRegister
|
||||
|
@ -10,7 +10,6 @@
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet.login
|
||||
|
||||
|
||||
import io.ktor.util.InternalAPI
|
||||
import kotlinx.io.core.*
|
||||
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
||||
import net.mamoe.mirai.qqandroid.network.*
|
||||
@ -20,8 +19,6 @@ import net.mamoe.mirai.qqandroid.utils.*
|
||||
import net.mamoe.mirai.qqandroid.utils.cryptor.TEA
|
||||
import net.mamoe.mirai.qqandroid.utils.guidFlag
|
||||
import net.mamoe.mirai.qqandroid.utils.io.*
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.currentTimeSeconds
|
||||
import net.mamoe.mirai.utils.error
|
||||
|
||||
@ -30,7 +27,6 @@ internal class WtLogin {
|
||||
* OicqRequest
|
||||
*/
|
||||
@Suppress("FunctionName")
|
||||
@OptIn(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
|
||||
internal object Login : OutgoingPacketFactory<Login.LoginPacketResponse>("wtlogin.login") {
|
||||
/**
|
||||
* 提交验证码
|
||||
@ -125,7 +121,6 @@ internal class WtLogin {
|
||||
object SubCommand9 {
|
||||
private const val appId = 16L
|
||||
|
||||
@OptIn(MiraiInternalAPI::class, MiraiExperimentalAPI::class)
|
||||
operator fun invoke(
|
||||
client: QQAndroidClient
|
||||
): OutgoingPacket = buildLoginOutgoingPacket(client, bodyType = 2) { sequenceId ->
|
||||
@ -306,7 +301,6 @@ internal class WtLogin {
|
||||
}
|
||||
}
|
||||
|
||||
@InternalAPI
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): LoginPacketResponse {
|
||||
|
||||
discardExact(2) // subCommand
|
||||
@ -364,7 +358,6 @@ internal class WtLogin {
|
||||
}
|
||||
}
|
||||
|
||||
@InternalAPI
|
||||
private fun onSolveLoginCaptcha(tlvMap: TlvMap, bot: QQAndroidBot): LoginPacketResponse.Captcha {
|
||||
/*
|
||||
java.lang.IllegalStateException: UNKNOWN CAPTCHA QUESTION:
|
||||
|
@ -18,7 +18,6 @@ import kotlinx.io.charsets.Charsets
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.String
|
||||
import kotlinx.io.core.use
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
@ -29,7 +28,6 @@ import kotlin.jvm.JvmSynthetic
|
||||
|
||||
@JvmOverloads
|
||||
@Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
internal fun List<Byte>.toUHexString(separator: String = " ", offset: Int = 0, length: Int = this.size - offset): String {
|
||||
require(offset >= 0) { "offset shouldn't be negative: $offset" }
|
||||
require(length >= 0) { "length shouldn't be negative: $length" }
|
||||
@ -53,7 +51,6 @@ internal fun List<Byte>.toUHexString(separator: String = " ", offset: Int = 0, l
|
||||
|
||||
@JvmOverloads
|
||||
@Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
internal fun ByteArray.toUHexString(separator: String = " ", offset: Int = 0, length: Int = this.size - offset): String {
|
||||
this.checkOffsetAndLength(offset, length)
|
||||
if (length == 0) {
|
||||
@ -100,7 +97,6 @@ internal inline fun ByteArray.encodeToString(offset: Int = 0, charset: Charset =
|
||||
internal inline fun ByteArray.toReadPacket(offset: Int = 0, length: Int = this.size - offset) =
|
||||
ByteReadPacket(this, offset = offset, length = length)
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
internal inline fun <R> ByteArray.read(t: ByteReadPacket.() -> R): R {
|
||||
contract {
|
||||
callsInPlace(t, InvocationKind.EXACTLY_ONCE)
|
||||
|
@ -20,7 +20,6 @@ import net.mamoe.mirai.qqandroid.utils.ByteArrayPool
|
||||
import net.mamoe.mirai.qqandroid.utils.toReadPacket
|
||||
import net.mamoe.mirai.qqandroid.utils.toUHexString
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
@ -40,7 +39,6 @@ internal inline fun ByteReadPacket.readPacketExact(
|
||||
n: Int = remaining.toInt()//not that safe but adequate
|
||||
): ByteReadPacket = this.readBytes(n).toReadPacket()
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
internal inline fun <C : Closeable, R> C.withUse(block: C.() -> R): R {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
|
@ -16,7 +16,6 @@ package net.mamoe.mirai.qqandroid.utils.io
|
||||
import kotlinx.io.core.*
|
||||
import net.mamoe.mirai.qqandroid.utils.coerceAtMostOrFail
|
||||
import net.mamoe.mirai.qqandroid.utils.cryptor.TEA
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
|
||||
@ -66,6 +65,6 @@ internal fun BytePacketBuilder.writeHex(uHex: String) {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
internal inline fun BytePacketBuilder.encryptAndWrite(key: ByteArray, encoder: BytePacketBuilder.() -> Unit) =
|
||||
TEA.encrypt(BytePacketBuilder().apply(encoder).build(), key) { decrypted -> writeFully(decrypted) }
|
@ -10,11 +10,9 @@
|
||||
package net.mamoe.mirai.qqandroid.utils
|
||||
|
||||
import kotlinx.io.core.toByteArray
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal class PlatformUtilsTest {
|
||||
|
||||
@Test
|
||||
|
@ -22,7 +22,6 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
* QQ for Android
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
actual object QQAndroid : BotFactory {
|
||||
|
||||
/**
|
||||
|
@ -23,12 +23,10 @@ import net.mamoe.mirai.utils.ContextImpl
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
@Suppress("FunctionName")
|
||||
internal fun QQAndroidBot(account: BotAccount, configuration: BotConfiguration): QQAndroidBot =
|
||||
QQAndroidBot(ContextImpl(), account, configuration)
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@Suppress("DEPRECATION")
|
||||
internal actual fun ByteReadChannel.toKotlinByteReadChannel(): kotlinx.coroutines.io.ByteReadChannel {
|
||||
return object : kotlinx.coroutines.io.ByteReadChannel {
|
||||
|
@ -81,7 +81,6 @@ internal actual class PlatformSocket : Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalIoApi::class)
|
||||
actual suspend fun connect(coroutineContext: CoroutineContext, serverHost: String, serverPort: Int) {
|
||||
withContext(Dispatchers.IO) {
|
||||
socket = Socket(serverHost, serverPort)
|
||||
|
@ -71,7 +71,6 @@ internal actual class ECDH actual constructor(actual val keyPair: ECDHKeyPair) {
|
||||
.genKeyPair())
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
actual fun calculateShareKey(
|
||||
privateKey: ECDHPrivateKey,
|
||||
publicKey: ECDHPublicKey
|
||||
|
@ -41,6 +41,13 @@ kotlin {
|
||||
all {
|
||||
languageSettings.enableLanguageFeature("InlineClasses")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.Experimental")
|
||||
languageSettings.useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiInternalAPI")
|
||||
languageSettings.useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiExperimentalAPI")
|
||||
languageSettings.useExperimentalAnnotation("net.mamoe.mirai.LowLevelAPI")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.time.ExperimentalTime")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
||||
languageSettings.progressiveMode = true
|
||||
}
|
||||
|
||||
|
@ -125,14 +125,13 @@ actual abstract class BotJavaFriendlyAPI actual constructor() {
|
||||
* @param message 若需要验证请求时的验证消息.
|
||||
* @param remark 好友备注
|
||||
*/
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@JvmName("addFriend")
|
||||
fun __addFriendBlockingForJava__(
|
||||
id: Long,
|
||||
message: String? = null,
|
||||
remark: String? = null
|
||||
): AddFriendResult {
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
|
||||
return runBlocking { addFriend(id, message, remark) }
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@ import net.mamoe.mirai.utils.WeakRefProperty
|
||||
* 群成员.
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@OptIn(MiraiInternalAPI::class, JavaFriendlyAPI::class)
|
||||
actual abstract class Member : MemberJavaFriendlyAPI() {
|
||||
/**
|
||||
* 所在的群.
|
||||
|
@ -29,7 +29,6 @@ import java.net.URL
|
||||
message = "use ContactMessage",
|
||||
replaceWith = ReplaceWith("ContactMessage", "net.mamoe.mirai.message.ContactMessage")
|
||||
)
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
actual abstract class MessagePacket<TSender : QQ, TSubject : Contact> actual constructor() :
|
||||
MessagePacketBase<TSender, TSubject>() {
|
||||
|
||||
|
@ -43,7 +43,6 @@ fun Bitmap.toExternalImage(formatName: String = "gif"): ExternalImage {
|
||||
/**
|
||||
* 读取文件头识别图片属性, 然后构造 [ExternalImage]
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@Throws(IOException::class)
|
||||
fun File.toExternalImage(): ExternalImage {
|
||||
val input = BitmapFactory.decodeFile(this.absolutePath)
|
||||
|
@ -108,8 +108,6 @@ actual open class SystemDeviceInfo actual constructor() : DeviceInfo() {
|
||||
(context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager).connectionInfo.ssid.orEmpty()
|
||||
.toByteArray()
|
||||
}.getOrEmpty()
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
override val imsiMd5: ByteArray
|
||||
@SuppressLint("HardwareIds")
|
||||
get() = kotlin.runCatching {
|
||||
|
@ -49,7 +49,6 @@ suspend inline fun <B : Bot> B.alsoLogin(): B = also { login() }
|
||||
* @see BotFactory 构造 [Bot] 的工厂, [Bot] 唯一的构造方式.
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@OptIn(MiraiInternalAPI::class, LowLevelAPI::class)
|
||||
abstract class Bot : CoroutineScope, LowLevelBotAPIAccessor, BotJavaFriendlyAPI(), ContactOrBot {
|
||||
companion object {
|
||||
/**
|
||||
@ -269,7 +268,6 @@ abstract class Bot : CoroutineScope, LowLevelBotAPIAccessor, BotJavaFriendlyAPI(
|
||||
*/
|
||||
abstract fun close(cause: Throwable? = null)
|
||||
|
||||
@OptIn(LowLevelAPI::class, MiraiExperimentalAPI::class)
|
||||
final override fun toString(): String = "Bot($id)"
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,6 @@ import kotlin.time.measureTime
|
||||
/*
|
||||
* 泛型 N 不需要向外(接口)暴露.
|
||||
*/
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@MiraiInternalAPI
|
||||
abstract class BotImpl<N : BotNetworkHandler> constructor(
|
||||
context: Context,
|
||||
@ -254,7 +253,7 @@ abstract class BotImpl<N : BotNetworkHandler> constructor(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
override fun close(cause: Throwable?) {
|
||||
if (!this.isActive) {
|
||||
// already cancelled
|
||||
|
@ -23,7 +23,10 @@ import net.mamoe.mirai.message.MessageReceipt
|
||||
import net.mamoe.mirai.message.data.Image
|
||||
import net.mamoe.mirai.message.data.Message
|
||||
import net.mamoe.mirai.message.data.toMessage
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.ExternalImage
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.OverFileSizeMaxException
|
||||
import net.mamoe.mirai.utils.get
|
||||
import net.mamoe.mirai.utils.internal.runBlocking
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmStatic
|
||||
@ -190,7 +193,6 @@ abstract class Group : Contact(), CoroutineScope {
|
||||
/**
|
||||
* @see quit
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@Suppress("FunctionName")
|
||||
@JvmName("quit")
|
||||
@JavaFriendlyAPI
|
||||
|
@ -18,7 +18,6 @@ import net.mamoe.mirai.getFriendOrNull
|
||||
import net.mamoe.mirai.message.MessageReceipt
|
||||
import net.mamoe.mirai.message.data.Message
|
||||
import net.mamoe.mirai.message.data.toMessage
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.WeakRefProperty
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
import kotlin.time.Duration
|
||||
@ -34,7 +33,7 @@ import kotlin.time.ExperimentalTime
|
||||
* [Member.isFriend] 判断此成员是否为好友
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@OptIn(MiraiInternalAPI::class, JavaFriendlyAPI::class)
|
||||
@OptIn(JavaFriendlyAPI::class)
|
||||
abstract class Member : MemberJavaFriendlyAPI() {
|
||||
/**
|
||||
* 所在的群.
|
||||
|
@ -14,7 +14,6 @@ package net.mamoe.mirai.event
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import net.mamoe.mirai.event.internal.broadcastInternal
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
import kotlin.jvm.Volatile
|
||||
@ -142,7 +141,6 @@ interface CancellableEvent : Event {
|
||||
/**
|
||||
* 广播一个事件的唯一途径.
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
suspend fun <E : Event> E.broadcast(): E = apply {
|
||||
if (this is BroadcastControllable && !this.shouldBroadcast) {
|
||||
return@apply
|
||||
|
@ -26,7 +26,6 @@ import kotlinx.coroutines.channels.ReceiveChannel
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.event.events.BotEvent
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
@ -64,7 +63,6 @@ abstract class AbstractCancellableEvent : AbstractEvent(), CancellableEvent
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
@kotlin.internal.LowPriorityInOverloadResolution
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun <R> Bot.subscribeMessages(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
|
||||
@ -90,7 +88,6 @@ fun <R> Bot.subscribeMessages(
|
||||
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun <R> Bot.subscribeGroupMessages(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
|
||||
@ -116,7 +113,6 @@ fun <R> Bot.subscribeGroupMessages(
|
||||
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun <R> Bot.subscribeFriendMessages(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
|
||||
@ -143,7 +139,6 @@ fun <R> Bot.subscribeFriendMessages(
|
||||
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun <R> Bot.subscribeTempMessages(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
|
||||
|
@ -187,7 +187,6 @@ sealed class MessageRecallEvent : BotEvent, AbstractEvent() {
|
||||
) : MessageRecallEvent(), GroupOperableEvent, Packet
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
val MessageRecallEvent.GroupRecall.author: Member
|
||||
get() = if (authorId == bot.id) group.botAsMember else group[authorId]
|
||||
|
||||
|
@ -14,7 +14,6 @@ import net.mamoe.mirai.contact.Friend
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.contact.Member
|
||||
import net.mamoe.mirai.event.Event
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
|
||||
/**
|
||||
* 有关一个 [Bot] 的事件
|
||||
@ -76,7 +75,6 @@ val GroupOperableEvent.isByBot: Boolean
|
||||
* 当操作人为 [Member] 时获取这个 [Member],
|
||||
* 当操作人为 [Bot] 时获取 [Group.botAsMember]
|
||||
*/
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
val GroupOperableEvent.operatorOrBot: Member
|
||||
get() = this.operator ?: this.group.botAsMember
|
||||
|
||||
|
@ -15,7 +15,10 @@ import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import net.mamoe.mirai.event.*
|
||||
import net.mamoe.mirai.event.events.BotEvent
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.LockFreeLinkedList
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.MiraiLogger
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.coroutineContext
|
||||
import kotlin.jvm.JvmField
|
||||
@ -26,10 +29,8 @@ internal fun <L : Listener<E>, E : Event> KClass<out E>.subscribeInternal(listen
|
||||
with(GlobalEventListeners[listener.priority]) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val node = ListenerNode(listener as Listener<Event>, this@subscribeInternal)
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
addLast(node)
|
||||
listener.invokeOnCompletion {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
this.remove(node)
|
||||
}
|
||||
}
|
||||
@ -128,13 +129,11 @@ internal expect class MiraiAtomicBoolean(initial: Boolean) {
|
||||
// inline: NO extra Continuation
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
internal suspend inline fun Event.broadcastInternal() {
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
if (EventDisabled) return
|
||||
callAndRemoveIfRequired(this@broadcastInternal as? AbstractEvent ?: error("Events must extends AbstractEvent"))
|
||||
}
|
||||
|
||||
@Suppress("DuplicatedCode")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal suspend fun <E : AbstractEvent> callAndRemoveIfRequired(
|
||||
event: E
|
||||
) {
|
||||
|
@ -18,7 +18,6 @@ import net.mamoe.mirai.message.data.PlainText
|
||||
import net.mamoe.mirai.message.isContextIdenticalWith
|
||||
import net.mamoe.mirai.message.nextMessage
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import kotlin.experimental.ExperimentalTypeInference
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
@ -69,7 +68,6 @@ suspend inline fun <reified T : MessageEvent> T.whileSelectMessages(
|
||||
/**
|
||||
* [selectMessages] 的 [Unit] 返回值捷径 (由于 Kotlin 无法推断 [Unit] 类型)
|
||||
*/
|
||||
@OptIn(ExperimentalTypeInference::class)
|
||||
@MiraiExperimentalAPI
|
||||
@JvmName("selectMessages1")
|
||||
suspend inline fun <reified T : MessageEvent> T.selectMessagesUnit(
|
||||
@ -474,7 +472,6 @@ internal val ExceptionHandlerIgnoringCancellationException = CoroutineExceptionH
|
||||
|
||||
@PublishedApi
|
||||
@BuilderInference
|
||||
@OptIn(ExperimentalTypeInference::class)
|
||||
internal suspend inline fun <reified T : MessageEvent, R> T.selectMessagesImpl(
|
||||
timeoutMillis: Long = -1,
|
||||
isUnit: Boolean,
|
||||
|
@ -22,7 +22,6 @@ import net.mamoe.mirai.message.FriendMessageEvent
|
||||
import net.mamoe.mirai.message.GroupMessageEvent
|
||||
import net.mamoe.mirai.message.MessageEvent
|
||||
import net.mamoe.mirai.message.TempMessageEvent
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
@ -39,7 +38,7 @@ typealias MessagePacketSubscribersBuilder = MessageSubscribersBuilder<MessageEve
|
||||
*
|
||||
* @see CoroutineScope.incoming 打开一个指定事件的接收通道
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
|
||||
fun <R> CoroutineScope.subscribeMessages(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
|
||||
@ -73,7 +72,6 @@ typealias GroupMessageSubscribersBuilder = MessageSubscribersBuilder<GroupMessag
|
||||
*
|
||||
* @see CoroutineScope.incoming 打开一个指定事件的接收通道
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun <R> CoroutineScope.subscribeGroupMessages(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
|
||||
@ -101,7 +99,6 @@ typealias FriendMessageSubscribersBuilder = MessageSubscribersBuilder<FriendMess
|
||||
*
|
||||
* @see CoroutineScope.incoming 打开一个指定事件的接收通道
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun <R> CoroutineScope.subscribeFriendMessages(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
|
||||
@ -129,7 +126,6 @@ typealias TempMessageSubscribersBuilder = MessageSubscribersBuilder<TempMessageE
|
||||
*
|
||||
* @see CoroutineScope.incoming 打开一个指定事件的接收通道
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun <R> CoroutineScope.subscribeTempMessages(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
|
||||
|
@ -22,7 +22,6 @@ import net.mamoe.mirai.event.Listener.EventPriority.NORMAL
|
||||
import net.mamoe.mirai.event.events.BotEvent
|
||||
import net.mamoe.mirai.event.internal.Handler
|
||||
import net.mamoe.mirai.event.internal.subscribeInternal
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
@ -41,7 +40,6 @@ import kotlin.reflect.KClass
|
||||
@Suppress("DeprecatedCallableAddReplaceWith", "DEPRECATION")
|
||||
@JvmSynthetic
|
||||
@JvmName("subscribeAlwaysForBot")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@kotlin.internal.LowPriorityInOverloadResolution
|
||||
@Deprecated(
|
||||
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
|
||||
@ -80,7 +78,6 @@ fun <E : BotEvent> Bot.subscribe(
|
||||
@JvmSynthetic
|
||||
@JvmName("subscribeAlwaysForBot1")
|
||||
@kotlin.internal.LowPriorityInOverloadResolution
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@Deprecated(
|
||||
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
|
||||
level = DeprecationLevel.HIDDEN
|
||||
@ -248,7 +245,6 @@ fun <E : Event> CoroutineScope.subscribeOnceDeprecated(
|
||||
@PlannedRemoval("1.2.0")
|
||||
@JvmSynthetic
|
||||
@JvmName("subscribeAlwaysForBot")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
@Suppress("unused")
|
||||
inline fun <reified E : BotEvent> Bot.subscribeDeprecated(
|
||||
@ -285,7 +281,6 @@ fun <E : BotEvent> Bot.subscribeDeprecated(
|
||||
@JvmName("subscribeAlwaysForBot1")
|
||||
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
@Suppress("unused")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
inline fun <reified E : BotEvent> Bot.subscribeAlwaysDeprecated(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
concurrency: Listener.ConcurrencyKind = CONCURRENT,
|
||||
|
@ -18,7 +18,6 @@ import net.mamoe.mirai.contact.*
|
||||
import net.mamoe.mirai.message.data.*
|
||||
import net.mamoe.mirai.recallIn
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.internal.runBlocking
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
@ -42,7 +41,6 @@ import kotlin.jvm.JvmSynthetic
|
||||
* @see MessageReceipt.sourceId 源 id
|
||||
* @see MessageReceipt.sourceTime 源时间
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
open class MessageReceipt<out C : Contact>(
|
||||
/**
|
||||
* 指代发送出去的消息.
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import kotlin.jvm.JvmField
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
@ -53,7 +52,7 @@ internal constructor(
|
||||
|
||||
private var toStringCache: String? = null
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
|
||||
override fun toString(): String = toStringCache ?: (left.toString() + tail.toString()).also { toStringCache = it }
|
||||
|
||||
private var contentToStringCache: String? = null
|
||||
@ -70,7 +69,7 @@ internal constructor(
|
||||
/*
|
||||
@JvmSynthetic
|
||||
// 不要把它用作 local function, 会编译错误
|
||||
@OptIn(MiraiExperimentalAPI::class, MiraiInternalAPI::class)
|
||||
|
||||
private suspend fun SequenceScope<SingleMessage>.yieldCombinedOrElementsFlatten(message: Message) {
|
||||
when (message) {
|
||||
is CombinedMessage -> {
|
||||
|
@ -114,7 +114,6 @@ sealed class CustomMessage : SingleMessage {
|
||||
override val typeName: String get() = "CustomMessage"
|
||||
private val factories: LockFreeLinkedList<Factory<*>> = LockFreeLinkedList()
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal fun register(factory: Factory<out CustomMessage>) {
|
||||
factories.removeIf { it::class == factory::class }
|
||||
val exist = factories.asSequence().firstOrNull { it.typeName == factory.typeName }
|
||||
@ -135,7 +134,6 @@ sealed class CustomMessage : SingleMessage {
|
||||
class CustomMessageFullDataDeserializeUserException(val body: ByteArray, cause: Throwable?) :
|
||||
RuntimeException(cause)
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
internal fun deserialize(fullData: ByteReadPacket): CustomMessage? {
|
||||
val msg = kotlin.runCatching {
|
||||
val length = fullData.readInt()
|
||||
@ -194,7 +192,6 @@ abstract class CustomMessageMetadata : CustomMessage(), MessageMetadata {
|
||||
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
internal inline fun <T : CustomMessageMetadata> T.customToStringImpl(factory: CustomMessage.Factory<*>): ByteArray {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return (factory as CustomMessage.Factory<T>).serialize(this)
|
||||
|
@ -542,8 +542,6 @@ class ForwardMessageBuilder private constructor(
|
||||
|
||||
/** 构造 [ForwardMessage] */
|
||||
fun build(): ForwardMessage = ForwardMessage(container.toList(), this.displayStrategy)
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
internal fun Bot.smartName(): String = when (val c = this@ForwardMessageBuilder.context) {
|
||||
is Group -> c.botAsMember.nameCardOrNick
|
||||
else -> nick
|
||||
|
@ -15,8 +15,6 @@ package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.message.data.PokeMessage.Types
|
||||
import net.mamoe.mirai.message.data.VipFace.Companion
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import kotlin.jvm.*
|
||||
|
||||
/**
|
||||
@ -42,7 +40,6 @@ sealed class HummerMessage : MessageContent {
|
||||
*
|
||||
* @see Types 使用伴生对象中的常量
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
data class PokeMessage internal constructor(
|
||||
/**
|
||||
* 仅 mirai, 显示的名称
|
||||
@ -133,7 +130,7 @@ data class PokeMessage internal constructor(
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
|
||||
private val stringValue = "[mirai:poke:$type,$id]"
|
||||
|
||||
override fun toString(): String = stringValue
|
||||
@ -155,7 +152,6 @@ data class PokeMessage internal constructor(
|
||||
*
|
||||
* @see Types 使用伴生对象中的常量
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
data class VipFace internal constructor(
|
||||
/**
|
||||
* 使用 [Companion] 中常量.
|
||||
@ -217,7 +213,7 @@ data class VipFace internal constructor(
|
||||
private infix fun Int.to(name: String): Kind = Kind(this, name)
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
|
||||
private val stringValue = "[mirai:vipface:$kind,$count]"
|
||||
|
||||
override fun toString(): String = stringValue
|
||||
@ -245,7 +241,7 @@ sealed class FlashImage : MessageContent, HummerMessage() {
|
||||
@JvmStatic
|
||||
@JvmName("from")
|
||||
operator fun invoke(image: Image): FlashImage {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
return when (image) {
|
||||
is GroupImage -> GroupFlashImage(image)
|
||||
is FriendImage -> FriendFlashImage(image)
|
||||
|
@ -100,7 +100,6 @@ expect interface Image : Message, MessageContent {
|
||||
@PlannedRemoval("1.2.0") // make internal
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
// CustomFace
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
sealed class GroupImage : AbstractImage() {
|
||||
companion object Key : Message.Key<GroupImage> {
|
||||
override val typeName: String get() = "GroupImage"
|
||||
@ -124,7 +123,6 @@ val Image.md5: ByteArray
|
||||
*/ // NotOnlineImage
|
||||
@PlannedRemoval("1.2.0") // make internal
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
sealed class FriendImage : AbstractImage() {
|
||||
companion object Key : Message.Key<FriendImage> {
|
||||
override val typeName: String get() = "FriendImage"
|
||||
@ -190,7 +188,6 @@ fun Image(imageId: String): OfflineImage = when {
|
||||
@JvmSynthetic
|
||||
suspend fun Image.queryUrl(): String {
|
||||
@Suppress("DEPRECATION")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
return when (this) {
|
||||
is OnlineImage -> this.originUrl
|
||||
else -> BotImpl.instances.peekFirst().get()?.queryImageUrl(this)
|
||||
@ -248,7 +245,6 @@ interface OfflineImage : Image {
|
||||
)
|
||||
@JvmSynthetic
|
||||
suspend fun OfflineImage.queryUrl(): String {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
return BotImpl.instances.peekFirst().get()?.queryImageUrl(this) ?: error("No Bot available to query image url")
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,7 @@ import net.mamoe.mirai.contact.Contact
|
||||
import net.mamoe.mirai.message.MessageEvent
|
||||
import net.mamoe.mirai.message.MessageReceipt
|
||||
import net.mamoe.mirai.message.data.Message.Key
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
@ -78,7 +76,6 @@ import kotlin.jvm.JvmSynthetic
|
||||
*
|
||||
* @see Contact.sendMessage 发送消息
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
interface Message { // must be interface. Don't consider any changes.
|
||||
/**
|
||||
* 类型 Key. 由伴生对象实现, 表示一个 [Message] 对象的类型.
|
||||
@ -205,7 +202,6 @@ inline val Message.content: String
|
||||
* - [PlainText] 长度为 0
|
||||
* - [MessageChain] 所有元素都满足 [isContentEmpty]
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun Message.isContentEmpty(): Boolean {
|
||||
contract {
|
||||
returns(false) implies (this@isContentEmpty is MessageContent)
|
||||
@ -218,7 +214,6 @@ fun Message.isContentEmpty(): Boolean {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
inline fun Message.isContentNotEmpty(): Boolean {
|
||||
contract {
|
||||
returns(true) implies (this@isContentNotEmpty is MessageContent)
|
||||
@ -226,7 +221,6 @@ inline fun Message.isContentNotEmpty(): Boolean {
|
||||
return !this.isContentEmpty()
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
inline fun Message.isPlain(): Boolean {
|
||||
contract {
|
||||
returns(true) implies (this@isPlain is PlainText)
|
||||
@ -235,7 +229,6 @@ inline fun Message.isPlain(): Boolean {
|
||||
return this is PlainText
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
inline fun Message.isNotPlain(): Boolean {
|
||||
contract {
|
||||
returns(false) implies (this@isNotPlain is PlainText)
|
||||
|
@ -15,7 +15,6 @@
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.JavaFriendlyAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import kotlin.js.JsName
|
||||
@ -173,7 +172,6 @@ inline fun <reified M : Message> MessageChain.anyIsInstance(): Boolean = this.an
|
||||
/**
|
||||
* 获取第一个 [M] 类型的 [Message] 实例
|
||||
*/
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@JvmSynthetic
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <M : Message> MessageChain.firstOrNull(key: Message.Key<M>): M? = firstOrNullImpl(key)
|
||||
@ -278,7 +276,6 @@ inline fun messageChainOf(vararg messages: Message): MessageChain = messages.asM
|
||||
@JvmName("newChain")
|
||||
@JsName("newChain")
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
fun Message.asMessageChain(): MessageChain = when (this) {
|
||||
is MessageChain -> this
|
||||
is CombinedMessage -> (this as Iterable<Message>).asMessageChain()
|
||||
@ -409,7 +406,6 @@ inline fun Array<out SingleMessage>.flatten(): Sequence<SingleMessage> = this.as
|
||||
* - 其他: 返回 `sequenceOf(this)`
|
||||
*/
|
||||
fun Message.flatten(): Sequence<SingleMessage> {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
return when (this) {
|
||||
is MessageChain -> this.asSequence()
|
||||
is CombinedMessage -> this.asSequence() // already constrained single.
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
@ -48,7 +47,6 @@ inline fun buildMessageChain(initialSize: Int, block: MessageChainBuilder.() ->
|
||||
* @see buildMessageChain 推荐使用
|
||||
* @see asMessageChain 完成构建
|
||||
*/
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
open class MessageChainBuilder private constructor(
|
||||
private val container: MutableList<SingleMessage>
|
||||
) : MutableList<SingleMessage> by container, Appendable {
|
||||
|
@ -20,8 +20,6 @@ import net.mamoe.mirai.message.MessageEvent
|
||||
import net.mamoe.mirai.message.MessageReceipt
|
||||
import net.mamoe.mirai.recallIn
|
||||
import net.mamoe.mirai.utils.LazyProperty
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
@ -58,7 +56,6 @@ import kotlin.jvm.JvmSynthetic
|
||||
* @see OnlineMessageSource 在线消息的 [MessageSource]
|
||||
* @see OfflineMessageSource 离线消息的 [MessageSource]
|
||||
*/
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
sealed class MessageSource : Message, MessageMetadata, ConstrainSingle<MessageSource> {
|
||||
companion object Key : Message.Key<MessageSource> {
|
||||
override val typeName: String get() = "MessageSource"
|
||||
@ -156,7 +153,6 @@ sealed class MessageSource : Message, MessageMetadata, ConstrainSingle<MessageSo
|
||||
*
|
||||
* @see OnlineMessageSource.toOffline 转为 [OfflineMessageSource]
|
||||
*/
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
sealed class OnlineMessageSource : MessageSource() {
|
||||
companion object Key : Message.Key<OnlineMessageSource> {
|
||||
override val typeName: String get() = "OnlineMessageSource"
|
||||
@ -336,7 +332,7 @@ inline fun MessageSource.isAboutFriend(): Boolean {
|
||||
* @see QuoteReply
|
||||
*/
|
||||
fun MessageSource.quote(): QuoteReply {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
return QuoteReply(this)
|
||||
}
|
||||
|
||||
@ -345,7 +341,7 @@ fun MessageSource.quote(): QuoteReply {
|
||||
* @see QuoteReply
|
||||
*/
|
||||
fun MessageChain.quote(): QuoteReply {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
return QuoteReply(this.source)
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@ package net.mamoe.mirai.message.data
|
||||
|
||||
import kotlinx.coroutines.Job
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
@ -45,7 +44,6 @@ import kotlin.jvm.JvmSynthetic
|
||||
*
|
||||
* @see MessageSource 获取有关消息源的更多信息
|
||||
*/
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
class QuoteReply(val source: MessageSource) : Message, MessageMetadata, ConstrainSingle<QuoteReply> {
|
||||
companion object Key : Message.Key<QuoteReply> {
|
||||
override val typeName: String
|
||||
|
@ -227,5 +227,5 @@ internal class LongMessage internal constructor(content: String, val resId: Stri
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
|
||||
internal class ForwardMessageInternal(content: String) : ServiceMessage(35, content)
|
@ -14,7 +14,6 @@
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
@ -23,9 +22,6 @@ import kotlin.native.concurrent.SharedImmutable
|
||||
/////////////////////////
|
||||
//// IMPLEMENTATIONS ////
|
||||
/////////////////////////
|
||||
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
private fun Message.hasDuplicationOfConstrain(key: Message.Key<*>): Boolean {
|
||||
return when (this) {
|
||||
is SingleMessage -> (this as? ConstrainSingle<*>)?.key == key
|
||||
@ -129,7 +125,6 @@ internal fun Message.followedByImpl(tail: Message): MessageChain {
|
||||
}
|
||||
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@JvmSynthetic
|
||||
internal fun Sequence<SingleMessage>.constrainSingleMessages(): List<SingleMessage> {
|
||||
val iterator = this.iterator()
|
||||
@ -169,7 +164,7 @@ internal inline fun constrainSingleMessagesImpl(iterator: () -> SingleMessage?):
|
||||
}
|
||||
|
||||
@JvmSynthetic
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
|
||||
internal fun Iterable<SingleMessage>.constrainSingleMessages(): List<SingleMessage> {
|
||||
val iterator = this.iterator()
|
||||
return constrainSingleMessagesImpl supplier@{
|
||||
@ -189,7 +184,6 @@ internal inline fun <T> List<T>.indexOfFirst(offset: Int, predicate: (T) -> Bool
|
||||
}
|
||||
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@JvmSynthetic
|
||||
@Suppress("UNCHECKED_CAST", "DEPRECATION_ERROR", "DEPRECATION")
|
||||
internal fun <M : Message> MessageChain.firstOrNullImpl(key: Message.Key<M>): M? = when (key) {
|
||||
|
@ -124,7 +124,7 @@ abstract class BotNetworkHandler : CoroutineScope {
|
||||
}
|
||||
|
||||
@MiraiInternalAPI
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
suspend fun BotNetworkHandler.closeAndJoin(cause: Throwable? = null) {
|
||||
this.close(cause)
|
||||
this.supervisor.join()
|
||||
|
@ -29,7 +29,6 @@ open class BotConfiguration {
|
||||
var botLoggerSupplier: ((Bot) -> MiraiLogger) = { DefaultLogger("Bot(${it.id})") }
|
||||
|
||||
/** 网络层日志构造器 */
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
var networkLoggerSupplier: ((BotNetworkHandler) -> MiraiLogger) = { DefaultLogger("Network(${it.bot.id})") }
|
||||
|
||||
/** 设备信息覆盖. 默认使用随机的设备信息. */
|
||||
@ -99,7 +98,6 @@ open class BotConfiguration {
|
||||
/**
|
||||
* 不显示网络日志
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@ConfigurationDsl
|
||||
fun noNetworkLog() {
|
||||
networkLoggerSupplier = { _: BotNetworkHandler -> SilentLogger }
|
||||
@ -137,7 +135,6 @@ open class BotConfiguration {
|
||||
|
||||
@SinceMirai("1.0.0")
|
||||
fun copy(): BotConfiguration {
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
return BotConfiguration().also { new ->
|
||||
new.botLoggerSupplier = botLoggerSupplier
|
||||
new.networkLoggerSupplier = networkLoggerSupplier
|
||||
|
@ -92,7 +92,6 @@ abstract class DeviceInfo {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@Serializable
|
||||
class DeviceInfoData(
|
||||
override val display: ByteArray,
|
||||
|
@ -1,11 +1,10 @@
|
||||
package net.mamoe.mirai.utils.internal
|
||||
|
||||
import net.mamoe.mirai.utils.FileCacheStrategy
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
|
||||
internal expect class DeferredReusableInput(input: Any, extraArg: Any?) : ReusableInput {
|
||||
val initialized: Boolean
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
|
||||
suspend fun init(strategy: FileCacheStrategy)
|
||||
}
|
@ -1,10 +1,9 @@
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
internal class CombinedMessageTest {
|
||||
|
||||
|
||||
|
@ -9,15 +9,12 @@
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertSame
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
internal class TestConstrainSingleMessage : ConstrainSingle<TestConstrainSingleMessage>, Any() {
|
||||
companion object Key : Message.Key<TestConstrainSingleMessage> {
|
||||
override val typeName: String
|
||||
@ -30,10 +27,10 @@ internal class TestConstrainSingleMessage : ConstrainSingle<TestConstrainSingleM
|
||||
get() = Key
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
|
||||
internal class ConstrainSingleTest {
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
|
||||
@Test
|
||||
fun testCombine() {
|
||||
val result = PlainText("te") + PlainText("st")
|
||||
|
@ -186,7 +186,6 @@ actual interface FileCacheStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
internal inline fun <I : Closeable, O : Closeable, R> I.withOut(output: O, block: I.(output: O) -> R): R {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
|
@ -145,7 +145,7 @@ actual abstract class LoginSolver {
|
||||
|
||||
actual companion object {
|
||||
actual val Default: LoginSolver =
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
|
||||
DefaultLoginSolver({ readLine() ?: throw NoStandardInputForCaptchaException(null) })
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ fun File.loadAsDeviceInfo(context: Context = ContextImpl()): DeviceInfo {
|
||||
private val JSON = Json(JsonConfiguration.Stable)
|
||||
|
||||
@Serializable
|
||||
@OptIn(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
|
||||
actual open class SystemDeviceInfo actual constructor() : DeviceInfo() {
|
||||
actual constructor(context: Context) : this() {
|
||||
this.context = context
|
||||
|
@ -15,7 +15,7 @@ internal actual class DeferredReusableInput actual constructor(
|
||||
) : ReusableInput {
|
||||
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
|
||||
actual suspend fun init(strategy: FileCacheStrategy) = withContext(Dispatchers.IO) {
|
||||
if (delegate != null) {
|
||||
return@withContext
|
||||
|
@ -219,7 +219,6 @@ class EventTests {
|
||||
*/
|
||||
fun resetEventListeners() {
|
||||
for (p in Listener.EventPriority.values()) {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
GlobalEventListeners[p].clear()
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("RedundantSuspendModifier", "unused")
|
||||
@file:Suppress("RedundantSuspendModifier", "unused", "UNUSED_PARAMETER")
|
||||
|
||||
package net.mamoe.mirai.event
|
||||
|
||||
@ -28,32 +28,38 @@ internal class JvmMethodEventsTest {
|
||||
|
||||
fun getCalled() = called.get()
|
||||
|
||||
@Suppress("unused")
|
||||
@EventHandler
|
||||
suspend fun TestEvent.`suspend receiver param Unit`(event: TestEvent) {
|
||||
called.getAndIncrement()
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
@EventHandler
|
||||
suspend fun TestEvent.`suspend receiver Unit`() {
|
||||
called.getAndIncrement()
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
@EventHandler
|
||||
suspend fun `suspend param Unit`(event: TestEvent) {
|
||||
called.getAndIncrement()
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@Suppress("unused")
|
||||
fun TestEvent.`receiver param Unit`(event: TestEvent) {
|
||||
called.getAndIncrement()
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@Suppress("unused")
|
||||
suspend fun TestEvent.`suspend receiver param LS`(event: TestEvent): ListeningStatus {
|
||||
called.getAndIncrement()
|
||||
return ListeningStatus.STOPPED
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
@EventHandler
|
||||
suspend fun TestEvent.`suspend receiver LS`(): ListeningStatus {
|
||||
called.getAndIncrement()
|
||||
@ -61,12 +67,14 @@ internal class JvmMethodEventsTest {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@Suppress("unused")
|
||||
suspend fun `suspend param LS`(event: TestEvent): ListeningStatus {
|
||||
called.getAndIncrement()
|
||||
return ListeningStatus.STOPPED
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@Suppress("unused")
|
||||
fun TestEvent.`receiver param LS`(event: TestEvent): ListeningStatus {
|
||||
called.getAndIncrement()
|
||||
return ListeningStatus.STOPPED
|
||||
@ -91,13 +99,15 @@ internal class JvmMethodEventsTest {
|
||||
|
||||
fun getCalled() = called.get()
|
||||
|
||||
@EventHandler(Listener.EventPriority.HIGHEST)
|
||||
@Suppress("unused")
|
||||
@EventHandler(EventPriority.HIGHEST)
|
||||
private suspend fun TestEvent.`suspend receiver param Unit`(event: TestEvent) {
|
||||
intercept()
|
||||
called.getAndIncrement()
|
||||
}
|
||||
|
||||
@EventHandler(EventPriority.MONITOR)
|
||||
@Suppress("unused")
|
||||
private fun TestEvent.`receiver param LS`(event: TestEvent): ListeningStatus {
|
||||
called.getAndIncrement()
|
||||
return ListeningStatus.STOPPED
|
||||
|
@ -20,7 +20,6 @@ import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@Suppress("UnusedEquals")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@MiraiExperimentalAPI
|
||||
internal class LockFreeLinkedListTest {
|
||||
@Test
|
||||
@ -136,7 +135,6 @@ internal class LockFreeLinkedListTest {
|
||||
list.size shouldBeEqualTo 0
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@Test
|
||||
fun withInlineClassElements() {
|
||||
val list = LockFreeLinkedList<UInt>()
|
||||
@ -264,7 +262,7 @@ internal class LockFreeLinkedListTest {
|
||||
*/
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class, MiraiInternalAPI::class)
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@MiraiExperimentalAPI
|
||||
internal suspend inline fun <E : LockFreeLinkedList<*>> E.concurrentDo(
|
||||
numberOfCoroutines: Int,
|
||||
|
Loading…
Reference in New Issue
Block a user