I use a dynamic system that is refreshed in the perform settings on connection. twitchclient 2 has to be set.

/raw twitchclient 2

in the perform I have /msg [your channel name here] .mods

Then this remote captures it and sets the mod table.

on *:text:The moderators of this room are*:?:{
if ($nick != jtv) return
/hfree ops
/hmake ops
/hadd -m ops [put your Broadcaster name here] $ctime
/var %count = $numtok($remove( $7- , $chr(32) ) , 44)
var %i = 1
while (%i <= %count) {
hadd -m ops $gettok($remove( $7- , $chr(32) ) ,%i,44) $ctime
inc %i
}
echo -a The number of ops is %count
}

If a mod is added the bot can be refreshed at any time by restarting or typing .mod in the channel window on the bot.

Once you have the function running, you can stop any function if the user is not an op by using the following command.

if !$hget(ops,$nick) { /halt }

Tested and working in a channel with 87 mods.