I use the following alias to join all the channels that I visited in my last session of IRC.

I use a ZNC and as IRC client (mIRC with IRcap).
Sometimes the ZNC disconnected from the IRC network and on reconnect, does not automatically join to all my channels at once, because I 'm in a lot of them and that generate lag.

The code:
Code:
/joinall {
  echo -s  Joining all channels.....
  var %counter = 1
  while (%counter <= $numtok(%recan,44)) {
    if ( $comchan($me,%counter) == $gettok(%recan,%counter,44)) { .timer 1 $calc(%counter + 3) echo -s  you already are in $comchan($me,%counter)
      inc %counter
    }
    else {
      .timer 1 $calc(%counter + 3) .msg chan invite  $gettok(%recan,%counter,44)
      inc %counter
    }
  }

}

Basically, the code works well, but when arriving in a channel that I am not, CHaN(official BoT Network also known as Chanserv) invites me and gives a "permission error". That is what I do not understand bearing in mind that I have got that level permission or even being the founder.
Look what the status window reports:
Quote:
juanam you already are in #channel1
juanam you already are in #channel2
juanam you already are in #channel3
juanam you already are in #channel4
= > CHaN invites you to #channel5 (Double click on the channel to join)
CHaN Permission denied!
= > CHaN invites you to #channel6 (Double click on the channel to join)
- CHaN Permission denied!

Once the process arrives at that point (the error) it does not work anymore. It does not continue with the rest of channels that exists in the variable.
As you see in the copy of the window I pasted, CHaN does not allow me to join in channels 5 and 6 even having the level enough to get in (otherwise the invitation would never arrive).

So the question is: If I have the level enough and the invitation from the bot also arrives why appears this permissions error?
Additional data:
IRC network: irc.chathispano.com
web: www.chathispano.com

I will be grateful if anyone knows the error or network and know how to fix it.
regards