IRC Bot Phrase Counter Help

You could keep it running constantly, then you never have to start/stop a timer.

If you’re looking for advice on methodology:

One simple way is to make an array of 60 buckets (positive integer values) for a 1 second granulation, then just count the occurrences of ‘VAC’ in each message and dump it in the appropriate bucket. Then when the count-per-minute is called for, add up all the buckets.

Or for each message you could count the occurrences, then push the count (plus a timestamp) onto an array. When the count is called for, start iterating backwards and adding up all the ones that are 1 minute or newer and throwing out the rest. You’d want to do some simple garbage collecting, like throwing out everything older than 1 minute once the array reaches a certain size, or throwing out the old ones once every few minutes, or throwing the out ones each time a new one is added.

Or keep it running for any amount of time, not necessarily a minute.

I’m sure people have come up with some pretty efficient and creative ways of counting the occurrences-per-minute in Twitch chat, but these are ways I’ve used to do it.

If you’re looking for language-specific answers though, you might have better luck in a forum for that language.