Well I'm not going to read all that long code [censored] so I'm not sure how the format of saving the nick is but something like this will point you in the right direction
Code:
on *:join:#:{
var %i = 1
while (%i <= $ini(chanaoplist.db,0)) {
if ($readini(chanaoplist.db,%i) == $nick) mode $chan +o $nick
inc %i
}
}

hope that helps