// this file is auto create by program, don't edit manually package data import ( mhayaError "github.com/mhaya/error" mhayaLogger "github.com/mhaya/logger" ) type kolConfig struct { maps map[string]*kolConfigRow } type kolConfigRow struct { Userid string `json:"userid"` // telegram用户唯一标识 Mark string `json:"mark"` // 类型 PptBoolean int `json:"ppt_boolean"` } func (p *kolConfig) Name() string { return "kolConfig" } func (p *kolConfig) Init() { p.maps = make(map[string]*kolConfigRow) } func (p *kolConfig) OnLoad(maps interface{}, _ bool) (int, error) { list, ok := maps.([]interface{}) if !ok { return 0, mhayaError.Error("maps convert to []interface{} error.") } loadMaps := make(map[string]*kolConfigRow) for index, data := range list { loadConfig := &kolConfigRow{} err := DecodeData(data, loadConfig) if err != nil { mhayaLogger.Warnf("decode error. [row = %d, %v], err = %s", index+1, loadConfig, err) continue } loadMaps[loadConfig.Userid] = loadConfig } p.maps = loadMaps return len(list), nil } func (p *kolConfig) OnAfterLoad(_ bool) { } func (p *kolConfig) Get(pk string) (*kolConfigRow, bool) { i, found := p.maps[pk] return i, found } func (p *kolConfig) Contain(pk string) bool { _, found := p.Get(pk) return found }