func defaultPuzzles(uni *context.Uni) []interface{} { def, has := jsonp.GetS(uni.Opt, "user.default_puzzles") if !has || len(def) == 0 { return []interface{}{"timer"} } return def }
// Return all hooks modules subscribed to a path. func all(e *Ev, path string) []string { modnames, ok := jsonp.GetS(e.uni.Opt, "Hooks."+path) if !ok { return nil } ret := []string{} for _, v := range modnames { ret = append(ret, v.(string)) } return ret }
// Return all hooks modules subscribed to a path. func (e *Hook) subscribers() []subscriber { ret := []subscriber{} subscribed, ok := jsonp.GetS(e.hooks, e.Hookname) if !ok { return ret } for _, v := range subscribed { inf := subscriber{} switch t := v.(type) { case string: inf.modName = t case []interface{}: if len(t) != 2 { panic("Misconfigured hook.") } inf.modName = t[0].(string) inf.methodName = t[1].(string) } ret = append(ret, inf) } return ret }
// Return all hooks modules subscribed to a path. func all(e *Ev, path string) []hookInf { ret := []hookInf{} subscribed, ok := jsonp.GetS(e.hooks, path) if !ok { return ret } for _, v := range subscribed { hinf := hookInf{} switch t := v.(type) { case string: hinf.modName = t case []interface{}: if len(t) != 2 { panic("Misconfigured hook.") } hinf.modName = t[0].(string) hinf.methodName = t[1].(string) } ret = append(ret, hinf) } return ret }