Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): 修复个别配置项的设置在 UI 不生效的问题 #1104

Merged
merged 3 commits into from
Oct 28, 2024
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
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"},
},
}