This script I don't know where to start. How would I got about unbanning the oldest X bans when the banlist becomes full?? (but leave them in the bot of course.)
Well, it's quite easy really. In your script, monitor new bans (MODE bind). Each time a ban is set, count the number of entries in the channel ban list (llength and chanbans). If it gets to within 5 of the maximum allowed, sort the bans by age (lsort), then unban the last 5 bans or so (for loop, putserv or killchanban).