For anyone else reading this, if you're wanting help with twitch, please say so up front, because that's not a real IRC network, and things that work everywhere else won't always work there, and things that work there won't work on any other IRC network. So my confusion was based on the assumption you were asking to have mIRC itself creating these colors, which it can't do.

It needs to be a mix of both kinds of code, because the correct method to use is FroggieDaFrog's usage of ON INPUT, because ON TEXT does not trigger for yourself making a message in a channel. Also, instead of choosing a random color from the list, it would need to create a local variable that keeps track of the last color, so it can use the next one.

I've rarely been on twitch, so this using of .color in a message is news to me, so I'm scripting this based on the assumption that the msg .color command actually works at twitch, though it works nowhere else that I'm aware of.

My warning in my original post still applies. These colors look like they're designed to work against a black background, with the 7th of 9 colors being marginally readible. However if you have people using a white background, they're going to get irritated with this very pronto because the yellow and white text can't be seen, and the orange is a shade that's marginal.

If twitch supports a color command to force the background for your line of text to be black, that could allow people with white background to at least read your text, though they won't like it when there's a black stripe each time you make a message. Hopefully twitch either has something like that, or has something automatically to change the background color to contrast with the foreground color.

Not sure how this script will work with other people using mIRC, because I don't know if mIRC recognizes the 24-bit color index to use that to change the default color for your text. You'd need to test with mIRC running twice, because otherwise you might be seeing your outbound text instead of what the server sends back to you.

Code
on *:INPUT:#:{
  ;; if ctrl+enter was NOT used
  ;; the text isn't being pasted in
  ;; the text doesn't start with /
  ;; the text doesn't start with a user defined command character
  if (!$ctrlenter && !$inpaste && /* !iswm $1 && $comchar $+ * !iswm $1) {

  ; Hardcoded list of N colors
  var %hex FF1F1F FF9A1F F8FF1F 44FF1F 1FECFF 1F75FF 401FFF FF1FFF FFFFFC
  ; bump the index +1 resulting in the range being 1 through N
  set %color.index $calc( (%color.index % $numtok(%hex,32)) +1 )
  ; send the magic color change command
  msg $chan .color $chr(35) $+ $gettok(%hex,%color.index,32)
  }
}