$1 is the first word of the line !sub
$2 is the 2nd word of the line, or is $null if there was none. So when they did "!sub foobar" then $2 is foobar. You probably want to do some error checking to make sure that foobar is a real username, and I'm not sure how to do that in twitch.

If $2 is @username and you need just username, you can take the string beginning at the 2nd character. $mid($2,2)

Question about your repeat blocking. Are you talking about repeating what they say to the bot, or any repeats of any kind? Is the repeat supposed to look only at the last 3 things they say, or does it need to check if the latest-msg, 5 messages ago, and 9 messages ago were the same? You'll need to decide what you want to flag and what you don't.