Idle OPs Check

By SplitFire on Jan 15, 2011

Idle OPs checking alias.
Usage: /icheck
Will mass -o+v all OPs with idletime or more

:-- Idle OPs check
:-- by SplitFire
:-- Usage: /icheck <minutes>
:-- will mass -o+v all OPs with idletime <minutes> or more

alias icheck {
  if (!$1) || ($1 !isnum) { echo $color(ctcp) -ai2 * /icheck: invalid format | halt }
  if ($active !ischan) { echo $color(ctcp) -ai2 * /icheck: Use in channel only | halt }
  if ($me !isop #) { echo $color(ctcp) -ai2 * /icheck: You need OP status | halt }

  var %x 1, %idlers, %idletime $calc($1 * 60)
  while (%x <= $nick(#,0,o)) {
    if ($nick(#,%x,o).idle >= %idletime) && ($nick(#,%x,o) != $me) && ($me isop #) { %idlers = %idlers $nick(#,%x,o) }
    inc %x
  }
  if (%idlers) {
    if (%idlers) { 
      xmsg # Checking for Idle Ops ( $+ $calc(%idletime / 60) $+ + mins)
      if ($gettok(%idlers,0,32) <= $calc($modespl / 2)) { 
        .raw -q mode # - $+ $str(o,$gettok(%idlers,0,32)) $+ + $+ $str(v,$gettok(%idlers,0,32)) %idlers %idlers 
      }
      else { sfm %idlers }
    }
  }
}

alias sfm {
  var %loop = 1, %domodes, %donicks, %current
  ;If nicknames are given comma separated, change to spaces
  if ($chr(44) isin $$1-) tokenize 44 $1-
  ;Build list of modes
  var %modes = - $+ $str(o,$0) $+ + $+ $str(v,$0)
  ;Build list of nicknames with - and + placeholders so tokens line up with %modes
  var %nicks = - $1- + $1-
  ;Loop through modes to build final mode string
  while (%loop <= $len(%modes)) {
    ;If you hit a + or - remember it and add it to %domodes
    if ($mid(%modes,%loop,1) !isalpha)  {
      %current = $v1
      %domodes = %domodes $+ %current
    }
    ;Add another mode and the nickname it applies to
    else {
      %domodes = %domodes $+ $v1
      %donicks = %donicks $gettok(%nicks,%loop,32)
      ;If you hit $modespl do a /mode and reset the variables
      if ($numtok(%donicks,32) == $modespl) {
        mode $chan %domodes %donicks
        ;Make sure %domodes starts with the appropriate + or -
        %domodes = %current
        %donicks = $null
      }
    }
    inc %loop
  }
  ;If there's anything left, do one last /mode
  if (%donicks) mode $chan %domodes %donicks
}

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.