/mode # b

So, what's the difference?

PS: irc opers can join channels even if they are banned/invite only, so this script might fail at such an occasion. Also if services like chanserv keep a banlist separate from the channel banlist, then those won't be detected, there's probably a /cs banlist command for those to parse...