This is what I use, I tend to stay away from raw data from sockets as it can be really messy, but for ease of use im sharing this with you. You can format it to your own needs.

Code:
on ^*:RAWMODE:*: {
  var %p = $left($nick($chan,$nick).pnick,1) | if (%p == $left($nick,1)) { unset %p }
  if ($regex($1,/^[\+-]?[ifmstplk]$/)) { echo $color(mode) -ti2 $chan 3› %p $+ $replace($nick,>,Guest_) sets mode: 14 $+ $chr(91) $+ 14 $+(3,$1,3) $2- 14 $+ $chr(93) 143 $+(14,«,3) $chan $+(14,»3) | haltdef }
  else {
    echo $color(mode) -ti2 $chan 3› %p $+ $replace($nick,>,Guest_) sets mode: 14 $+ $chr(91) $+ 14 $+(3,$regsubex($1,/([oqQvh])\1+/g,\t),3) 14 $+ $chr(93) 143 $replace($2-,$chr(32),$+($chr(44),$chr(32)))
    haltdef
  }
}