Replying to the other thread here, since it's modifying the code of this thread.
https://forums.mirc.com/ubbthreads.php/topics/264596/Re:_Twitch_Commands_Help#Post264596

I combined the 2 tasks in the same event handlers. The code for each task is kept in separate groups of lines.

The %timeframe2 variable should be defined as the same number in both places it's used, ditto for %table1 and %table2. As with the flood counter, I'm resetting the clock when they change their nick instead of continuing with the existing time countdown.

I also modified the TEXT and ACTION events with the @ prefix, which prevents the event from triggering unless you have OP level in that channel. If that doesn't apply to twitch, you can delete the @ from those lines.

As before, I leave it up to you to code the action you're taking against the offender.

Code:
on @*:TEXT:*:#*:{ noop $flood_counter $repeat_counter($1-)   }
on @*:ACTION:*:#*:{ noop $flood_counter $repeat_counter($1-) }
on *:NICK:{
  var %table flood , %timeframe 300 , %wilditem $+(*!,$fulladdress)
  while ($hfind(%table,%wilditem,1,w)) {
    hdel %table $v1
    hadd -u $+ %timeframe %table $puttok($v1,$newnick,3,33)
  }

  var %timeframe2 300 , %table1 repeat.text , %table2 repeat.count , %wilditem $+(*!,$fulladdress)
  while ($hfind(%table1,%wilditem,1,w)) {
    var %a $puttok($v1,$newnick,2,33)
    hadd -u $+ %timeframe2 %table1 %a $hget(%table1,$v1)
    hadd -u $+ %timeframe2 %table2 %a $hget(%table2,$v1)
    hdel %table1 $v1
    hdel %table2 $v1
  }

}

alias -l repeat_counter {
  var %timeframe2 300 , %kill.at.repeats 3 , %table1 repeat.text , %table2 repeat.count
  var %text $lower($strip($1))

  if (!$hget(%table1)) { hmake %table1 101 }
  if (!$hget(%table2)) { hmake %table2 101 }
  var %item $+($chan,!,$fulladdress)
  var %a $hget(%table1,%item)
  if ((%a == $null) || (%a != %text)) {
    hadd -u $+ %timeframe2 %table1 %item %text
    hadd -u $+ %timeframe2 %table2 %item 1
    return
  }

  var %secs $hget(%table1,%item).unset | if (!%secs) var %secs %timeframe2
  hinc -u $+ %timeframe2 %table2 %item
  var %count $hget(%table2,%item)

  if (%count >= %kill.at.repeats) {
    echo 4 -a $nick has repeated %count times within %timeframe2 seconds. Action goes in here
  }

}

alias -l flood_counter {
  var %timeframe 300 , %max.messages 5 , %table flood
  if (!$hget(%table)) { hmake %table 101 | hadd %table counter 1 }
  var %counter $hget(%table,counter) | hinc %table counter 1
  var %item $+(%counter,!,$chan,!,$fulladdress) , %wilditem $+(*!,$chan,!,$fulladdress)
  hadd -u $+ %timeframe %table %item | var %msg_count $hfind(%table,%wilditem,0,w)
  echo -s debug message: $nick has %msg_count messages in the last %timeframe seconds
  if (%msg_count >= %max.messages) {
    echo 4 -s action to take against $nick in $chan goes inside these brackets
  }
}