to make a little improvement:

use $nick($1, %i, hvr) instead of $nick($1, %i) to check only those people that aren't already an op and stop opping them several times.