Same idea, but I'd use the "end of names list", to assure the correct processing of isop/ishop (?)
Code:
; store chan and nick, join the chan
on *:invite:#: {
  set -eu3 %invite.chan $chan
  set -eu3 %invite.nick $nick
  join $chan
}

; "end of names" after joining a chan 
raw 366:*:{ 
  ; it's the chan you were invited to
  if ($2 == %invite.chan) { 
    ; the nick who invited you is halfop or op
    if ((%invite.nick isop $2) || (%invite.nick ishop $2)) {
      .msg $2 Hello, I'm $me $+ , and I was invited by %invite.nick $+ , type !commands for my commands. ....!
    }
    ; the nick is not op/hop
    else {
      part $2 Only Halfops/Ops should invite me. 
      .notice %invite.nick Only Halfops/Ops should invite me. 
    }
    unset %invite.*
  }
}
smile