$nick(#ChannelName,Nick).idle gives the time idle in that channel. Each time they do something in that channel it resets to zero, but does not change the idle time for any other channels you share with them. If YOU /hop that channel, it also resets everyone else's idle time to zero.
You can set a timer which activates every 60 seconds calling an alias.
Note that
var %i $nick(#channelname,0,a,vr)
isn't the same as
var %i $nick(#channelname,0,oh)
because it's possible to set someone with mode +ov
Also, if you have additional modes you wish to be exempted, you'll need to reflect them in your variable. For example, if superops are given prefix & and channel owner is given & or !, you probably want to exempt them. $nick seems to accept the mode as well as the prefix, which is needed because mode +a can give prefix & but for $nick "a" means all people in the channel.
var %i $nick(#channelname,0,ohq&!,q&!)
while (%i) {
if ($nick(#channelname,0,ohq&!,q&!).idle isnum 3600-) { var %n $nick(#channelname,0,ohq&!,q&!) | mode #channelname -oh #channelname %n %n }
dec %i
}
}
It's possible to make the code more efficient by combining nicks on the same row and eliminating references to modes not present, however different networks have different limits to how many modes can be set at the same time. Also, the odds are probably low that several nicks would reach the time limit within the same 1 minute. If you use mode -oh it will only display the modes someone has which can be taken away.
The part for giving their mode back to them can be a nightmare. If someone does /hop it can be handled by the normal method people are given status when they enter a channel. For people who do something within the channel to reset their idle time, are you going to want to use the official list of nicks for that channel, or also include people who might have been manually opped by another op?
If it's the latter, you'll need to keep track of all the status+nick combinations that the script has removed so it can give them back.
The nightmare part comes when people have scripts to protect themselves from having their op status taken away from them. If they have a script to ask chanserv to give their op status back to them when it's taken away, you could have a duel between the chanserv giving someone status and the bot taking it away 60 seconds later.
ON NICK
ON TEXT
ON ACTION
These will reset the idle, so you would want to trap them for giving status back. SOUND also reset idle, but you didn't say you wanted to give status back for that.