Random Featured Image Based on Category

First of all when you call the get_image function pass the post categories slugs as param.

Edit your autoset_featured function replacing

...
} else {
   set_post_thumbnail($post->ID, get_image());
}
...

with:

... 
} else {
  $cat_slugs = wp_get_post_terms($post->ID, 'event-categories', array("fields" => "slugs"));
  $image = get_image( $cat_slugs );
  if ( image ) set_post_thumbnail($post->ID, $image);
}
...

Then edit the get_image to something like this:

function get_image( $cats = array() ) {
  $media_query = new WP_Query(
    array(
      'post_status' => 'inherit',
      'post_parent' => 0,
      'post_type' => 'attachment',
      'post_mime_type' => 'image/jpeg',
      // set 'orderby' to 'rand' will randomize results order
      'orderby' => 'rand',

      // READ CAREFULLY:
      // if in the title of all images intended to be used as thumbnail
      // you put something that contain 'UF' you can use the 's' param
      // retrieving less results and so improving performance
      // in that case uncomment next line
      // 's' => 'UF'

    )
  );

  if ( $media_query->have_posts() ) {

    $lastid = false; // just an early setup

    // loop through images
    foreach ($media_query->posts as $post) {

      // get current image url
      $fullpath = wp_get_attachment_url($post->ID);

      // if current image name doesn't start with 'UF-' skip it
      if ( strpos( basename($fullpath), 'UF-' ) !== 0 ) continue;

      // if the original post has no categories assigned, return first image ID
      // images are random ordered, so first one is random one
      if ( empty($cats) ) return $post->ID;    

      // get current image file name (without extension) and remove the 'UF-' part
      $name = pathinfo( basename($fullpath), PATHINFO_FILENAME);
      $nameNoUF = str_replace('UF-', '', $name); 

      // $nameNoUF contain something like 'category-name-01'
      // because 'UF-' at beginning and extension were both removed

      // save the current image ID in a helper variable for future possible use
      $lastid = $post->ID;

      // loop through categories and if $nameNoUF start with a category slug,
      // return the image ID.
      // this way every image named like 'UF-category-name-01.jpg' match
      foreach ( $cats as $cat ) {
        if ( strpos($nameNoUF, $cat) === 0 ) return $post->ID;
      }
    }
    // if we are here no category related image was found, so return the last image ID
    // images are random ordered, so last one is random one
    return $lastid;
  }
  // no images found at all, sorry, return false (no thumbnail will be setted)
  return false;
}

As suggested in inline comments to use the s parameter in query to retrieve the images that has ‘UF’ in title or content to limit results. Of course this need you add that string to images title or content.

Inline comments should explain how the function works.

Hope it helps.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)