@thegingon. That wouldnt work seeing as to check if $nick isop $chan you need to be on the channel.
I see now that its for a bot, so with some spam protection and a couple of other bells and whistles it would be good to have auto-join on invite.