Code:
alias caps return $calc($regex($1,/[A-Z]/g) / $len($1-) * 100)
alias _caps return $calc($regex($1,/[A-Z]/g) / $len($remove($1,$chr(32))) * 100)
alias __caps {
  var %text
  return $calc($(,,$regsub($1,/[^a-z]/gi,,%text)) $regex(%text,/[A-Z]/g) / $len(%text) * 100)
}
on @*:text:*:#:{
  if ($nick !isreg $chan) return
  var %method = _caps, %percent = 50, %warn = Don't use so many caps $+ $chr(32), $& 
    %kick = You were told not to use so many caps, %ban = This is what happens when people don't listen, %mask = 2
  if ($($+($,%method,$chr(40),$1-,$chr(41)),2) > %percent) {
    hinc -m $+(caps,$cid,$chan) $nick
    var %n = $hget($+(caps,$cid,$chan),$nick)
    if (%n == 1) msg $chan %warn $nick
    elseif (%n == 2) kick $chan $nick %kick
    elseif (%n == 3) {
      ban -ku60 $chan $nick %mask %ban
      hdel $+(caps,$cid,$chan) $nick
    }
  }
}


There are several variables at the top of the on text event you can edit to change how the code works:

%mask - the type of mask to ban in the ban command. Look at /help $mask to see a list.

%method - the method used to determine how many caps are used. This can be caps (returns percentage of capital letters in the string), _caps (returns percentage of capitals in the string, ignores spaces) or __caps (returns percentage of capitrals in the string, ignores everything except letters).

%percent - the percentage of caps allowed. If the percentage of caps in a string is more than this value the user will be warned/kicked/banned.

%warn - warning message.
%kick - kick message.
%ban - ban message.