If you also have chanserv, then try checking
/msg chanserv help aop
/msg chanserv help sop

If these options are available, they'll work better than a script