initial: 基本完成的首个版本, 还需要调整一下.

暂时按照当初的计划实现了一个可用版本出来, 发布与否晚些再确定.
This commit is contained in:
2022-01-16 20:21:18 +08:00
parent cbaeb2ce00
commit 37f0d4e6b8
28 changed files with 1513 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package net.lamgc.scalabot
import net.lamgc.scalabot.util.toHaxString
import org.mapdb.DBMaker
import org.telegram.abilitybots.api.db.DBContext
import org.telegram.abilitybots.api.db.MapDBContext
import java.nio.charset.StandardCharsets
import java.security.MessageDigest
internal object BotDBMaker {
private val digest: MessageDigest = MessageDigest.getInstance("SHA-256")
fun getBotMaker(botAccount: BotAccount): DBContext {
val digestBytes = digest.digest(botAccount.token.toByteArray(StandardCharsets.UTF_8))
val dbPath = AppPaths.DATA_DB.path + "${digestBytes.toHaxString()}.db"
val db = DBMaker.fileDB(dbPath)
.closeOnJvmShutdownWeakReference()
.checksumStoreEnable()
.fileChannelEnable()
.make()
return MapDBContext(db)
}
}