if ($nick isop #) may fail on twitch because twitch is not a proper irc network and does not immediately notify clients that a user is an operator. To get around that you'd need to save the names of mods somewhere and look it up as needed.
To fix the exploit, use the "n" switch with $read and $readini: $readini(file,n,topic,item)
To fix the problems with matching !commands you need to move the wildcard !* event below all other events you've defined that begin with !