Skip to content

Commit 8cc3b7d

Browse files
authored
Merge pull request #7 from lz1998/master
update device
2 parents d5ba111 + 9c9037d commit 8cc3b7d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/main/kotlin/net/lz1998/mirai/entity/WebSocketBotClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class WebsocketBotClient(override var botId: Long, override var password: String
9696
override suspend fun initBot() {
9797
wsClient = httpClient.newWebSocket(wsRequest, wsListener)
9898
bot = Bot(botId, password) {
99-
fileStrBasedDeviceInfo("device.json")
99+
fileStrBasedDeviceInfo("device/${botId}.json")
100100
loginSolver = MyLoginSolver
101101
noNetworkLog()
102102
}.alsoLogin()

src/main/kotlin/net/lz1998/mirai/ext/MyDeviceInfo.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ fun BotConfiguration.getFileStrBasedDeviceInfoSupplier(filename: String): ((Cont
189189
fun File.loadStrAsDeviceInfo(json: Json, context: Context = ContextImpl()): DeviceInfo {
190190
if (!this.exists() || this.length() == 0L) {
191191
return MyDeviceInfo(context).also {
192+
if (!this.parentFile.exists()) {
193+
this.parentFile.mkdirs()
194+
}
192195
this.writeText(json.encodeToString(MyDeviceInfo.serializer(), it))
193196
}
194197
}

0 commit comments

Comments
 (0)