All pastes #236496 Raw Edit

Stuff

public text v1 · immutable
·published 2006-11-03 20:48 UTC
rendered paste body
;Written by [FtUC]Hydro
alias qbash {
  set %qbash.chan $1
  set -z %bash.flood 6
  if $2 { set %qbash.qnum $2 }
  sockopen qbash www.bash.org 80
}
on *:sockopen:qbash:{
  var %a = sockwrite -tn $sockname
  %a GET $iif(!%qbash.qnum,/?random1,/?quote= $+ %qbash.qnum) HTTP/1.1
  %a Host: www.bash.org
  %a Keep-Alive: 300
  %a Connection: keep-alive
  %a Referer: http://www.bash.org/
  %a 
}
on *:sockread:qbash:{
  var %read
  sockread %read
  while $sockbr {
    if $regex(%read,/(Quote #\d+? was rejected\.)/) {
      msg %qbash.chan  $+ $regml(1)
      sockclose qbash
      unset %qbash.*
      break
    }
    elseif $regex(%read,/(Quote #\d+? does not exist\.)/) {
      msg %qbash.chan  $+ $regml(1)
      sockclose qbash
      unset %qbash.*
      break
    }
    elseif $regex(%read,/<p class="qt">/) {
      set %qbash.found $true
      set %qbash.counter 0
    }
    if %qbash.found { 
      var %temp = $striphtml(%read).160
      %temp = $striphtml_entities(%temp).160
      noop $regex(%temp,/^(?:(#\d+?) \+\(\d+\)- \[X\])?(.+?)$/)
      .timer 1 %qbash.counter msg %qbash.chan $iif($regml(0) == 2,$+($chr(2),Quote $regml(1),$chr(2),:) $regml(2),$regml(1))
      inc %qbash.counter
    }
    if %qbash.found && $regex(%read,/<\/p>$/) {
      sockclose qbash
      unset %qbash.*
      break
    }
    sockread %read
  }
}

on *:text:!bash*:#:{
  if $1 == !bash && ($network == mIRCx || #[FtUC]* iswm $chan) && !%bash.flood {
    qbash $chan $iif($2 isnum,$2)
  }
}

; # .:[ dJabba's $striphtml version 0.5 ]:. #
; Modified by [FtUC]Hydro
alias -l striphtml {
  if $isid && $1 {
    var %H = $1 , %T = $regsub(%H,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,,%H)
    return %H
  }
}
alias striphtml_entities {
  var %H = $1
  var %H = $replace(%H,&quot;,",&lt;,<,&gt;,>,&euro;,&#8364;,&nbsp;,$iif($prop,$chr($prop),$chr(32)),&acute;,´)
  var %H = $replace(%H,&brvbar;,¦,&cedil;,¸,&cent;,¢,&circ;,&#710;,&copy;,©,&deg;,°)
  var %H = $replace(%H,&divide;,÷,&Euro;,&#8364;,&fnof;,&#402;,&frac12;,½,&frac14;,¼)
  var %H = $replace(%H,&frac34;,¾,&iexcl;,¡,&iquest;,¿,&laquo;,«,&macr;,¯,&micro;,µ,&middot;,·)
  var %H = $replace(%H,&not;,¬)
  var %H = $replace(%H,&para;,¶,&plusmn;,±,&pound;,£,&raquo;,»,&reg;,®,&sect;,§,&shy;,,&sup1;,¹,&sup2;,²)
  var %H = $replace(%H,&sup3;,³,&tilde;,&#732;,&times;,×,&uml;,¨)
  var %H = $replace(%H,&yen;,¥)
  var %H = $replace(%H,&rsquo;,&#8217;,&sbquo;,&#8218;,&ldquo;,&#8220;,&rdquo;,&#8221;,&bdquo;,&#8222;,&lsaquo;,&#8249;,&rsaquo;,&#8250;,&dagger;,&#8224;,&Dagger;,&#8225;,&permil;,&#8240;,&bull;,&#8226;,&hellip;,&#8230;)
  var %H = $replace(%H,&image;,I,&real;,R,&trade;,&#8482;)
  var %H = $replace(%H,&minus;,-)
  var %H = $replace(%H,&amp;,&)
  return %H
}