@@ -20,6 +20,8 @@ import kotlinx.coroutines.SupervisorJob
20
20
import kotlinx.serialization.json.Json
21
21
import net.mamoe.mirai.Bot
22
22
import net.mamoe.mirai.BotFactory
23
+ import net.mamoe.mirai.Mirai
24
+ import net.mamoe.mirai.auth.BotAuthorization
23
25
import net.mamoe.mirai.event.events.BotOfflineEvent
24
26
import kotlin.coroutines.CoroutineContext
25
27
import kotlin.coroutines.EmptyCoroutineContext
@@ -249,7 +251,19 @@ public open class BotConfiguration : AbstractBotConfiguration() { // open for Ja
249
251
* @since 2.8
250
252
*/
251
253
MACOS ,
254
+ ;
252
255
256
+ /* *
257
+ * 当前协议是否支持[二维码登录][BotAuthorization.byQRCode]
258
+ *
259
+ * @since 2.15.0
260
+ */
261
+ public val isQRLoginSupported: Boolean get() = data.isQRLoginSupported
262
+
263
+ private inline val data: InternalProtocolDataExchange .InternalProtocolData
264
+ get() = InternalProtocolDataExchange .instance.of(
265
+ this
266
+ )
253
267
}
254
268
255
269
/* *
@@ -562,3 +576,30 @@ internal val deviceInfoStub: (Bot) -> DeviceInfo = {
562
576
private val logger by lazy {
563
577
MiraiLogger .Factory .create(BotConfiguration ::class )
564
578
}
579
+
580
+ /* * @since 2.15.0 */
581
+ @MiraiInternalApi
582
+ public interface InternalProtocolDataExchange {
583
+ @MiraiInternalApi
584
+ public interface InternalProtocolData {
585
+ public val isQRLoginSupported: Boolean
586
+ public val mainVersion: String
587
+ public val buildVersion: String
588
+ public val sdkVersion: String
589
+ }
590
+
591
+ @MiraiInternalApi
592
+ public fun of (protocol : BotConfiguration .MiraiProtocol ): InternalProtocolData
593
+
594
+ @MiraiInternalApi
595
+ public companion object {
596
+ internal val instance by lazy {
597
+ Mirai // ensure service loaded
598
+
599
+ loadService(
600
+ InternalProtocolDataExchange ::class ,
601
+ " net.mamoe.mirai.internal.utils.MiraiProtocolInternal\$ Exchange"
602
+ )
603
+ }
604
+ }
605
+ }
0 commit comments