Be sure to look at the wikichip links above, and the other topics at that wiki. They often give a little more detail than mentioned in the F1 help.

In your example, you are using ampersand incorrectly. That field should use wildcards ? as a single character and asterisk as 1-or-more characters. "*enlisted for ?? months*" would only match when the word before 'months' has 2 digits.

Also, look at words as if they are values separated by at least 1 space, even if they are touched by color codes or punctuation. $1 is the first 'word' of the line, so in your example, $1 is 'user', so $2 is johndoe123 and $6 is the the 6th word '2'. $nick is the nick saying the message, in this case it's hnlbot.

You can trap rate limited data using a variable that unsets after N seconds. When you use global variables which remain outside your alias or on-text, you should avoid using simple names like %a or %short_word which might also be used by a different script. If you are using %var to create local variables which disappear outside the ON TEXT or your alias, it's fine to use %a or %x as long as you first define them as blank or another value, to prevent them containing the value in the global variable, which continues to exist after your local variable vanishes. If you have an on text which triggers only for lines containing *hi there*, you can use that to increase the counter.

Code:
on *:TEXT:*hi there*:#djquad:{
  inc -u30 %hithere_counter $count($1-,hi there)
  if (%hithere_counter isnum 3-) msg $chan hey $nick - <message>
}


The -uN switch makes the variable unset 30 seconds later, so each time the -u30 is used to increment the counter, the 30 second clock gets reset to 30. If you don't want the clock reset each time:

inc $iif( !%hithere_counter,-u30) %hithere_counter $count($1-,hi there)

This uses the -u30 only to create the variable, so it disappears 30 seconds after the 1st 'hi there' regardless how many times triggered during that 30 seconds.

if $1- is 'hi there hi there' $count returns 2. You don't want to use /inc -u30 for all lines even when $count returns 0 because the countdown clock gets reset to to 30 each time a chat message appears.

Be careful about using a %variable with /inc if it could be blank:

unset %x
inc %a %x

This is the same as "inc %a" and increases %a by 1.

Also, the purple messages created by "/me says hi there" use the event ON ACTION, so you would also need to trap that if you want the script to see those too.

Be careful about putting more than 1 ON TEXT in a script.

Code:
on *:TEXT:*test*:#djquad:{
  echo -a event 1
}
on *:TEXT:*:#djquad:{
 echo -a event 2
}


The 1st one traps all messages containing 'test', preventing them from being trapped by the 2nd one.