Skip to content

Commit

Permalink
fix(config): 修复个别配置项的设置在 UI 不生效的问题 (#1104)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustAnotherID authored Oct 28, 2024
1 parent 8488066 commit 0eb28c5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
16 changes: 6 additions & 10 deletions dice/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2081,8 +2081,13 @@ func (d *Dice) loads() {
d.ImSession.EndPoints = dNew.ImSession.EndPoints
d.DiceMasters = dNew.DiceMasters
if len(d.DiceMasters) == 0 {
d.DiceMasters = []string{"UI:1001"}
d.DiceMasters = DefaultConfig.DiceMasters
}
d.CommandPrefix = dNew.CommandPrefix
if len(d.CommandPrefix) == 0 {
d.CommandPrefix = DefaultConfig.CommandPrefix
}
d.DeckList = dNew.DeckList
var newDiceMasters []string
for _, i := range d.DiceMasters {
if i != "<平台,如QQ>:<帐号,如QQ号>" {
Expand Down Expand Up @@ -2304,15 +2309,6 @@ func (d *Dice) loads() {
i.AdapterSetup()
}

if len(d.CommandPrefix) == 0 {
d.CommandPrefix = []string{
"!",
".",
"。",
"/",
}
}

d.LogWriter.LogLimit = d.Config.UILogLimit

// 设置扩展选项
Expand Down
13 changes: 11 additions & 2 deletions dice/dice_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type Config struct {
NewsConfig `yaml:",inline"`
// 敏感词设置
CensorConfig `yaml:",inline"`

// 其它设置,包含由于被导出无法从 Dice 上迁移过来的配置项,为了在 DefaultConfig 上统一设置默认值增加此结构
DirtyConfig `yaml:",inline"`
}

func NewConfig(d *Dice) Config {
Expand Down Expand Up @@ -183,8 +186,8 @@ type QuitInactiveConfig struct {

QuitInactiveThresholdDays float64 `yaml:"-" json:"quitInactiveThreshold"` // 为了和前端通信

QuitInactiveBatchSize int64 `yaml:"quitInactiveBatchSize"` // 退出不活跃群组的批量大小
QuitInactiveBatchWait int64 `yaml:"quitInactiveBatchWait"` // 退出不活跃群组的批量等待时间(分)
QuitInactiveBatchSize int64 `yaml:"quitInactiveBatchSize" json:"quitInactiveBatchSize"` // 退出不活跃群组的批量大小
QuitInactiveBatchWait int64 `yaml:"quitInactiveBatchWait" json:"quitInactiveBatchWait"` // 退出不活跃群组的批量等待时间(分)
}

type ExtConfig struct {
Expand Down Expand Up @@ -230,3 +233,9 @@ type CensorConfig struct {
CensorMatchPinyin bool `json:"censorMatchPinyin" yaml:"censorMatchPinyin"` // 敏感词匹配拼音
CensorFilterRegexStr string `json:"censorFilterRegexStr" yaml:"censorFilterRegexStr"` // 敏感词过滤字符正则
}

type DirtyConfig struct {
DeckList []*DeckInfo `yaml:"-"` // 牌堆信息
CommandPrefix []string `yaml:"-"` // 指令前导
DiceMasters []string `yaml:"-"` // 骰主设置,需要格式: 平台:帐号
}
10 changes: 10 additions & 0 deletions dice/dice_config_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,14 @@ var DefaultConfig = Config{
CensorMatchPinyin: false,
CensorFilterRegexStr: "",
},
DirtyConfig{
DeckList: nil,
CommandPrefix: []string{
"!",
".",
"。",
"/",
},
DiceMasters: []string{"UI:1001"},
},
}

0 comments on commit 0eb28c5

Please sign in to comment.