All pastes #813303 Raw Edit

Cameron

public text v1 · immutable
·published 2007-12-12 13:02 UTC
rendered paste body
alias throttled {
  var %f $hget(IRCHelpFlood,0).item
  while (%f) {
    var %a $sorttok($regsubex($hget(IRCHelpFlood,$hget(IRCHelpFlood,%f).item),/[^a-zA-Z0-9\s]/Sig,),32),%c,%b $numtok(%a,32)
    while (%b) {
      if ($count(%a,$gettok(%a,%b,32),32) > 1) var %a $remtok(%a,$gettok(%a,%b,32),$v1,32)
      dec %b
    }
    var %b $numtok(%a,32)
    while (%b) {
      if ($+(*,$gettok(%a,%b,32),*) iswm $1-) inc %c
      dec %b
    }
    if ($calc(%c / $numtok(%a,32) * 100) > 66) {
      echo -a $+($chr(3),$color(info),* Error: Message Throttled)
      return $true
    }
    dec %f
  }
}

on *:text:*:#irchelp: {
  if (!$hget(IRCHelpFlood)) hmake IRCHelpFlood
  if (/ isin $1-) hadd -u10 IRCHelpFlood $ticks $1-
}
on *:input:#irchelp: {
  if ($throttled($1-)) halt
}