All pastes #940125 Raw Edit

stats

public text v1 · immutable
·published 2008-03-12 19:53 UTC
rendered paste body
on *:START: { 
  if (!hget(current)) hmake current 20 
  if (!hget(record)) hmake record 20 
  if (!$hget(transferred)) hmake transferred 20 
  if (!$hget(packs)) hmake packs 20 
  if (!$hget(slotsopen)) hmake slotsopen 20 
  if (!$hget(slotstotal)) hmake slotstotal 20 
  if ($exists(current1.hsh)) hload -b current current1.hsh 
  if ($exists(record1.hsh)) hload -b record record1.hsh 
  if ($exists(transferred1.hsh)) hload -b transferred transferred1.hsh 
  if ($exists(packs1.hsh)) hload -b packs packs1.hsh 
  if ($exists(slotsopen1.hsh)) hload -b slotsopen slotsopen1.hsh 
  if ($exists(slotstotal1.hsh)) hload -b slotstotal slotstotal1.hsh 
} 
on *:exit: { 
  hsave -bo current current1.hsh 
  hsave -bo record record1.hsh 
  hsave -bo transferred transferred1.hsh 
  hsave -bo packs packs1.hsh 
  hsave -bo slotsopen slotsopen1.hsh 
  hsave -bo slotstotal slotstotal1.hsh  
} 
on *:text:*:#absolute-chat, #absolute-movies: { 
  tokenize 32 $strip($1-) 
  if ($regex(speed,$1-,/\*\* Bandwidth Usage \*\* Current: (\d+\.?\d+)(KB|MB|GB)\/s.*Record: (\d+\.?\d+)(KB|MB|GB)\/s/i)) { 
    hadd -m current $nick $tobytes($regml(speed,1),$regml(speed,2)) 
    hadd -m record $nick $tobytes($regml(speed,3),$regml(speed,4)) 
  } 
  if ($regex(trans,$1-,/(?:Total Offered: \d+\.?\d* (?:kb|mb|gb|tb) )?Total Transferred: (\d+\.?\d*) ?(kb|mb|gb|tb)/i)) { 
    hadd -m transferred $nick $tobytes($regml(trans,1),$regml(trans,2)) 
  } 
  if ($regex(packs,$1-,/\*\* (\d+) packs? \*\* (\d+) of (\d+) slots? open.*/)) { 
    hadd -m packs $nick $regml(packs,1) 
    hadd -m slotsopen $nick $regml(packs,2) 
    hadd -m slotstotal $nick $regml(packs,3) 
  } 
  if ( $1 == !stats ) { 
    msg $chan 10[14#Absolute-Movies Stats10]
    msg $chan 10[14Servers 0nline: $botsonline 10] 
    msg $chan 10[14Total Packs: $packs 10]
    msg $chan 10[14Slots Open $slotsopen 10] 
    msg $chan 10[14Total Slots: $slotstotal 10] 
    msg $chan 10[14Current Bandwidth: $currentspeed 10] 
    msg $chan 10[14Record Bandwidth: $recordspeed 10] 
    msg $chan 10[14Total Transferred: $transferred 10] 
    unset %current 
    unset %record 
    unset %transferred 
    unset %packs 
    unset %slotsopen 
    unset %slotstotal 
  } 
}  
on *:notice:*:*: { 
  if ($regex(speed,$1-,/\*\* Bandwidth Usage \*\* Current: (\d+\.?\d+)(KB|MB|GB)\/s.*Record: (\d+\.?\d+)(KB|MB|GB)\/s/i)) { 
    hadd -m current $nick $tobytes($regml(speed,1),$regml(speed,2)) 
    hadd -m record $nick $tobytes($regml(speed,3),$regml(speed,4)) 
  } 
  if ($regex(trans,$1-,/(?:Total Offered: \d+\.?\d* (?:kb|mb|gb|tb) )?Total Transferred: (\d+\.?\d*) (kb|mb|gb|tb)/i)) { 
    hadd -m transferred $nick $tobytes($regml(trans,1),$regml(trans,2)) 
  } 
} 
alias currentspeed { 
  var %x 1 
  while ( %x <= $hget(current,0).item ) { 
    If ( $hget(current,%x).item ison #absolute-movies ) { 
      if ( %current = $null ) { 
        set %current $hget(current,%x).data 
      } 
      else { 
        set %current $calc( %current + $hget(current,%x).data) 
      } 
    } 
    inc %x 
  } 
  return $+($bytes(%current).suf,/s) 
} 
alias recordspeed { 
  var %x 1 
  while ( %x <= $hget(record,0).item ) { 
    If ( $hget(record,%x).item ison #absolute-movies ) { 
      if ( %record = $null ) { 
        set %record $hget(record,%x).data 
      } 
      else { 
        set %record $calc( %record + $hget(record,%x).data) 
      } 
    } 
    inc %x 
  } 
  return $+($bytes(%record).suf,/s) 
} 
alias transferred { 
  var %x 1 
  while ( %x <= $hget(transferred,0).item ) { 
    If ( $hget(transferred,%x).item ison #absolute-movies ) { 
      if ( %transferred = $null ) { 
        set %transferred $hget(transferred,%x).data 
      } 
      else { 
        set %transferred $calc( %transferred + $hget(transferred,%x).data) 
      } 
    } 
    inc %x 
  } 
  return $bytes(%transferred).suf 
} 
alias botsonline { 
  if ( $nick(#absolute-movies,0,v,ohr) >= $hget(packs,0).item ) { 
    return $hget(packs,0).item 
  } 
  else { 
    return $nick(#absolute-movies,0,v,ohr) 
  } 
} 
alias packs { 
  var %x 1 
  while ( %x <= $hget(packs,0).item ) { 
    If ( $hget(packs,%x).item ison #absolute-movies ) { 
      if ( %packs = $null ) { 
        set %packs $hget(packs,%x).data 
      } 
      else { 
        set %packs $calc( %packs + $hget(packs,%x).data) 
      } 
    } 
    inc %x 
  } 
  return %packs 
} 
alias slotsopen { 
  var %x 1 
  while ( %x <= $hget(slotsopen,0).item ) { 
    If ( $hget(slotsopen,%x).item ison #absolute-movies ) { 
      if ( %slotsopen = $null ) { 
        set %slotsopen $hget(slotsopen,%x).data 
      } 
      else { 
        set %slotsopen $calc( %slotsopen + $hget(slotsopen,%x).data) 
      } 
    } 
    inc %x 
  } 
  return %slotsopen 
} 
alias slotstotal { 
  var %x 1 
  while ( %x <= $hget(slotstotal,0).item ) { 
    If ( $hget(slotstotal,%x).item ison #absolute-movies ) { 
      if ( %slotstotal = $null ) { 
        set %slotstotal $hget(slotstotal,%x).data 
      } 
      else { 
        set %slotstotal $calc( %slotstotal + $hget(slotstotal,%x).data) 
      } 
    } 
    inc %x 
  } 
  return %slotstotal 
} 
alias xlist { 
  var %x 1 
  while ( %x <= $nick(#absolute-movies,0,v,ohr) ) { 
    .msg $nick(#absolute-movies,%x,v,ohr) xdcc list 
    inc %x 
  } 
}
alias tobytes { 
  if ($2 == kb) return $calc($1 * 1024) 
  if ($2 == mb) return $calc($1 * 1048576) 
  if ($2 == gb) return $calc($1 * 1073741824) 
  if ($2 == tb) return $calc($1 * 1099511627776)