All pastes #715239 Raw Edit

Someone

public text v1 · immutable
#715239 ·published 2007-09-26 03:44 UTC
rendered paste body
on $*:TEXT:/^[!@](cash|price(check)?|gold)/Si:#:{
  if (!$2) { notice $nick 3 *** [Price Guide]: You must supply a item -4 !price <item> }
  else {
    inc %id
    set $+(%,price.item.,%id) $replace($2-,$chr(32),$chr(37) $+ 20)
    set $+(%,price.style.,%id) $iif($left($1,1) == @,msg $chan,notice $nick) 3*** [Price Guide]:
    sockopen $+(price.,%id) zybez.net 80
  }
}
on *:SOCKOPEN:price.*:{
  var %id = $gettok($sockname,2,46)
  sockwrite -nt $sockname GET /priceguide.php?search_terms= $+ $($+(%,price.item.,%id),2) $+ &search_area=1&price_low=&price_high=&member=1 HTTP/1.1
  sockwrite -nt $sockname Host: www.zybez.net
  sockwrite -nt $sockname $+($crlf,$crlf)
}
on *:SOCKREAD:price.*:{
  var %id = $gettok($sockname,2,46)
  var %style = $($+(%,price.style.,%id),2), $&
    %item = $replace($($+(%,price.item.,%id),2),$chr(37) $+ 20,$chr(32))
  if ($sockerr) {
    %style An error occured while connecting
    unset $+(%,price.*)
    sockclose $+(price.,%id)
  }
  else {
    var %read
    sockread %read

    if (*<td class="tablebottom" colspan="5">3Your search did not return any results. Please make sure your spelling is correct and that you are typing full words.</td>* iswm %read) {
      %style No results were found for " $+ %item $+ "
      unset $+(%,price.*.,%id)
      sockclose $+(price.,%id)
    }
    if (*<!--name--><td class='tablebottom'>*</td>* iswm %read) {
      tokenize 32 $nohtml(%read)
      set $+(%,price.name.,%id) $1-
    }
    if (*<!--price--><td class="tablebottom">*</td>* iswm %read) {
      tokenize 32 $nohtml(%read)
      set $+(%,price.price.,%id) $1-
    }
    if (*<td class="tablebottom"><a href="/priceguide.php?category=*">*</a></td>* iswm %read) {
      tokenize 32 $nohtml(%read)
      inc $+(%,price.times.,%id)
      if ($($+(%,price.times.,%id),2) > 5 && !$($+(%,price.stop.,%id),2)) {
        %style 3 Max results of 5 allowed. Try making your search for4 " $+ %item $+ "3 more specific.
        unset $+(%,price.*.,%id)
        set $+(%,price.stop.,%id) true
        sockclose $+(price.,%id)
      }
      elseif ($($+(%,price.times.,%id),2) <= 5) {
        %style Item - $($+(%,price.name.,%id),2) $&
          Price - $($+(%,price.price.,%id),2) $&
          Category - $1-
        unset $+(%,price.name.,%id)
        unset $+(%,price.price.,%id)
      }
    }
    if (*</html>* iswm %read) {
      unset $+(%,price.*.,%id)
      sockclose $+(price.,%id)
    }
  }
}

alias -l nohtml {
  var %x,%i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x)
  %x = $replace(%x,&nbsp;,$null)
  return %x
}