code: func (p *Plugin) GetMemory(in *Msg, k string) Memory {
  	var buf []byte
  	var err error
  
  	// Only retrieve state-related values of that specific plugin.
  	// Otherwise fetch the memory from any plugin.
  	if in.User.ID > 0 {
  		if k == StateKey || k == stateEnteredKey {
  			q := `SELECT value FROM states
  			      WHERE userid=$1 AND key=$2 AND pluginname=$3`
  			err = p.DB.Get(&buf, q, in.User.ID, k, p.Config.Name)
  		} else {
  			q := `SELECT value FROM states
  			      WHERE userid=$1 AND key=$2`
  			err = p.DB.Get(&buf, q, in.User.ID, k)
  		}
  	} else {
  		if k == StateKey || k == stateEnteredKey {
  			q := `SELECT value FROM states
  			      WHERE flexid=$1 AND flexidtype=$2 AND key=$3 AND pluginname=$4`
  			err = p.DB.Get(&buf, q, in.User.FlexID,
  				in.User.FlexIDType, k, p.Config.Name)
  		} else {
  			q := `SELECT value FROM states
  			      WHERE flexid=$1 AND flexidtype=$2 AND key=$3`
  			err = p.DB.Get(&buf, q, in.User.FlexID,
  				in.User.FlexIDType, k)
  		}
  	}
  	if err == sql.ErrNoRows {
  		return Memory{Key: k, Val: json.RawMessage{}, log: p.Log}
  	}
  	if err != nil {
  		p.Log.Infof("could not get memory for key %s. %s", k,
  			err.Error())
  		return Memory{Key: k, Val: json.RawMessage{}, log: p.Log}
  	}
  	return Memory{Key: k, Val: buf, log: p.Log}
  }
docs: // GetMemory retrieves a memory for a given key. Accessing that Memory's value
  // is described in itsabot.org/abot/shared/datatypes/memory.go.