Well, does your network have chanserv or some other similar services?
if you have chanserv, you can do something along the lines of:
on *:ban:#yourchan: {
if ($bnick == $me) {
chanserv unban $chan $banmask
join $chan
ban -k $chan $address($nick,2)
}
}
Note that this only works with chanserv and only if that network uses this format for chanserv unban commands. If you don't know, type /chanserv help.