March 24, 2004

Power check

A self-serving alias more than an useful one, but I was bored and wanted to try and script something like this. :)
This alias, when you type /power, will display the amount of channels you have ops, halfops, voice, or are a regular user in across all channels and networks you are in, as well as calculate how many channels and users you have power on.
If you type it in a channel or message window, it will message the results to that channel or message window; if you type it anywhere else (status window, custom window) it will echo the results to the active window.
Sample output:

<sailoreagle> Power: I am opped in 7, voiced in 1, regular in 1 out of 9 channels over 2 networks. This means I have power over 77.8% channels, which is 28/46 (60.9%) users.

Goes in remotes.

alias power {
  var %conns = $scon(0)
  while (%conns) {
    scon %conns
    var %c = $chan(0)
    inc %power.total $chan(0)
    while (%c) {
      inc %power.totalusers $nick($chan(%c),0)
      if ($me isop $chan(%c)) {
        inc %power.oppedchans
        inc %power.users $nick($chan(%c),0)
      }
      elseif ($me ishop $chan(%c)) { inc %power.halfopchans }
      elseif ($me isvoice $chan(%c)) { inc %power.voicechans }
      else { inc %power.regchans }
      dec %c
    }
    dec %conns
  }
  if ($active != Status Window) && (@ !isin $active) {
    msg $active Power: I am $iif(%power.oppedchans,opped in $+(%power.oppedchans,$chr(44))) $iif(%power.halfopchans,halfopped in $+(%power.halfopchans,$chr(44))) $iif(%power.voicechans,voiced in $+(%power.voicechans,$chr(44))) $iif(%power.regchans,regular in %power.regchans) out of %power.total channels over $scon(0) networks. This means I have power over $round($calc((%power.oppedchans / %power.total) * 100),1) $+ % channels, which is $+(%power.users,/,%power.totalusers) ( $+ $round($calc((%power.users / %power.totalusers) * 100),1) $+ % $+ ) users.
  }
  else {
    echo $color(info) -ta * Power: I am $iif(%power.oppedchans,opped in $+(%power.oppedchans,$chr(44))) $iif(%power.halfopchans,halfopped in $+(%power.halfopchans,$chr(44))) $iif(%power.voicechans,voiced in $+(%power.voicechans,$chr(44))) $iif(%power.regchans,regular in %power.regchans) out of %power.total channels over $scon(0) networks. This means I have power over $round($calc((%power.oppedchans / %power.total) * 100),1) $+ % channels, which is $+(%power.users,/,%power.totalusers) ( $+ $round($calc((%power.users / %power.totalusers) * 100),1) $+ % $+ ) users.
  }
  unset %power.*
}
Posted by sailoreagle at 07:16 PM | Comments (3) | Scripts