How to attach a module to a drupal article?
For example, my module named custom2, so:

&lt;?php

function custom2_random_text(){
    return 'random-text';
}

function custom2_node_presave($node){
    //check for our node type if needed
    if($node-&gt;type == 'article')
        //assign value
        $node-&gt;body['und'][0]['value'] = custom2_random_text();
}



hook only works for Article content type
custom2_random_text - returns random text
custom2_node_presave - implementation of hook_node_presave


  function hook_node_presave
  
  7 node.api.php    hook_node_presave($node)
  
  Act on a node being inserted or updated.
  
  This hook is invoked from node_save() before the node is saved to the
  database.



Note how hooks in Drupal works. You are implementing hook_node_presave in your_module.module via replacing hook word by your module's name.

If you in doubt about structure of some entity on your site I should recommend you to use Devel module.

For first step you can implement hook_node_view and in code of your implementation use dpm($node) - it is Devel module function that will display node structure when node is displaying.

For my example:

function custom2_node_view($node, $view_mode, $langcode){
  dpm($node);
}