mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-27 08:50:15 +08:00
parent
b62151ea6e
commit
60b6eab73e
@ -71,7 +71,7 @@ If you meet any problem or have any questions, be free to open a issue. Our goal
|
||||
|
||||
## Requirements
|
||||
|
||||
Kotlin 1.3.70
|
||||
Kotlin 1.3.61
|
||||
|
||||
On JVM: Java 6
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
## 构建需求
|
||||
|
||||
- Kotlin 1.3.70 (必须)
|
||||
- Kotlin 1.3.61 (必须)
|
||||
- JDK 6 或更高 (必须)
|
||||
- Android SDK 29 (可选, 用于编译安卓目标)
|
||||
|
||||
|
@ -5,7 +5,7 @@ miraiVersion=0.24.1
|
||||
kotlin.incremental.multiplatform=true
|
||||
kotlin.parallel.tasks.in.project=true
|
||||
# kotlin
|
||||
kotlinVersion=1.3.70
|
||||
kotlinVersion=1.3.61
|
||||
# kotlin libraries
|
||||
serializationVersion=0.20.0-1.3.70-eap-274-2
|
||||
coroutinesVersion=1.3.3
|
||||
|
@ -21,7 +21,7 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
actual object QQAndroid : BotFactory {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
@JvmName("newBot")
|
||||
actual override fun Bot(context: Context, qq: Long, password: String, configuration: BotConfiguration): Bot {
|
||||
return QQAndroidBot(context, BotAccount(qq, password), configuration)
|
||||
@ -30,7 +30,7 @@ actual object QQAndroid : BotFactory {
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
@JvmName("newBot")
|
||||
actual override fun Bot(
|
||||
context: Context,
|
||||
|
@ -14,7 +14,7 @@ import net.mamoe.mirai.utils.BotConfiguration
|
||||
import net.mamoe.mirai.utils.Context
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal actual class QQAndroidBot
|
||||
actual constructor(
|
||||
context: Context,
|
||||
|
@ -367,7 +367,7 @@ internal fun GroupImpl.Companion.checkIsInstance(expression: Boolean) {
|
||||
}
|
||||
|
||||
@Suppress("PropertyName")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal class GroupImpl(
|
||||
bot: QQAndroidBot, override val coroutineContext: CoroutineContext,
|
||||
override val id: Long,
|
||||
@ -383,7 +383,7 @@ internal class GroupImpl(
|
||||
|
||||
override lateinit var owner: Member
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@UseExperimental(MiraiExperimentalAPI::class)
|
||||
override val botAsMember: Member by lazy {
|
||||
Member(object : MemberInfo {
|
||||
override val nameCard: String
|
||||
@ -401,7 +401,7 @@ internal class GroupImpl(
|
||||
})
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@UseExperimental(MiraiExperimentalAPI::class)
|
||||
override lateinit var botPermission: MemberPermission
|
||||
|
||||
var _botMuteTimestamp: Int = groupInfo.botMuteRemaining
|
||||
@ -557,10 +557,10 @@ internal class GroupImpl(
|
||||
TODO("not implemented")
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@UseExperimental(MiraiExperimentalAPI::class)
|
||||
override fun Member(memberInfo: MemberInfo): Member {
|
||||
return MemberImpl(
|
||||
@OptIn(LowLevelAPI::class)
|
||||
@UseExperimental(LowLevelAPI::class)
|
||||
bot._lowLevelNewQQ(memberInfo) as QQImpl,
|
||||
this,
|
||||
this.coroutineContext,
|
||||
|
@ -36,14 +36,14 @@ import net.mamoe.mirai.utils.*
|
||||
import kotlin.collections.asSequence
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal expect class QQAndroidBot constructor(
|
||||
context: Context,
|
||||
account: BotAccount,
|
||||
configuration: BotConfiguration
|
||||
) : QQAndroidBotBase
|
||||
|
||||
@OptIn(MiraiInternalAPI::class, MiraiExperimentalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class, MiraiExperimentalAPI::class)
|
||||
internal abstract class QQAndroidBotBase constructor(
|
||||
context: Context,
|
||||
account: BotAccount,
|
||||
@ -69,7 +69,7 @@ internal abstract class QQAndroidBotBase constructor(
|
||||
override val friends: ContactList<QQ> = ContactList(LockFreeLinkedList())
|
||||
|
||||
override val selfQQ: QQ by lazy {
|
||||
@OptIn(LowLevelAPI::class)
|
||||
@UseExperimental(LowLevelAPI::class)
|
||||
_lowLevelNewQQ(object : FriendInfo {
|
||||
override val uin: Long get() = this@QQAndroidBotBase.uin
|
||||
override val nick: String get() = this@QQAndroidBotBase.nick
|
||||
@ -101,7 +101,7 @@ internal abstract class QQAndroidBotBase constructor(
|
||||
return groups.delegate.getOrNull(uin)
|
||||
}
|
||||
|
||||
@OptIn(LowLevelAPI::class)
|
||||
@UseExperimental(LowLevelAPI::class)
|
||||
override suspend fun _lowLevelQueryGroupList(): Sequence<Long> {
|
||||
return network.run {
|
||||
FriendList.GetTroopListSimplify(bot.client)
|
||||
@ -109,7 +109,7 @@ internal abstract class QQAndroidBotBase constructor(
|
||||
}.groups.asSequence().map { it.groupUin.shl(32) and it.groupCode }
|
||||
}
|
||||
|
||||
@OptIn(LowLevelAPI::class)
|
||||
@UseExperimental(LowLevelAPI::class)
|
||||
override suspend fun _lowLevelQueryGroupInfo(groupCode: Long): GroupInfo = network.run {
|
||||
TroopManagement.GetGroupInfo(
|
||||
client = bot.client,
|
||||
@ -117,7 +117,7 @@ internal abstract class QQAndroidBotBase constructor(
|
||||
).sendAndExpect<GroupInfoImpl>(retry = 2)
|
||||
}
|
||||
|
||||
@OptIn(LowLevelAPI::class)
|
||||
@UseExperimental(LowLevelAPI::class)
|
||||
override suspend fun _lowLevelQueryGroupMemberList(
|
||||
groupUin: Long,
|
||||
groupCode: Long,
|
||||
@ -187,7 +187,7 @@ internal abstract class QQAndroidBotBase constructor(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(LowLevelAPI::class)
|
||||
@UseExperimental(LowLevelAPI::class)
|
||||
override suspend fun _lowLevelRecallFriendMessage(friendId: Long, messageId: Long, time: Long) {
|
||||
network.run {
|
||||
val response: PbMessageSvc.PbMsgWithDraw.Response =
|
||||
@ -198,7 +198,7 @@ internal abstract class QQAndroidBotBase constructor(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(LowLevelAPI::class)
|
||||
@UseExperimental(LowLevelAPI::class)
|
||||
override suspend fun _lowLevelRecallGroupMessage(groupId: Long, messageId: Long) {
|
||||
network.run {
|
||||
val response: PbMessageSvc.PbMsgWithDraw.Response =
|
||||
|
@ -96,7 +96,7 @@ class Jce private constructor(private val charset: JceCharset, override val cont
|
||||
* From: com.qq.taf.jce.JceOutputStream
|
||||
*/
|
||||
@Suppress("unused", "MemberVisibilityCanBePrivate")
|
||||
@OptIn(ExperimentalIoApi::class)
|
||||
@UseExperimental(ExperimentalIoApi::class)
|
||||
private open inner class JceEncoder(
|
||||
internal val output: BytePacketBuilder
|
||||
) : TaggedEncoder<Int>() {
|
||||
@ -120,7 +120,7 @@ class Jce private constructor(private val charset: JceCharset, override val cont
|
||||
else -> throw SerializationException("Primitives are not supported at top-level")
|
||||
}
|
||||
|
||||
@OptIn(ImplicitReflectionSerializer::class)
|
||||
@UseExperimental(ImplicitReflectionSerializer::class)
|
||||
@Suppress("UNCHECKED_CAST", "NAME_SHADOWING")
|
||||
override fun <T> encodeSerializableValue(serializer: SerializationStrategy<T>, value: T) =
|
||||
when {
|
||||
@ -546,7 +546,7 @@ class Jce private constructor(private val charset: JceCharset, override val cont
|
||||
}
|
||||
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class)
|
||||
internal inner class JceInput(
|
||||
@PublishedApi
|
||||
internal val input: ByteReadPacket,
|
||||
@ -711,7 +711,7 @@ class Jce private constructor(private val charset: JceCharset, override val cont
|
||||
} while (head.type.toInt() != 11)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class)
|
||||
@PublishedApi
|
||||
internal fun skipField(type: Byte) = when (type.toInt()) {
|
||||
0 -> this.input.discardExact(1)
|
||||
@ -843,7 +843,7 @@ internal inline fun <R> Jce.JceInput.skipToTagOrNull(tag: Int, block: (JceHead)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class)
|
||||
inline class JceHead(private val value: Long) {
|
||||
constructor(tag: Int, type: Byte) : this(tag.toLong().shl(32) or type.toLong())
|
||||
|
||||
|
@ -253,7 +253,7 @@ internal class MessageSourceFromSendFriend(
|
||||
val sequenceId: Int,
|
||||
override val originalMessage: MessageChain
|
||||
) : MessageSourceFromSend() {
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@UseExperimental(ExperimentalCoroutinesApi::class)
|
||||
override val id: Long
|
||||
get() = sequenceId.toLong().shl(32) or
|
||||
messageRandom.toLong().and(0xFFFFFFFF)
|
||||
@ -277,12 +277,12 @@ internal class MessageSourceFromSendGroup(
|
||||
) : MessageSourceFromSend() {
|
||||
private lateinit var sequenceIdDeferred: Deferred<Int>
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@UseExperimental(ExperimentalCoroutinesApi::class)
|
||||
override val id: Long
|
||||
get() = sequenceIdDeferred.getCompleted().toLong().shl(32) or
|
||||
messageRandom.toLong().and(0xFFFFFFFF)
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@UseExperimental(MiraiExperimentalAPI::class)
|
||||
internal fun startWaitingSequenceId(coroutineScope: CoroutineScope) {
|
||||
sequenceIdDeferred =
|
||||
coroutineScope.subscribingGetAsync<OnlinePush.PbPushGroupMsg.SendGroupMessageReceipt, Int>(
|
||||
|
@ -219,7 +219,7 @@ private val atAllData = ImMsgBody.Elem(
|
||||
)
|
||||
)
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal fun MessageChain.toRichTextElems(forGroup: Boolean): MutableList<ImMsgBody.Elem> {
|
||||
val elements = mutableListOf<ImMsgBody.Elem>()
|
||||
|
||||
@ -332,7 +332,7 @@ internal class OnlineFriendImageImpl(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
|
||||
internal fun MsgComm.Msg.toMessageChain(): MessageChain {
|
||||
val elements = this.msgBody.richText.elems
|
||||
|
||||
@ -343,7 +343,7 @@ internal fun MsgComm.Msg.toMessageChain(): MessageChain {
|
||||
}
|
||||
|
||||
// These two functions are not identical, dont combine.
|
||||
@OptIn(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
|
||||
internal fun ImMsgBody.SourceMsg.toMessageChain(): MessageChain {
|
||||
val elements = this.elems!!
|
||||
|
||||
@ -368,9 +368,7 @@ private fun MessageChain.removeAtIfHasQuoteReply(): MessageChain =
|
||||
}.asMessageChain()
|
||||
} else this*/
|
||||
|
||||
@OptIn(
|
||||
MiraiInternalAPI::class, ExperimentalUnsignedTypes::class, MiraiDebugAPI::class, LowLevelAPI::class
|
||||
)
|
||||
@UseExperimental(MiraiInternalAPI::class, ExperimentalUnsignedTypes::class, MiraiDebugAPI::class, LowLevelAPI::class)
|
||||
internal fun List<ImMsgBody.Elem>.joinToMessageChain(message: MessageChainBuilder) {
|
||||
this.forEach {
|
||||
when {
|
||||
|
@ -44,7 +44,7 @@ import kotlin.jvm.Volatile
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler() {
|
||||
override val bot: QQAndroidBot by bot.unsafeWeakRef()
|
||||
override val supervisor: CompletableJob = SupervisorJob(bot.coroutineContext[Job])
|
||||
@ -182,7 +182,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
|
||||
internal var pendingIncomingPackets: LockFreeLinkedList<KnownPacketFactories.IncomingPacket<*>>? =
|
||||
LockFreeLinkedList()
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class, ExperimentalTime::class)
|
||||
@UseExperimental(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" }
|
||||
@ -371,7 +371,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
|
||||
*
|
||||
* @param input 一个完整的包的内容, 去掉开头的 int 包长度
|
||||
*/
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@UseExperimental(ExperimentalCoroutinesApi::class)
|
||||
fun parsePacketAsync(input: Input): Job {
|
||||
return this.launch(start = CoroutineStart.ATOMIC) {
|
||||
input.use { parsePacket(it) }
|
||||
|
@ -40,7 +40,7 @@ import net.mamoe.mirai.utils.io.*
|
||||
DOMAINS
|
||||
Pskey: "openmobile.qq.com"
|
||||
*/
|
||||
@OptIn(MiraiExperimentalAPI::class, MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiExperimentalAPI::class, MiraiInternalAPI::class)
|
||||
@PublishedApi
|
||||
internal open class QQAndroidClient(
|
||||
context: Context,
|
||||
@ -158,7 +158,7 @@ internal open class QQAndroidClient(
|
||||
*/
|
||||
val uin: Long get() = _uin
|
||||
|
||||
@OptIn(RawAccountIdUse::class)
|
||||
@UseExperimental(RawAccountIdUse::class)
|
||||
@Suppress("PropertyName")
|
||||
internal var _uin: Long = bot.account.id
|
||||
|
||||
|
@ -35,7 +35,7 @@ import net.mamoe.mirai.utils.io.ByteArrayPool
|
||||
import net.mamoe.mirai.utils.io.PlatformSocket
|
||||
import net.mamoe.mirai.utils.io.withUse
|
||||
|
||||
@OptIn(MiraiInternalAPI::class, InternalSerializationApi::class)
|
||||
@UseExperimental(MiraiInternalAPI::class, InternalSerializationApi::class)
|
||||
@Suppress("SpellCheckingInspection")
|
||||
internal suspend fun HttpClient.postImage(
|
||||
htcmd: String,
|
||||
@ -93,9 +93,9 @@ internal suspend fun HttpClient.postImage(
|
||||
}
|
||||
} == HttpStatusCode.OK
|
||||
|
||||
@OptIn(MiraiInternalAPI::class, InternalSerializationApi::class)
|
||||
@UseExperimental(MiraiInternalAPI::class, InternalSerializationApi::class)
|
||||
internal object HighwayHelper {
|
||||
@OptIn(InternalCoroutinesApi::class)
|
||||
@UseExperimental(InternalCoroutinesApi::class)
|
||||
suspend fun uploadImage(
|
||||
client: QQAndroidClient,
|
||||
serverIp: String,
|
||||
|
@ -22,7 +22,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.io.*
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal fun createImageDataPacketSequence( // RequestDataTrans
|
||||
client: QQAndroidClient,
|
||||
command: String,
|
||||
|
@ -16,7 +16,7 @@ import net.mamoe.mirai.utils.cryptor.ECDHKeyPair
|
||||
import net.mamoe.mirai.utils.io.encryptAndWrite
|
||||
import net.mamoe.mirai.utils.io.writeShortLVByteArray
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class)
|
||||
internal interface EncryptMethod {
|
||||
val id: Int
|
||||
|
||||
|
@ -31,7 +31,7 @@ internal class OutgoingPacket constructor(
|
||||
internal val KEY_16_ZEROS = ByteArray(16)
|
||||
internal val EMPTY_BYTE_ARRAY = ByteArray(0)
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal inline fun OutgoingPacketFactory<*>.buildOutgoingUniPacket(
|
||||
client: QQAndroidClient,
|
||||
bodyType: Byte = 1, // 1: PB?
|
||||
@ -64,7 +64,7 @@ internal inline fun OutgoingPacketFactory<*>.buildOutgoingUniPacket(
|
||||
}
|
||||
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal inline fun IncomingPacketFactory<*>.buildResponseUniPacket(
|
||||
client: QQAndroidClient,
|
||||
bodyType: Byte = 1, // 1: PB?
|
||||
@ -95,7 +95,7 @@ internal inline fun IncomingPacketFactory<*>.buildResponseUniPacket(
|
||||
})
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal inline fun BytePacketBuilder.writeUniPacket(
|
||||
commandName: String,
|
||||
unknownData: ByteArray,
|
||||
@ -128,7 +128,7 @@ 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)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal inline fun OutgoingPacketFactory<*>.buildLoginOutgoingPacket(
|
||||
client: QQAndroidClient,
|
||||
bodyType: Byte,
|
||||
@ -166,7 +166,7 @@ internal inline fun OutgoingPacketFactory<*>.buildLoginOutgoingPacket(
|
||||
|
||||
private inline val BRP_STUB get() = ByteReadPacket.Empty
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal inline fun BytePacketBuilder.writeSsoPacket(
|
||||
client: QQAndroidClient,
|
||||
subAppId: Long,
|
||||
@ -232,7 +232,7 @@ internal inline fun BytePacketBuilder.writeSsoPacket(
|
||||
writeIntLVPacket(lengthOffset = { it + 4 }, builder = body)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
|
||||
internal fun BytePacketBuilder.writeOicqRequestPacket(
|
||||
client: QQAndroidClient,
|
||||
encryptMethod: EncryptMethod,
|
||||
|
@ -47,7 +47,7 @@ internal sealed class PacketFactory<TPacket : Packet?> {
|
||||
*
|
||||
* @param TPacket 服务器回复包解析结果
|
||||
*/
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class)
|
||||
internal abstract class OutgoingPacketFactory<TPacket : Packet?>(
|
||||
/**
|
||||
* 命令名. 如 `wtlogin.login`, `ConfigPushSvc.PushDomain`
|
||||
@ -116,7 +116,7 @@ internal val PacketLogger: MiraiLoggerWithSwitch = DefaultLogger("Packet").withS
|
||||
/**
|
||||
* 已知的数据包工厂列表.
|
||||
*/
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class)
|
||||
internal object KnownPacketFactories {
|
||||
object OutgoingFactories : List<OutgoingPacketFactory<*>> by mutableListOf(
|
||||
WtLogin.Login,
|
||||
@ -163,7 +163,7 @@ internal object KnownPacketFactories {
|
||||
* full packet without length
|
||||
*/
|
||||
// do not inline. Exceptions thrown will not be reported correctly
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun <T : Packet?> parseIncomingPacket(bot: QQAndroidBot, rawInput: Input, consumer: PacketConsumer<T>) = with(rawInput) {
|
||||
// login
|
||||
@ -225,7 +225,7 @@ internal object KnownPacketFactories {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal suspend fun <T : Packet?> handleIncomingPacket(it: IncomingPacket<T>, bot: QQAndroidBot, flag2: Int, consumer: PacketConsumer<T>) {
|
||||
if (it.packetFactory == null) {
|
||||
bot.network.logger.debug("Received commandName: ${it.commandName}")
|
||||
@ -274,7 +274,7 @@ internal object KnownPacketFactories {
|
||||
/**
|
||||
* 解析 SSO 层包装
|
||||
*/
|
||||
@OptIn(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
|
||||
private fun parseSsoFrame(bot: QQAndroidBot, input: ByteReadPacket): IncomingPacket<*> {
|
||||
val commandName: String
|
||||
val ssoSequenceId: Int
|
||||
@ -335,7 +335,7 @@ internal object KnownPacketFactories {
|
||||
return IncomingPacket(packetFactory, ssoSequenceId, packet, commandName)
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
private suspend fun <T : Packet?> ByteReadPacket.parseOicqResponse(
|
||||
bot: QQAndroidBot,
|
||||
packetFactory: OutgoingPacketFactory<T>,
|
||||
|
@ -73,7 +73,7 @@ internal class MessageSvc {
|
||||
/**
|
||||
* 获取好友消息和消息记录
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal object PbGetMsg : OutgoingPacketFactory<PbGetMsg.Response>("MessageSvc.PbGetMsg") {
|
||||
operator fun invoke(
|
||||
client: QQAndroidClient,
|
||||
@ -104,7 +104,7 @@ internal class MessageSvc {
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
open class GetMsgSuccess(delegate: List<Packet>) : Response(MsgSvc.SyncFlag.STOP, delegate) {
|
||||
override fun toString(): String = "MessageSvc.PbGetMsg.GetMsgSuccess(messages=<Iterable>))"
|
||||
}
|
||||
@ -121,7 +121,7 @@ internal class MessageSvc {
|
||||
|
||||
object EmptyResponse : GetMsgSuccess(emptyList())
|
||||
|
||||
@OptIn(MiraiInternalAPI::class, MiraiExperimentalAPI::class, FlowPreview::class)
|
||||
@UseExperimental(MiraiInternalAPI::class, MiraiExperimentalAPI::class, 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())
|
||||
@ -276,7 +276,6 @@ internal class MessageSvc {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("FunctionName")
|
||||
inline fun ToFriend(
|
||||
client: QQAndroidClient,
|
||||
toUin: Long,
|
||||
@ -327,7 +326,6 @@ internal class MessageSvc {
|
||||
}
|
||||
|
||||
|
||||
@Suppress("FunctionName")
|
||||
inline fun ToGroup(
|
||||
client: QQAndroidClient,
|
||||
groupCode: Long,
|
||||
|
@ -55,7 +55,7 @@ internal class OnlinePush {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
@UseExperimental(ExperimentalStdlibApi::class)
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot, sequenceId: Int): Packet? {
|
||||
// 00 00 02 E4 0A D5 05 0A 4F 08 A2 FF 8C F0 03 10 DD F1 92 B7 07 18 52 20 00 28 BC 3D 30 8C 82 AB F1 05 38 D2 80 E0 8C 80 80 80 80 02 4A 21 08 E7 C1 AD B8 02 10 01 18 BA 05 22 09 48 69 6D 31 38 38 6D 6F 65 30 06 38 02 42 05 4D 69 72 61 69 50 01 58 01 60 00 88 01 08 12 06 08 01 10 00 18 00 1A F9 04 0A F6 04 0A 26 08 00 10 87 82 AB F1 05 18 B7 B4 BF 30 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 E6 03 42 E3 03 12 2A 7B 34 45 31 38 35 38 32 32 2D 30 45 37 42 2D 46 38 30 46 2D 43 35 42 31 2D 33 34 34 38 38 33 37 34 44 33 39 43 7D 2E 6A 70 67 22 00 2A 04 03 00 00 00 32 60 15 36 20 39 36 6B 45 31 41 38 35 32 32 39 64 63 36 39 38 34 37 39 37 37 62 20 20 20 20 20 20 35 30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7B 34 45 31 38 35 38 32 32 2D 30 45 37 42 2D 46 38 30 46 2D 43 35 42 31 2D 33 34 34 38 38 33 37 34 44 33 39 43 7D 2E 6A 70 67 31 32 31 32 41 38 C6 BB 8A A9 08 40 FB AE 9E C2 09 48 50 50 41 5A 00 60 01 6A 10 4E 18 58 22 0E 7B F8 0F C5 B1 34 48 83 74 D3 9C 72 59 2F 67 63 68 61 74 70 69 63 5F 6E 65 77 2F 31 30 34 30 34 30 30 32 39 30 2F 36 35 35 30 35 37 31 32 37 2D 32 32 33 33 36 33 38 33 34 32 2D 34 45 31 38 35 38 32 32 30 45 37 42 46 38 30 46 43 35 42 31 33 34 34 38 38 33 37 34 44 33 39 43 2F 31 39 38 3F 74 65 72 6D 3D 32 82 01 57 2F 67 63 68 61 74 70 69 63 5F 6E 65 77 2F 31 30 34 30 34 30 30 32 39 30 2F 36 35 35 30 35 37 31 32 37 2D 32 32 33 33 36 33 38 33 34 32 2D 34 45 31 38 35 38 32 32 30 45 37 42 46 38 30 46 43 35 42 31 33 34 34 38 38 33 37 34 44 33 39 43 2F 30 3F 74 65 72 6D 3D 32 B0 01 4D B8 01 2E C8 01 FF 05 D8 01 4D E0 01 2E FA 01 59 2F 67 63 68 61 74 70 69 63 5F 6E 65 77 2F 31 30 34 30 34 30 30 32 39 30 2F 36 35 35 30 35 37 31 32 37 2D 32 32 33 33 36 33 38 33 34 32 2D 34 45 31 38 35 38 32 32 30 45 37 42 46 38 30 46 43 35 42 31 33 34 34 38 38 33 37 34 44 33 39 43 2F 34 30 30 3F 74 65 72 6D 3D 32 80 02 4D 88 02 2E 12 45 AA 02 42 50 03 60 00 68 00 9A 01 39 08 09 20 BF 50 80 01 01 C8 01 00 F0 01 00 F8 01 00 90 02 00 98 03 00 A0 03 20 B0 03 00 C0 03 00 D0 03 00 E8 03 00 8A 04 04 08 02 08 01 90 04 80 80 80 10 B8 04 00 C0 04 00 12 06 4A 04 08 00 40 01 12 14 82 01 11 0A 09 48 69 6D 31 38 38 6D 6F 65 18 06 20 08 28 03 10 8A CA 9D A1 07 1A 00
|
||||
if (!bot.firstLoginSucceed) return null
|
||||
@ -94,7 +94,7 @@ internal class OnlinePush {
|
||||
|
||||
internal object PbPushTransMsg : IncomingPacketFactory<Packet>("OnlinePush.PbPushTransMsg", "OnlinePush.RespPush") {
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
@ExperimentalUnsignedTypes
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot, sequenceId: Int): Packet {
|
||||
val content = this.readProtoBuf(OnlinePushTrans.PbMsgInfo.serializer())
|
||||
@ -187,7 +187,7 @@ internal class OnlinePush {
|
||||
//0C 01 B1 89 BE 09 5E 3D 72 A6 00 01 73 68 FC 06 00 00 00 3C
|
||||
internal object ReqPush : IncomingPacketFactory<Packet>("OnlinePush.ReqPush", "OnlinePush.RespPush") {
|
||||
@ExperimentalUnsignedTypes
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
@UseExperimental(ExperimentalStdlibApi::class)
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot, sequenceId: Int): Packet {
|
||||
val reqPushMsg = decodeUniPacket(OnlinePushPack.SvcReqPushMsg.serializer(), "req")
|
||||
|
||||
|
@ -29,7 +29,7 @@ internal class WtLogin {
|
||||
* OicqRequest
|
||||
*/
|
||||
@Suppress("FunctionName")
|
||||
@OptIn(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
|
||||
internal object Login : OutgoingPacketFactory<Login.LoginPacketResponse>("wtlogin.login") {
|
||||
private const val subAppId = 537062845L
|
||||
|
||||
@ -127,7 +127,7 @@ internal class WtLogin {
|
||||
private const val appId = 16L
|
||||
private const val subAppId = 537062845L
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
operator fun invoke(
|
||||
client: QQAndroidClient
|
||||
): OutgoingPacket = buildLoginOutgoingPacket(client, bodyType = 2) { sequenceId ->
|
||||
@ -309,7 +309,7 @@ internal class WtLogin {
|
||||
}
|
||||
|
||||
@InternalAPI
|
||||
@OptIn(MiraiDebugAPI::class)
|
||||
@UseExperimental(MiraiDebugAPI::class)
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): LoginPacketResponse {
|
||||
|
||||
discardExact(2) // subCommand
|
||||
@ -368,7 +368,7 @@ internal class WtLogin {
|
||||
}
|
||||
|
||||
@InternalAPI
|
||||
@OptIn(MiraiDebugAPI::class)
|
||||
@UseExperimental(MiraiDebugAPI::class)
|
||||
private fun onSolveLoginCaptcha(tlvMap: TlvMap, bot: QQAndroidBot): LoginPacketResponse.Captcha {
|
||||
/*
|
||||
java.lang.IllegalStateException: UNKNOWN CAPTCHA QUESTION:
|
||||
@ -404,7 +404,7 @@ internal class WtLogin {
|
||||
error("UNKNOWN CAPTCHA, tlvMap=" + tlvMap._miraiContentToString())
|
||||
}
|
||||
|
||||
@OptIn(MiraiDebugAPI::class)
|
||||
@UseExperimental(MiraiDebugAPI::class)
|
||||
private fun onLoginSuccess(tlvMap: TlvMap, bot: QQAndroidBot): LoginPacketResponse.Success {
|
||||
val client = bot.client
|
||||
//println("TLV KEYS: " + tlvMap.keys.joinToString { it.contentToString() })
|
||||
|
@ -21,7 +21,7 @@ import kotlin.jvm.JvmName
|
||||
/**
|
||||
* Inline the block
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
@UseExperimental(ExperimentalContracts::class)
|
||||
@PublishedApi
|
||||
internal inline fun <R> inline(block: () -> R): R {
|
||||
contract {
|
||||
|
@ -35,7 +35,7 @@ inline fun ByteArray.debugPrintThis(name: String): ByteArray {
|
||||
return this
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class, MiraiInternalAPI::class)
|
||||
@UseExperimental(ExperimentalContracts::class, MiraiInternalAPI::class)
|
||||
inline fun <R> Input.debugIfFail(name: String = "", onFail: (ByteArray) -> ByteReadPacket = { it.toReadPacket() }, block: ByteReadPacket.() -> R): R {
|
||||
|
||||
contract {
|
||||
|
@ -23,7 +23,7 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
* QQ for Android
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
actual object QQAndroid : BotFactory {
|
||||
|
||||
/**
|
||||
|
@ -15,11 +15,11 @@ import net.mamoe.mirai.utils.Context
|
||||
import net.mamoe.mirai.utils.ContextImpl
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
@Suppress("FunctionName")
|
||||
internal fun QQAndroidBot(account: BotAccount, configuration: BotConfiguration): QQAndroidBot = QQAndroidBot(ContextImpl(), account, configuration)
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal actual class QQAndroidBot actual constructor(
|
||||
context: Context,
|
||||
account: BotAccount,
|
||||
|
@ -161,7 +161,7 @@ data class PBFieldInfo(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class)
|
||||
fun String.generateProtoBufDataClass(): GeneratedClass {
|
||||
if (this.indexOf("extends") == -1) {
|
||||
val javaClassname = substringBetween("class", "{")
|
||||
@ -367,7 +367,7 @@ fun String.getNumericalValue(): Int? {
|
||||
return this.filter { it in '0'..'9' }.toDoubleOrNull()?.toInt()
|
||||
}
|
||||
|
||||
@OptIn(MiraiDebugAPI::class)
|
||||
@UseExperimental(MiraiDebugAPI::class)
|
||||
fun ProtoType.mapToKotlinType(): String {
|
||||
return when (this) {
|
||||
ProtoType.VAR_INT -> "Int"
|
||||
|
@ -24,9 +24,7 @@ import net.mamoe.mirai.utils.*
|
||||
* @see kotlinx.coroutines.isActive 判断 [Bot] 是否正常运行中. (在线, 且没有被 [close])
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@OptIn(
|
||||
MiraiInternalAPI::class, LowLevelAPI::class, MiraiExperimentalAPI::class, JavaHappyAPI::class
|
||||
)
|
||||
@UseExperimental(MiraiInternalAPI::class, LowLevelAPI::class, MiraiExperimentalAPI::class, JavaHappyAPI::class)
|
||||
actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIAccessor, BotJavaHappyAPI() {
|
||||
actual companion object {
|
||||
/**
|
||||
@ -236,6 +234,6 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
|
||||
*/
|
||||
actual abstract fun close(cause: Throwable?)
|
||||
|
||||
@OptIn(LowLevelAPI::class, MiraiExperimentalAPI::class)
|
||||
@UseExperimental(LowLevelAPI::class, MiraiExperimentalAPI::class)
|
||||
actual final override fun toString(): String = "Bot(${uin})"
|
||||
}
|
@ -132,7 +132,7 @@ actual abstract class BotJavaHappyAPI actual constructor() {
|
||||
message: String? = null,
|
||||
remark: String? = null
|
||||
): AddFriendResult {
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@UseExperimental(MiraiExperimentalAPI::class)
|
||||
return runBlocking { addFriend(id, message, remark) }
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ actual abstract class BotJavaHappyAPI actual constructor() {
|
||||
}
|
||||
|
||||
// !! 不要 crossinline, 会编译失败
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@UseExperimental(ExperimentalCoroutinesApi::class)
|
||||
internal fun <R, C : CoroutineScope> C.future(block: suspend C.() -> R): Future<R> {
|
||||
val future = object : Future<R> {
|
||||
val value: CompletableDeferred<R> = CompletableDeferred()
|
||||
@ -215,7 +215,7 @@ internal fun <R, C : CoroutineScope> C.future(block: suspend C.() -> R): Future<
|
||||
}
|
||||
|
||||
launch {
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@UseExperimental(ExperimentalCoroutinesApi::class)
|
||||
future.value.completeWith(kotlin.runCatching { block() })
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ import net.mamoe.mirai.utils.WeakRefProperty
|
||||
* @author Him188moe
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class, JavaHappyAPI::class)
|
||||
actual abstract class Contact : CoroutineScope, ContactJavaHappyAPI() {
|
||||
/**
|
||||
* 这个联系人所属 [Bot].
|
||||
|
@ -21,7 +21,7 @@ import net.mamoe.mirai.utils.WeakRefProperty
|
||||
* 群成员.
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class, JavaHappyAPI::class)
|
||||
actual abstract class Member : MemberJavaHappyAPI() {
|
||||
/**
|
||||
* 所在的群.
|
||||
|
@ -16,7 +16,7 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
/**
|
||||
* 平台相关扩展
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
actual abstract class MessagePacket<TSender : QQ, TSubject : Contact> actual constructor() : MessagePacketBase<TSender, TSubject>() {
|
||||
// suspend inline fun uploadImage(image: Bitmap): Image = subject.uploadImage(image)
|
||||
//suspend inline fun uploadImage(image: URL): Image = subject.uploadImage(image)
|
||||
|
@ -28,7 +28,7 @@ import net.mamoe.mirai.utils.unsafeWeakRef
|
||||
* @see MessageReceipt.sourceTime 源时间
|
||||
*/
|
||||
@Suppress("FunctionName")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
actual open class MessageReceipt<C : Contact> actual constructor(
|
||||
actual val source: MessageSource,
|
||||
target: C,
|
||||
@ -94,7 +94,7 @@ actual open class MessageReceipt<C : Contact> actual constructor(
|
||||
*/
|
||||
actual open suspend fun quote(): QuoteReplyToSend {
|
||||
this.source.ensureSequenceIdAvailable()
|
||||
@OptIn(LowLevelAPI::class)
|
||||
@UseExperimental(LowLevelAPI::class)
|
||||
return _unsafeQuote()
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ import java.io.File
|
||||
/**
|
||||
* 加载一个设备信息. 若文件不存在或为空则随机并创建一个设备信息保存.
|
||||
*/
|
||||
@OptIn(UnstableDefault::class)
|
||||
@UseExperimental(UnstableDefault::class)
|
||||
fun File.loadAsDeviceInfo(context: Context): DeviceInfo {
|
||||
if (!this.exists() || this.length() == 0L) {
|
||||
return SystemDeviceInfo(context).also {
|
||||
|
@ -80,7 +80,7 @@ actual class PlatformSocket : Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalIoApi::class)
|
||||
@UseExperimental(ExperimentalIoApi::class)
|
||||
actual suspend fun connect(serverHost: String, serverPort: Int) {
|
||||
withContext(Dispatchers.IO) {
|
||||
socket = Socket(serverHost, serverPort)
|
||||
|
@ -26,7 +26,7 @@ import java.util.zip.Inflater
|
||||
/**
|
||||
* Ktor HttpClient. 不同平台使用不同引擎.
|
||||
*/
|
||||
@OptIn(KtorExperimentalAPI::class)
|
||||
@UseExperimental(KtorExperimentalAPI::class)
|
||||
actual val Http: HttpClient
|
||||
get() = HttpClient(CIO)
|
||||
|
||||
@ -76,7 +76,7 @@ private inline fun InputStream.readInSequence(block: (Int) -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
actual fun ByteArray.unzip(offset: Int, length: Int): ByteArray {
|
||||
this.checkOffsetAndLength(offset, length)
|
||||
if (length == 0) return ByteArray(0)
|
||||
|
@ -41,7 +41,7 @@ import kotlin.jvm.JvmSynthetic
|
||||
* @see kotlinx.coroutines.isActive 判断 [Bot] 是否正常运行中. (在线, 且没有被 [close])
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@OptIn(MiraiInternalAPI::class, LowLevelAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class, LowLevelAPI::class)
|
||||
expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
|
||||
companion object {
|
||||
/**
|
||||
@ -241,7 +241,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
|
||||
*/
|
||||
abstract fun close(cause: Throwable? = null)
|
||||
|
||||
@OptIn(LowLevelAPI::class, MiraiExperimentalAPI::class)
|
||||
@UseExperimental(LowLevelAPI::class, MiraiExperimentalAPI::class)
|
||||
final override fun toString(): String
|
||||
}
|
||||
|
||||
|
@ -52,5 +52,5 @@ data class BotAccount(
|
||||
@MiraiInternalAPI
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR)
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
||||
@Experimental(level = Experimental.Level.WARNING)
|
||||
annotation class RawAccountIdUse
|
@ -27,7 +27,7 @@ import kotlin.coroutines.CoroutineContext
|
||||
/*
|
||||
* 泛型 N 不需要向外(接口)暴露.
|
||||
*/
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@UseExperimental(MiraiExperimentalAPI::class)
|
||||
@MiraiInternalAPI
|
||||
abstract class BotImpl<N : BotNetworkHandler> constructor(
|
||||
context: Context,
|
||||
@ -43,7 +43,7 @@ abstract class BotImpl<N : BotNetworkHandler> constructor(
|
||||
@Suppress("CanBePrimaryConstructorProperty") // for logger
|
||||
final override val account: BotAccount = account
|
||||
|
||||
@OptIn(RawAccountIdUse::class)
|
||||
@UseExperimental(RawAccountIdUse::class)
|
||||
override val uin: Long
|
||||
get() = account.id
|
||||
final override val logger: MiraiLogger by lazy { configuration.botLoggerSupplier(this) }
|
||||
@ -172,7 +172,7 @@ abstract class BotImpl<N : BotNetworkHandler> constructor(
|
||||
|
||||
// endregion
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
override fun close(cause: Throwable?) {
|
||||
if (!this.botJob.isActive) {
|
||||
// already cancelled
|
||||
|
@ -36,7 +36,7 @@ import kotlin.jvm.JvmSynthetic
|
||||
*
|
||||
* @author Him188moe
|
||||
*/ // 不要删除多平台结构 !!! kotlin bug
|
||||
@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class, JavaHappyAPI::class)
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
expect abstract class Contact() : CoroutineScope, ContactJavaHappyAPI {
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ import net.mamoe.mirai.utils.*
|
||||
*
|
||||
* @see ContactList.asSequence
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
@Suppress("unused")
|
||||
class ContactList<C : Contact>(@MiraiInternalAPI val delegate: LockFreeLinkedList<C>) {
|
||||
/**
|
||||
@ -79,7 +79,7 @@ fun <E : Contact> ContactList<E>.toList(): List<E> = toMutableList()
|
||||
/**
|
||||
* Collect all the elements into a [MutableList].
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
fun <E : Contact> ContactList<E>.toMutableList(): MutableList<E> = this.delegate.toMutableList()
|
||||
|
||||
/**
|
||||
@ -90,7 +90,7 @@ fun <E : Contact> ContactList<E>.toSet(): Set<E> = toMutableSet()
|
||||
/**
|
||||
* Collect all the elements into a [MutableSet].
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
fun <E : Contact> ContactList<E>.toMutableSet(): MutableSet<E> = this.delegate.toMutableSet()
|
||||
|
||||
/**
|
||||
@ -98,7 +98,7 @@ fun <E : Contact> ContactList<E>.toMutableSet(): MutableSet<E> = this.delegate.t
|
||||
*
|
||||
* Note that the sequence is dynamic, that is, elements are yielded atomically only when it is required
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
fun <E : Contact> ContactList<E>.asSequence(): Sequence<E> {
|
||||
return this.delegate.asSequence()
|
||||
}
|
@ -25,7 +25,7 @@ import kotlin.time.ExperimentalTime
|
||||
* 群成员.
|
||||
*/ // 不要删除多平台结构, kotlin bug
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class, JavaHappyAPI::class)
|
||||
expect abstract class Member() : MemberJavaHappyAPI {
|
||||
/**
|
||||
* 所在的群.
|
||||
|
@ -82,7 +82,7 @@ expect class PermissionDeniedException : IllegalStateException {
|
||||
*
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@UseExperimental(MiraiExperimentalAPI::class)
|
||||
inline fun Group.checkBotPermission(
|
||||
required: MemberPermission,
|
||||
lazyMessage: () -> String = {
|
||||
@ -99,7 +99,7 @@ inline fun Group.checkBotPermission(
|
||||
*
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@UseExperimental(MiraiExperimentalAPI::class)
|
||||
inline fun Group.checkBotPermissionOperator(
|
||||
lazyMessage: () -> String = {
|
||||
"Permission denied: required ${MemberPermission.ADMINISTRATOR} or ${MemberPermission.OWNER}, got actual $botPermission for $bot in group $id"
|
||||
|
@ -66,7 +66,7 @@ abstract class AbstractCancellableEvent : Event, CancellableEvent {
|
||||
/**
|
||||
* 广播一个事件的唯一途径.
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
suspend fun <E : Event> E.broadcast(): E = apply {
|
||||
if (this is BroadcastControllable && !this.shouldBroadcast) {
|
||||
return@apply
|
||||
|
@ -143,7 +143,7 @@ sealed class MessageRecallEvent : BotEvent {
|
||||
) : MessageRecallEvent(), GroupOperableEvent, Packet
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@UseExperimental(MiraiExperimentalAPI::class)
|
||||
val MessageRecallEvent.GroupRecall.author: Member
|
||||
get() = if (authorId == bot.uin) group.botAsMember else group[authorId]
|
||||
|
||||
|
@ -73,7 +73,7 @@ val GroupOperableEvent.isByBot: Boolean get() = operator == null
|
||||
* 当操作人为 [Member] 时获取这个 [Member],
|
||||
* 当操作人为 [Bot] 时获取 [Group.botAsMember]
|
||||
*/
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@UseExperimental(MiraiExperimentalAPI::class)
|
||||
val GroupOperableEvent.operatorOrBot: Member
|
||||
get() = this.operator ?: this.group.botAsMember
|
||||
|
||||
|
@ -36,7 +36,7 @@ internal fun <E : Event> CoroutineScope.Handler(
|
||||
coroutineContext: CoroutineContext,
|
||||
handler: suspend (E) -> ListeningStatus
|
||||
): Handler<E> {
|
||||
@OptIn(ExperimentalCoroutinesApi::class) // don't remove
|
||||
@UseExperimental(ExperimentalCoroutinesApi::class) // don't remove
|
||||
val context = this.newCoroutineContext(coroutineContext)
|
||||
return Handler(context[Job], context, handler)
|
||||
}
|
||||
@ -50,7 +50,7 @@ internal class Handler<in E : Event>
|
||||
@PublishedApi internal constructor(parentJob: Job?, private val subscriberContext: CoroutineContext, @JvmField val handler: suspend (E) -> ListeningStatus) :
|
||||
Listener<E>, CompletableJob by Job(parentJob) {
|
||||
|
||||
@OptIn(MiraiDebugAPI::class)
|
||||
@UseExperimental(MiraiDebugAPI::class)
|
||||
override suspend fun onEvent(event: E): ListeningStatus {
|
||||
if (isCompleted || isCancelled) return ListeningStatus.STOPPED
|
||||
if (!isActive) return ListeningStatus.LISTENING
|
||||
@ -155,7 +155,7 @@ internal suspend inline fun Event.broadcastInternal() = coroutineScope {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
private fun <E : Event> CoroutineScope.callAndRemoveIfRequired(event: E, listeners: EventListeners<E>) {
|
||||
// atomic foreach
|
||||
listeners.forEachNode { node ->
|
||||
|
@ -33,7 +33,7 @@ import kotlin.coroutines.EmptyCoroutineContext
|
||||
*
|
||||
* @see CoroutineScope.incoming
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
@UseExperimental(ExperimentalContracts::class)
|
||||
inline fun <R> CoroutineScope.subscribeMessages(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
crossinline listeners: MessageSubscribersBuilder<MessagePacket<*, *>>.() -> R
|
||||
@ -58,7 +58,7 @@ inline fun <R> CoroutineScope.subscribeMessages(
|
||||
*
|
||||
* @see CoroutineScope.incoming
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
@UseExperimental(ExperimentalContracts::class)
|
||||
inline fun <R> CoroutineScope.subscribeGroupMessages(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
crossinline listeners: MessageSubscribersBuilder<GroupMessage>.() -> R
|
||||
@ -78,7 +78,7 @@ inline fun <R> CoroutineScope.subscribeGroupMessages(
|
||||
*
|
||||
* @see CoroutineScope.incoming
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
@UseExperimental(ExperimentalContracts::class)
|
||||
inline fun <R> CoroutineScope.subscribeFriendMessages(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
crossinline listeners: MessageSubscribersBuilder<FriendMessage>.() -> R
|
||||
@ -98,7 +98,7 @@ inline fun <R> CoroutineScope.subscribeFriendMessages(
|
||||
*
|
||||
* @see CoroutineScope.incoming
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
@UseExperimental(ExperimentalContracts::class)
|
||||
inline fun <R> Bot.subscribeMessages(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
crossinline listeners: MessageSubscribersBuilder<MessagePacket<*, *>>.() -> R
|
||||
@ -120,7 +120,7 @@ inline fun <R> Bot.subscribeMessages(
|
||||
*
|
||||
* @see CoroutineScope.incoming
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
@UseExperimental(ExperimentalContracts::class)
|
||||
inline fun <R> Bot.subscribeGroupMessages(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
crossinline listeners: MessageSubscribersBuilder<GroupMessage>.() -> R
|
||||
@ -140,7 +140,7 @@ inline fun <R> Bot.subscribeGroupMessages(
|
||||
*
|
||||
* @see CoroutineScope.incoming
|
||||
*/
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
@UseExperimental(ExperimentalContracts::class)
|
||||
inline fun <R> Bot.subscribeFriendMessages(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
crossinline listeners: MessageSubscribersBuilder<FriendMessage>.() -> R
|
||||
|
@ -118,7 +118,7 @@ interface Listener<in E : Event> : CompletableJob {
|
||||
* @see subscribeGroupMessages 监听群消息 DSL
|
||||
* @see subscribeFriendMessages 监听好友消息 DSL
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
inline fun <reified E : Event> CoroutineScope.subscribe(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
noinline handler: suspend E.(E) -> ListeningStatus
|
||||
@ -136,7 +136,7 @@ inline fun <reified E : Event> CoroutineScope.subscribe(
|
||||
*
|
||||
* @see subscribe 获取更多说明
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class, ExperimentalContracts::class)
|
||||
@UseExperimental(MiraiInternalAPI::class, ExperimentalContracts::class)
|
||||
inline fun <reified E : Event> CoroutineScope.subscribeAlways(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
noinline listener: suspend E.(E) -> Unit
|
||||
@ -158,7 +158,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeAlways(
|
||||
*
|
||||
* @see subscribe 获取更多说明
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
inline fun <reified E : Event> CoroutineScope.subscribeOnce(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
noinline listener: suspend E.(E) -> Unit
|
||||
@ -184,7 +184,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeOnce(
|
||||
* @see subscribe 获取更多说明
|
||||
*/
|
||||
@JvmName("subscribeAlwaysForBot")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
inline fun <reified E : BotEvent> Bot.subscribe(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
noinline handler: suspend E.(E) -> ListeningStatus
|
||||
@ -204,7 +204,7 @@ inline fun <reified E : BotEvent> Bot.subscribe(
|
||||
* @see subscribe 获取更多说明
|
||||
*/
|
||||
@JvmName("subscribeAlwaysForBot1")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
inline fun <reified E : BotEvent> Bot.subscribeAlways(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
noinline listener: suspend E.(E) -> Unit
|
||||
@ -224,7 +224,7 @@ inline fun <reified E : BotEvent> Bot.subscribeAlways(
|
||||
* @see subscribe 获取更多说明
|
||||
*/
|
||||
@JvmName("subscribeOnceForBot2")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
inline fun <reified E : BotEvent> Bot.subscribeOnce(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
noinline listener: suspend E.(E) -> Unit
|
||||
|
@ -15,7 +15,7 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
* 表明这个 API 是为了让 Java 使用者调用更方便.
|
||||
*/
|
||||
@MiraiInternalAPI
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
|
||||
@Experimental(level = Experimental.Level.ERROR)
|
||||
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.TYPE, AnnotationTarget.CLASS)
|
||||
annotation class JavaHappyAPI
|
||||
|
||||
|
@ -25,7 +25,7 @@ import net.mamoe.mirai.utils.WeakRef
|
||||
* 使用低级的 API 无法带来任何安全和便捷保障.
|
||||
* 仅在某些使用结构化 API 可能影响性能的情况下使用这些低级 API.
|
||||
*/
|
||||
@RequiresOptIn
|
||||
@Experimental
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
|
||||
annotation class LowLevelAPI
|
||||
|
@ -33,7 +33,7 @@ import kotlin.jvm.JvmName
|
||||
* 一条从服务器接收到的消息事件.
|
||||
* 请查看各平台的 `actual` 实现的说明.
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
expect abstract class MessagePacket<TSender : QQ, TSubject : Contact>() : MessagePacketBase<TSender, TSubject>
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,6 @@ import kotlin.jvm.JvmStatic
|
||||
* @see AtAll 全体成员
|
||||
*/
|
||||
class At
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
private constructor(val target: Long, val display: String) : Message, MessageContent {
|
||||
|
||||
/**
|
||||
|
@ -76,7 +76,7 @@ interface OnlineImage : Image {
|
||||
* 查询原图下载链接.
|
||||
*/
|
||||
suspend fun Image.queryUrl(): String {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
return when (this) {
|
||||
is OnlineImage -> this.originUrl
|
||||
else -> BotImpl.instances.peekFirst().get()?.queryImageUrl(this)
|
||||
@ -102,7 +102,7 @@ interface OfflineImage : Image
|
||||
* 原图下载链接. 包含域名
|
||||
*/
|
||||
suspend fun OfflineImage.queryOriginUrl(): String {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
return BotImpl.instances.peekFirst().get()?.queryImageUrl(this) ?: error("No Bot available to query image url")
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ suspend fun OfflineImage.queryOriginUrl(): String {
|
||||
* 群图片
|
||||
*/
|
||||
// CustomFace
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
sealed class GroupImage : AbstractImage() {
|
||||
abstract val filepath: String
|
||||
abstract val fileId: Int
|
||||
@ -184,7 +184,7 @@ abstract class OnlineGroupImage : GroupImage(), OnlineImage
|
||||
/**
|
||||
* 好友图片
|
||||
*/ // NotOnlineImage
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
sealed class FriendImage : AbstractImage() {
|
||||
abstract val resourceId: String
|
||||
abstract val md5: ByteArray
|
||||
|
@ -39,7 +39,7 @@ open class QuoteReply
|
||||
* 用于发送的引用回复.
|
||||
* 总是使用 [quote] 来构造实例.
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
sealed class QuoteReplyToSend
|
||||
@MiraiInternalAPI constructor(source: MessageSource) : QuoteReply(source) {
|
||||
class ToGroup(source: MessageSource, val sender: QQ) : QuoteReplyToSend(source) {
|
||||
@ -53,7 +53,7 @@ sealed class QuoteReplyToSend
|
||||
* 引用这条消息.
|
||||
* @see sender 消息发送人.
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
fun MessageChain.quote(sender: QQ?): QuoteReplyToSend {
|
||||
this.firstOrNull<MessageSource>()?.let {
|
||||
return it.quote(sender)
|
||||
@ -65,7 +65,7 @@ fun MessageChain.quote(sender: QQ?): QuoteReplyToSend {
|
||||
* 引用这条消息.
|
||||
* @see from 消息来源. 若是好友发送
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
fun MessageSource.quote(from: QQ?): QuoteReplyToSend {
|
||||
return if (this.groupId != 0L) {
|
||||
check(from is Member) { "sender must be Member to quote a GroupMessage" }
|
||||
|
@ -101,7 +101,7 @@ abstract class BotNetworkHandler : CoroutineScope {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
suspend fun BotNetworkHandler.closeAndJoin(cause: Throwable? = null) {
|
||||
this.close(cause)
|
||||
this.supervisor.join()
|
||||
|
@ -120,7 +120,7 @@ class DeviceInfoData(
|
||||
@Transient
|
||||
override lateinit var context: Context
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class)
|
||||
override val ipAddress: ByteArray
|
||||
get() = localIpAddress().split(".").map { it.toUByte().toByte() }.takeIf { it.size == 4 }?.toByteArray() ?: byteArrayOf()
|
||||
override val androidId: ByteArray get() = display
|
||||
|
@ -18,7 +18,7 @@ import kotlin.annotation.AnnotationTarget.*
|
||||
* 非常不建议在发行版本中使用这些 API.
|
||||
*/
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
|
||||
@Experimental(level = Experimental.Level.ERROR)
|
||||
@Target(
|
||||
CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR,
|
||||
CLASS,
|
||||
@ -36,7 +36,7 @@ annotation class MiraiInternalAPI(
|
||||
* 不建议在发行版本中使用这些 API.
|
||||
*/
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
||||
@Experimental(level = Experimental.Level.WARNING)
|
||||
@Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR)
|
||||
annotation class MiraiExperimentalAPI(
|
||||
val message: String = ""
|
||||
@ -49,7 +49,7 @@ annotation class MiraiExperimentalAPI(
|
||||
* 非常不建议在发行版本中使用这些 API.
|
||||
*/
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
||||
@Experimental(level = Experimental.Level.WARNING)
|
||||
@Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR)
|
||||
annotation class MiraiDebugAPI(
|
||||
val message: String = ""
|
||||
|
@ -32,7 +32,7 @@ import kotlin.jvm.JvmName
|
||||
*/
|
||||
@InternalSerializationApi
|
||||
suspend fun ByteReadChannel.copyTo(dst: OutputStream) {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
ByteArrayPool.useInstance { buffer ->
|
||||
var size: Int
|
||||
while (this.readAvailable(buffer).also { size = it } > 0) {
|
||||
@ -45,7 +45,7 @@ suspend fun ByteReadChannel.copyTo(dst: OutputStream) {
|
||||
* 从接收者管道读取所有数据并写入 [dst]. 不会关闭 [dst]
|
||||
*/
|
||||
suspend fun ByteReadChannel.copyTo(dst: Output) {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
ByteArrayPool.useInstance { buffer ->
|
||||
var size: Int
|
||||
while (this.readAvailable(buffer).also { size = it } > 0) {
|
||||
@ -78,7 +78,7 @@ suspend fun ByteReadChannel.copyTo(dst: kotlinx.coroutines.io.ByteWriteChannel)
|
||||
@InternalSerializationApi
|
||||
suspend fun ByteReadChannel.copyAndClose(dst: OutputStream) {
|
||||
try {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
ByteArrayPool.useInstance { buffer ->
|
||||
var size: Int
|
||||
while (this.readAvailable(buffer).also { size = it } > 0) {
|
||||
@ -95,7 +95,7 @@ suspend fun ByteReadChannel.copyAndClose(dst: OutputStream) {
|
||||
*/
|
||||
suspend fun ByteReadChannel.copyAndClose(dst: Output) {
|
||||
try {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
ByteArrayPool.useInstance { buffer ->
|
||||
var size: Int
|
||||
while (this.readAvailable(buffer).also { size = it } > 0) {
|
||||
|
@ -30,7 +30,7 @@ import kotlin.jvm.JvmSynthetic
|
||||
|
||||
@JvmOverloads
|
||||
@Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class)
|
||||
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" }
|
||||
@ -54,7 +54,7 @@ fun List<Byte>.toUHexString(separator: String = " ", offset: Int = 0, length: In
|
||||
|
||||
@JvmOverloads
|
||||
@Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class)
|
||||
fun ByteArray.toUHexString(separator: String = " ", offset: Int = 0, length: Int = this.size - offset): String {
|
||||
this.checkOffsetAndLength(offset, length)
|
||||
if (length == 0) {
|
||||
@ -99,7 +99,7 @@ inline fun ByteArray.encodeToString(charset: Charset = Charsets.UTF_8): String =
|
||||
inline fun ByteArray.toReadPacket(offset: Int = 0, length: Int = this.size - offset) =
|
||||
ByteReadPacket(this, offset = offset, length = length)
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
@UseExperimental(ExperimentalContracts::class)
|
||||
inline fun <R> ByteArray.read(t: ByteReadPacket.() -> R): R {
|
||||
contract {
|
||||
callsInPlace(t, InvocationKind.EXACTLY_ONCE)
|
||||
|
@ -51,7 +51,7 @@ class ChunkedInput(
|
||||
*
|
||||
* 若 [ByteReadPacket.remaining] 小于 [sizePerPacket], 将会返回唯一元素 [this] 的 [Sequence]
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
fun ByteReadPacket.chunkedFlow(sizePerPacket: Int): Flow<ChunkedInput> {
|
||||
ByteArrayPool.checkBufferSize(sizePerPacket)
|
||||
if (this.remaining <= sizePerPacket.toLong()) {
|
||||
@ -76,7 +76,7 @@ fun ByteReadPacket.chunkedFlow(sizePerPacket: Int): Flow<ChunkedInput> {
|
||||
* 对于一个 1000 长度的 [ByteReadChannel] 和参数 [sizePerPacket] = 300, 将会产生含四个元素的 [Sequence],
|
||||
* 其长度分别为: 300, 300, 300, 100.
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
fun ByteReadChannel.chunkedFlow(sizePerPacket: Int): Flow<ChunkedInput> {
|
||||
ByteArrayPool.checkBufferSize(sizePerPacket)
|
||||
if (this.isClosedForRead) {
|
||||
@ -100,7 +100,7 @@ fun ByteReadChannel.chunkedFlow(sizePerPacket: Int): Flow<ChunkedInput> {
|
||||
* 对于一个 1000 长度的 [Input] 和参数 [sizePerPacket] = 300, 将会产生含四个元素的 [Sequence],
|
||||
* 其长度分别为: 300, 300, 300, 100.
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class, ExperimentalCoroutinesApi::class)
|
||||
@UseExperimental(MiraiInternalAPI::class, ExperimentalCoroutinesApi::class)
|
||||
internal fun Input.chunkedFlow(sizePerPacket: Int): Flow<ChunkedInput> {
|
||||
ByteArrayPool.checkBufferSize(sizePerPacket)
|
||||
|
||||
@ -127,7 +127,7 @@ internal fun Input.chunkedFlow(sizePerPacket: Int): Flow<ChunkedInput> {
|
||||
*
|
||||
* 若 [ByteReadPacket.remaining] 小于 [sizePerPacket], 将会返回唯一元素 [this] 的 [Sequence]
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class, ExperimentalCoroutinesApi::class, InternalSerializationApi::class)
|
||||
@UseExperimental(MiraiInternalAPI::class, ExperimentalCoroutinesApi::class, InternalSerializationApi::class)
|
||||
internal fun InputStream.chunkedFlow(sizePerPacket: Int): Flow<ChunkedInput> {
|
||||
ByteArrayPool.checkBufferSize(sizePerPacket)
|
||||
|
||||
|
@ -18,7 +18,6 @@ import io.ktor.utils.io.charsets.Charsets
|
||||
import io.ktor.utils.io.core.*
|
||||
import io.ktor.utils.io.pool.useInstance
|
||||
import kotlinx.io.OutputStream
|
||||
import kotlinx.serialization.InternalSerializationApi
|
||||
import net.mamoe.mirai.utils.MiraiDebugAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
@ -28,8 +27,7 @@ import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
@InternalSerializationApi
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
fun ByteReadPacket.copyTo(outputStream: OutputStream) {
|
||||
ByteArrayPool.useInstance {
|
||||
while (this.isNotEmpty) {
|
||||
@ -52,7 +50,7 @@ inline fun ByteReadPacket.readPacketExact(
|
||||
n: Int = remaining.toInt()//not that safe but adequate
|
||||
): ByteReadPacket = this.readBytes(n).toReadPacket()
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
@UseExperimental(ExperimentalContracts::class)
|
||||
inline fun <C : Closeable, R> C.withUse(block: C.() -> R): R {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
|
@ -68,6 +68,6 @@ fun BytePacketBuilder.writeHex(uHex: String) {
|
||||
/**
|
||||
* 会使用 [ByteArrayPool] 缓存
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
inline fun BytePacketBuilder.encryptAndWrite(key: ByteArray, encoder: BytePacketBuilder.() -> Unit) =
|
||||
TEA.encrypt(BytePacketBuilder().apply(encoder).build(), key) { decrypted -> writeFully(decrypted) }
|
@ -35,7 +35,7 @@ internal class CombinedMessageTest {
|
||||
|
||||
private val toAdd = "1".toMessage()
|
||||
|
||||
@OptIn(ExperimentalTime::class)
|
||||
@UseExperimental(ExperimentalTime::class)
|
||||
@Test
|
||||
fun speedTest() = repeat(100) {
|
||||
var count = 1L
|
||||
@ -86,7 +86,7 @@ internal class CombinedMessageTest {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalTime::class)
|
||||
@UseExperimental(ExperimentalTime::class)
|
||||
@Test
|
||||
fun testFastIteration() {
|
||||
println("start!")
|
||||
|
@ -24,9 +24,7 @@ import net.mamoe.mirai.utils.*
|
||||
* @see kotlinx.coroutines.isActive 判断 [Bot] 是否正常运行中. (在线, 且没有被 [close])
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@OptIn(
|
||||
MiraiInternalAPI::class, LowLevelAPI::class, MiraiExperimentalAPI::class, JavaHappyAPI::class
|
||||
)
|
||||
@UseExperimental(MiraiInternalAPI::class, LowLevelAPI::class, MiraiExperimentalAPI::class, JavaHappyAPI::class)
|
||||
actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIAccessor, BotJavaHappyAPI() {
|
||||
actual companion object {
|
||||
/**
|
||||
@ -246,6 +244,6 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
|
||||
*/
|
||||
actual abstract fun close(cause: Throwable?)
|
||||
|
||||
@OptIn(LowLevelAPI::class, MiraiExperimentalAPI::class)
|
||||
@UseExperimental(LowLevelAPI::class, MiraiExperimentalAPI::class)
|
||||
actual final override fun toString(): String = "Bot(${uin})"
|
||||
}
|
@ -132,7 +132,7 @@ actual abstract class BotJavaHappyAPI actual constructor() {
|
||||
message: String? = null,
|
||||
remark: String? = null
|
||||
): AddFriendResult {
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
@UseExperimental(MiraiExperimentalAPI::class)
|
||||
return runBlocking { addFriend(id, message, remark) }
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ actual abstract class BotJavaHappyAPI actual constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@UseExperimental(ExperimentalCoroutinesApi::class)
|
||||
internal fun <R, C : CoroutineScope> C.future(block: suspend C.() -> R): Future<R> {
|
||||
val future = object : Future<R> {
|
||||
val value: CompletableDeferred<R> = CompletableDeferred()
|
||||
@ -214,7 +214,7 @@ internal fun <R, C : CoroutineScope> C.future(block: suspend C.() -> R): Future<
|
||||
}
|
||||
|
||||
launch {
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@UseExperimental(ExperimentalCoroutinesApi::class)
|
||||
future.value.completeWith(kotlin.runCatching { block() })
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ import net.mamoe.mirai.utils.WeakRefProperty
|
||||
* @author Him188moe
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class, JavaHappyAPI::class)
|
||||
actual abstract class Contact : CoroutineScope, ContactJavaHappyAPI() {
|
||||
/**
|
||||
* 这个联系人所属 [Bot].
|
||||
|
@ -20,7 +20,7 @@ import net.mamoe.mirai.utils.WeakRefProperty
|
||||
/**
|
||||
* 群成员.
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class, JavaHappyAPI::class)
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
actual abstract class Member : MemberJavaHappyAPI() {
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ import java.net.URL
|
||||
* 一条从服务器接收到的消息事件.
|
||||
* JVM 平台相关扩展
|
||||
*/
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
actual abstract class MessagePacket<TSender : QQ, TSubject : Contact> actual constructor() : MessagePacketBase<TSender, TSubject>() {
|
||||
// region 上传图片
|
||||
suspend inline fun uploadImage(image: BufferedImage): Image = subject.uploadImage(image)
|
||||
|
@ -28,7 +28,7 @@ import net.mamoe.mirai.utils.unsafeWeakRef
|
||||
* @see MessageReceipt.sourceTime 源时间
|
||||
*/
|
||||
@Suppress("FunctionName")
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
actual open class MessageReceipt<C : Contact> actual constructor(
|
||||
actual val source: MessageSource,
|
||||
target: C,
|
||||
@ -94,7 +94,7 @@ actual open class MessageReceipt<C : Contact> actual constructor(
|
||||
*/
|
||||
actual open suspend fun quote(): QuoteReplyToSend {
|
||||
this.source.ensureSequenceIdAvailable()
|
||||
@OptIn(LowLevelAPI::class)
|
||||
@UseExperimental(LowLevelAPI::class)
|
||||
return _unsafeQuote()
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ actual fun localIpAddress(): String = InetAddress.getLocalHost().hostAddress
|
||||
|
||||
actual val Http: HttpClient get() = HttpClient(CIO)
|
||||
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
actual fun ByteArray.unzip(offset: Int, length: Int): ByteArray {
|
||||
this.checkOffsetAndLength(offset, length)
|
||||
if (length == 0) return ByteArray(0)
|
||||
|
@ -21,7 +21,7 @@ import java.io.File
|
||||
/**
|
||||
* 加载一个设备信息. 若文件不存在或为空则随机并创建一个设备信息保存.
|
||||
*/
|
||||
@OptIn(UnstableDefault::class)
|
||||
@UseExperimental(UnstableDefault::class)
|
||||
fun File.loadAsDeviceInfo(context: Context = ContextImpl()): DeviceInfo {
|
||||
if (!this.exists() || this.length() == 0L) {
|
||||
return SystemDeviceInfo(context).also {
|
||||
@ -35,7 +35,7 @@ fun File.loadAsDeviceInfo(context: Context = ContextImpl()): DeviceInfo {
|
||||
|
||||
|
||||
@Serializable
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class)
|
||||
actual open class SystemDeviceInfo actual constructor() : DeviceInfo() {
|
||||
actual constructor(context: Context) : this() {
|
||||
this.context = context
|
||||
|
@ -80,7 +80,7 @@ actual class PlatformSocket : Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalIoApi::class)
|
||||
@UseExperimental(ExperimentalIoApi::class)
|
||||
actual suspend fun connect(serverHost: String, serverPort: Int) {
|
||||
withContext(Dispatchers.IO) {
|
||||
socket = Socket(serverHost, serverPort)
|
||||
|
@ -142,7 +142,7 @@ internal class LockFreeLinkedListTest {
|
||||
list.size shouldBeEqualTo 0
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class)
|
||||
@Test
|
||||
fun withInlineClassElements() {
|
||||
val list = LockFreeLinkedList<UInt>()
|
||||
@ -270,7 +270,7 @@ internal class LockFreeLinkedListTest {
|
||||
*/
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@UseExperimental(ExperimentalCoroutinesApi::class)
|
||||
@MiraiExperimentalAPI
|
||||
internal suspend inline fun <E : LockFreeLinkedList<*>> E.concurrentDo(numberOfCoroutines: Int, times: Int, crossinline todo: E.() -> Unit) =
|
||||
coroutineScope {
|
||||
|
Loading…
Reference in New Issue
Block a user