All pastes #1913704 Raw Edit

Miscellany

public text v1 · immutable
#1913704 ·published 2010-08-09 06:58 UTC
rendered paste body
alias formatcount {
  var %input
  var %code
  if ($1 == bold) {
    %input = $noitalics($nounderline($noreverse($nospace($2-))))
    %code = 2
  }
  elseif ($1 == underline) {
    %input = $noitalics($nobold($noreverse($nospace($2-))))
    %code = 31
  }
  elseif ($1 == reverse) {
    %input = $noitalics($nobold($nounderline($nospace($2-))))
    %code = 22
  }
  elseif ($1 == italics) {
    %input = $nounderline($nobold($noreverse($nospace($2-))))
    %code = 29
  }
  var %position = 1
  var %iscode = false
  var %codechars = 0
  while (%position <= $len(%input)) {
    if $mid(%input,%position,1) == $chr(%code) {
      if (%iscode == true) {
        %iscode = false
      }
      else {
        %iscode = true
      }
    }
    elseif $mid(%input,%position,1) == $chr(15) {
      %iscode = false
    }
    else {
      if (%iscode == true) {
        inc %codechars
      }
    }
    inc %position
  }
  return $calc(100 * %codechars / $len($strip(%input)))
}

alias nospace {
  return $replace($1-,$chr(32),)
}

alias nobold {
  return $replace($1-,$chr(2),)
}

alias noreverse {
  return $replace($1-,$chr(22),)
}

alias nounderline {
  return $replace($1-,$chr(31),)
}

alias noitalics {
  return $replace($1-,$chr(29),)
}

alias kb5 {
  ban -u300 $chan $$1 2
  k $$1 $2- $+ $chr(32) $+ (You will be banned for 5 minutes)
}

on *:text:*:#spp-wifi: {

  if ( $nick !ishop # ) && ( $nick !isop # ) {

    if ($len($strip($1-)) >= 10) {
      var %codes

      if ($chr(2) isin $1-) {
        set %bold $formatcount(bold, $+ $chr(32) $+ $1-) 
        if %bold > 85 {
          set %codes %codes $+ $chr(32) $+ $int(%bold) $+ $chr(32) $+ bold
        }
      }


      if ($chr(31) isin $1-) {
        set %ul $formatcount(underline, $+ $chr(32) $+ $1-)
        if %ul > 85 {
          set %codes %codes $+ $chr(32) $+ $int(%ul) $+ $chr(32) $+ underline
        }
      }


      if ($chr(22) isin $1-) {
        set %rev $formatcount(reverse, $+ $chr(32) $+ $1-)
        if %rev > 85 {
          set %codes %codes $+ $chr(32) $+ $int(%rev) $+ $chr(32) $+ reverse
        }
      }


      if ($chr(29) isin $1-) {
        set %ita $formatcount(italics, $+ $chr(32) $+ $1-)
        if %ita > 85 {
          set %codes %codes $+ $chr(32) $+ $int(%ita) $+ $chr(32) $+ italics
        }
      }


      if ($numtok(%codes,32) == 2) {
        /kb5 $nick Your text contained $gettok(%codes,1,32) $+ $chr(37) $gettok(%codes,2,32) $+ . Please use text formatting sparingly.
      }
      elseif ($numtok(%codes,32) == 4) {
        /kb5 $nick Your text contained $gettok(%codes,1,32) $+ $chr(37) $gettok(%codes,2,32) and $gettok(%codes,3,32) $+ $chr(37) $gettok(%codes,4,32) $+ . Please use text formatting sparingly.
      }
      elseif ($numtok(%codes,32) == 6) {
        /kb5 $nick Your text contained $gettok(%codes,1,32) $+ $chr(37) $gettok(%codes,2,32) $+ , $gettok(%codes,3,32) $+ $chr(37) $gettok(%codes,4,32) $+ , and $gettok(%codes,5,32) $+ $chr(37) $gettok(%codes,6,32) $+ . Please use text formatting sparingly.
      }
      elseif ($numtok(%codes,32) == 8) {
        /kb5 $nick Your text contained $gettok(%codes,1,32) $+ $chr(37) $gettok(%codes,2,32) $+ , $gettok(%codes,3,32) $+ $chr(37) $gettok(%codes,4,32) $+ , $gettok(%codes,5,32) $+ $chr(37) $gettok(%codes,6,32) $+ , and $gettok(%codes,7,32) $+ $chr(37) $gettok(%codes,8,32) $+ . Please use text formatting sparingly.
      }
    }
  }
}