Code:
 
on *:sockread:bot2:{
  sockread %zz
  tokenize 32 %zz
  window -k @probe2
  echo @probe2 $lower($remove($gettok(%zz,1,32),:)) : $lower($remove($gettok(%zz,4-,32),:))
  set %nick $mid(%zz,2,$calc($pos(%zz,!,1) - 2)) 
  if ($gettok(%zz,1,32) == PING) {
    sockwrite -tn bot2 pong $gettok(%zz,2,32)
  }
  if ($4 == :@remember) && (($right($gettok($1,1,33),-1) == $me) || ($level($address($right($gettok($1,1,33),-1),5)) == aowner)) {
    if (&nick isin $gettok([color:blue]%z[/color],6-,32)) {
      [color:green]$replace(&nick,$gettok(%z,6-,32),$gettok(%z,6-,32))[/color]
      write [color:orange]$gettok(%z,6,32) .txt[/color] $gettok(%z,7-,32)
      sockwrite -n bot2 privmsg $3 :bot1.0;14 $sock(ot2).mark $+ 1b5(14 $+ $gettok(%z,7-,32) added to $gettok(%boo,6,32) .txt15)
    }
    else {
      write [color:orange]$gettok(%z,6,32) .txt[/color] $gettok(%z,7-,32)
      sockwrite -n bot2 privmsg $3 : $sock(bot2).mark $+ 15(14 $+ $gettok(%z,7-,32) added to $gettok(%z,6,32) .txt15)
    }
  }
}


(1) %z you never set value %z but use it often so its either $null or its currently being set by something else which if you look down to (3) may answer your question.
(2) $replace(&nick,$gettok(%z,6-,32),$gettok(%z,6-,32)) what but what is that ment to do!?!?!?!?!?!
(3) $gettok(%z,6,32) .txt the 6th word in %z what ever it is or ".txt" is being used as the filename to write to.