All pastes #347707 Raw Edit

Something

public text v1 · immutable
·published 2007-02-09 16:49 UTC
rendered paste body
alias c1 { return 4 $+( $4-,) } 
alias c2 { return 6 $+( $6-,) } 


on $*:TEXT:/^[@,!]price/Si:#:{ 
  if (!$2) { 
    notice $nick *** 6 [Price Guide]: 4 You must supply a item - !price <item> 
    halt 
  } 
  else { 
    inc %q 
    inc %time.price 
    set %price.item. [ $+ [ %q ] ] $replace($2-,$chr(32),$chr(37) $+ 20) 
    set %price.style. [ $+ [ %q ] ] $iif($left($1,1) == @,msg $chan,notice $nick) 4 *** 6 [Price Guide]4 : 
    set %price.real. [ $+ [ %q ] ] $2- 
    sockopen price. $+ %q zybez.net 80 
  } 
} 
on *:SOCKOPEN:price.*:{ 
  sockwrite -nt $sockname GET /priceguide.php?search_terms= $+ %price.item. [ $+ [ %q ] ] $+ &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 %style = %price.style. [ $+ [ %q ] ], %item = %price.item. [ $+ [ %q ] ], %real = %price.real. [ $+ [ %q ] ] 
  if ($sockerr) { 
    %style An error occured while connecting 
    clean.up %q 
    sockclose $sockname 
    return 
    halt 
  } 
  else { 
    var %read 
    sockread %read 

    if (<td class="tablebottom" colspan="5">Your search did not return any results. Please make sure your spelling is correct and that you are typing full words.</td> isin %read) { 
      %style No results were found for " $+ %real $+ " 
      clean.up %q 
      sockclose $sockname 
      return 
      halt 
    } 
    elseif (<!--name--><td class='tablebottom'>*</td> iswm %read) { 
      tokenize 32 $nohtml(%read) 
      set %price.name. [ $+ [ %q ] ] $1- 
    } 
    elseif (<!--price--><td class="tablebottom">*</td> iswm %read) { 
      tokenize 32 $nohtml(%read) 
      set %price.price. [ $+ [ %q ] ] $1- 
    } 
    elseif (<td class="tablebottom"><a href="/priceguide.php?category=*">*</a></td> iswm %read) { 
      tokenize 32 $nohtml(%read) 
      set %price.cat. [ $+ [ %q ] ] $1- 
    } 
    if (%price.name. [ $+ [ %q ] ] && %price.price. [ $+ [ %q ] ] && %price.cat. [ $+ [ %q ] ]) { 
      inc %price.times. [ $+ [ %q ] ] 
      if (%price.times. [ $+ [ %q ] ] > 5) { 
        %style Max results of 5 allowed. Try making your search for " $+ %real $+ " more specific. 
        clean.up %q 
        sockclose $sockname 
        return 
        halt 
      } 
      elseif (%price.times. [ $+ [ %q ] ] < 5 || %price.times. [ $+ [ %q ] ] == 5) { 
        %style Item - %price.name. [ $+ [ %q ] ] $& 
          Price - %price.price. [ $+ [ %q ] ] $& 
          Category - %price.cat. [ $+ [ %q ] ] $& 
          Served - %time.price 
        unset %price.name. [ $+ [ %q ] ] 
        unset %price.price. [ $+ [ %q ] ] 
        unset %price.cat. [ $+ [ %q ] ] 
      } 
    } 
    if (</html> isin %read) { 
      clean.up %q 
      sockclose $sockname 
      return 
      halt 
    } 
  } 
} 
on *:SOCKCLOSE:price.*:{ 
  unset %price.* 
  halt 
} 
alias -l clean.up { 
  unset %price.*. [ $+ [ $1 ] ] 
  sockclose price. $+ $1 
  halt 
} 
alias -l nohtml { 
  var %x,%i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x) 
  %x = $replace(%x,&nbsp;,$null) 
  return %x 
}