Aleykum selam,
i dont know what you mean by
if opnick* iswm $nick
to be honest, i didnt understand all your description
the $opnick identifier will only receive a value on the "on op/op deop" event, which means the $opnick its the nick who received op or who was op removed
so you can use
if ($nick isop $chan) { command }
you need a check, to check if the person who is running the code is op on channel to set ban
i will not give an example of $regex, based on your script, cause it will confuse you