[core] Push bot working directories to service

This commit is contained in:
Karlatemp 2023-06-29 12:40:11 +08:00
parent 804cb8b12d
commit ed7eca7f6b
No known key found for this signature in database
GPG Key ID: BA173CA2B9956C59
3 changed files with 10 additions and 1 deletions

View File

@ -18,11 +18,12 @@ import kotlinx.serialization.json.Json
import net.mamoe.mirai.internal.QQAndroidBot
import net.mamoe.mirai.internal.network.component.ComponentKey
import net.mamoe.mirai.internal.network.protocol.packet.createChannelProxy
import net.mamoe.mirai.internal.spi.EncryptService
import net.mamoe.mirai.internal.spi.EncryptServiceContext
import net.mamoe.mirai.internal.utils.actualCacheDir
import net.mamoe.mirai.internal.utils.crypto.QQEcdh
import net.mamoe.mirai.internal.utils.crypto.QQEcdhInitialPublicKey
import net.mamoe.mirai.internal.utils.crypto.verify
import net.mamoe.mirai.internal.utils.workingDirPath
import net.mamoe.mirai.utils.MiraiLogger
import net.mamoe.mirai.utils.buildTypeSafeMap
import net.mamoe.mirai.utils.currentTimeSeconds
@ -124,6 +125,8 @@ internal class EcdhInitialPublicKeyUpdaterImpl(
set(EncryptServiceContext.KEY_DEVICE_INFO, bot.client.device)
set(EncryptServiceContext.KEY_BOT_PROTOCOL, bot.configuration.protocol)
set(EncryptServiceContext.KEY_QIMEI36, bot.client.qimei36 ?: "")
set(EncryptServiceContext.KEY_BOT_WORKING_DIR, bot.configuration.workingDirPath)
set(EncryptServiceContext.KEY_BOT_CACHING_DIR, bot.configuration.actualCacheDir().absolutePath)
}))
}

View File

@ -14,6 +14,8 @@ import net.mamoe.mirai.internal.network.component.ComponentKey
import net.mamoe.mirai.internal.spi.EncryptService
import net.mamoe.mirai.internal.spi.EncryptServiceContext
import net.mamoe.mirai.internal.spi.GlobalEncryptServiceUsage
import net.mamoe.mirai.internal.utils.actualCacheDir
import net.mamoe.mirai.internal.utils.workingDirPath
import net.mamoe.mirai.utils.buildTypeSafeMap
internal interface EncryptServiceHolder {
@ -48,6 +50,8 @@ internal class EncryptServiceHolderImpl(
EncryptServiceContext(bot.id, buildTypeSafeMap {
set(EncryptServiceContext.KEY_BOT_PROTOCOL, bot.configuration.protocol)
set(EncryptServiceContext.KEY_DEVICE_INFO, ssoProcessorContext.device)
set(EncryptServiceContext.KEY_BOT_WORKING_DIR, bot.configuration.workingDirPath)
set(EncryptServiceContext.KEY_BOT_CACHING_DIR, bot.configuration.actualCacheDir().absolutePath)
})
)
isAvailable = true

View File

@ -33,6 +33,8 @@ public class EncryptServiceContext @MiraiInternalApi constructor(
public val KEY_CHANNEL_PROXY: TypeKey<EncryptService.ChannelProxy> = TypeKey("KEY_CHANNEL_PROXY")
public val KEY_DEVICE_INFO: TypeKey<DeviceInfo> = TypeKey("KEY_DEVICE_INFO")
public val KEY_QIMEI36: TypeKey<String> = TypeKey("KEY_QIMEI36")
public val KEY_BOT_WORKING_DIR: TypeKey<String> = TypeKey("KEY_BOT_WORKING_DIR")
public val KEY_BOT_CACHING_DIR: TypeKey<String> = TypeKey("KEY_BOT_CACHING_DIR")
}
}