Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class WebsocketBotClient(override var botId: Long, override var password: String
override suspend fun initBot() {
wsClient = httpClient.newWebSocket(wsRequest, wsListener)
bot = Bot(botId, password) {
fileStrBasedDeviceInfo("device.json")
fileStrBasedDeviceInfo("device/${botId}.json")
loginSolver = MyLoginSolver
noNetworkLog()
}.alsoLogin()
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/net/lz1998/mirai/ext/MyDeviceInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ fun BotConfiguration.getFileStrBasedDeviceInfoSupplier(filename: String): ((Cont
fun File.loadStrAsDeviceInfo(json: Json, context: Context = ContextImpl()): DeviceInfo {
if (!this.exists() || this.length() == 0L) {
return MyDeviceInfo(context).also {
if (!this.parentFile.exists()) {
this.parentFile.mkdirs()
}
this.writeText(json.encodeToString(MyDeviceInfo.serializer(), it))
}
}
Expand Down