package rcon import ( "fmt" "regexp" "strconv" ) var ( timeRegexp = regexp.MustCompile("(\\d+)$") ) func (r *Session) AddTime(delta int) int { res, err := r.connection().SendCommand(fmt.Sprintf("time add %d", delta)) if err != nil { return -1 } m := timeRegexp.FindStringSubmatch(res) if m == nil { return -1 } ret, _ := strconv.Atoi(m[1]) return ret } func (r *Session) GetTime() int { res, err := r.connection().SendCommand("time query daytime") if err != nil { return -1 } m := timeRegexp.FindStringSubmatch(res) if m == nil { return -1 } v, _ := strconv.Atoi(m[1]) return v }