I need to count how many times my char said "hi" in the NPC channel without being talked to by the NPC. If my char says "hi" 6 times or more, then do X action.

Is that possible?

Ex:
My char: hi
My char: hi
My char: hi
NPC: hello
My char: hi
My char: hi
My char: hi

In the example above the NPC talked to me so no action will be taken.

Ex:
My char: hi
My char: hi
My char: hi
My char: hi
My char: hi
My char: hi

In the example above the NPC didn't talk to me so X action will be taken.