How could I incorporate the spam protection that this welcome script has?

Code:
on !*:JOIN:#:{
  set -e $+(%,ajwelcome.,$cid,#) $addtok($($+(%,ajwelcome.,$cid,#),2),$nick $+ $chr(44),32)
  if (!$timer($+(.ajw.,$cid,#))) { $+(.timer.ajw.,$cid,#) 1 10 ajwelcome # }
}
alias -l ajwelcome {
  if ($($+(%,ajwelcome.,$cid,$1),2)) {
    msg $1 Welcome to the stream $left($v1,-1) $+ !
    unset $+(%,ajwelcome.,$cid,$1)
  }
}


What I like about it is that is welcomes multiple people that have join in a repeating 10 second interval. What I want for this word counter is to display the word count message (ex.: "Testword has been used X times in chat.") at the end of the 10 second interval if it was used within that 10 second interval. If the word was not used I don't want any word count message displayed. But, if the word was used 5 times within the 10 second period I only want 1 message displaying the total count including the 5 most recent uses of the count word.