go_dreamfactory/modules/chat/options.go
2022-09-21 21:20:32 +08:00

42 lines
771 B
Go

package chat
import (
"errors"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/utils/mapstructure"
"go_dreamfactory/modules"
)
type (
IOptions interface {
modules.IOptions
}
Options struct {
modules.Options
GM bool //是否开启gm工具
}
)
func (this *Options) GetDebug() bool {
return this.Debug
}
func (this *Options) GetLog() log.ILogger {
return this.Log
}
func (this *Options) LoadConfig(settings map[string]interface{}) (err error) {
if settings != nil {
if err = mapstructure.Decode(settings, &this.Options); err != nil {
return
}
if err = mapstructure.Decode(settings, this); err != nil {
return
}
}
if this.Log = log.NewTurnlog(true, log.Clone("", 4)); this.Log == nil {
err = errors.New("log is nil")
}
return
}