mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-07-03 22:07:24 +00:00
refactor(config): 为 BotAccount 添加 id 字段.
根据 Telegram Bot token 的组成结构, 可以取出 Bot Account Id, 故添加 id 字段.
This commit is contained in:
@ -32,7 +32,14 @@ internal data class BotAccount(
|
||||
val name: String,
|
||||
val token: String,
|
||||
val creatorId: Long = -1
|
||||
)
|
||||
) {
|
||||
|
||||
val id
|
||||
// 不要想着每次获取都要从 token 里取出有性能损耗.
|
||||
// 由于 Gson 解析方式, 如果不这么做, 会出现 token 设置前 id 初始化完成, 就只有"0"了,
|
||||
// 虽然能过单元测试, 但实际使用过程是不能正常用的.
|
||||
get() = token.substringBefore(":").toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* 机器人配置.
|
||||
|
Reference in New Issue
Block a user