All pastes #269901 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-12-06 22:20 UTC
rendered paste body
on *:LOAD: {
  echo -a 4RuneScape Price Checker Loaded
  echo -a 4To use the price checker either type /PriceCheck or go to Commands - RuneScape Price Checker
  echo -a 4Credits:
  echo -a 4[M]ike - Main design/coding.
  echo -a 4Slushpuppy - Price Parser
  echo -a 4Annie - Bug fixes, etc.
}
alias pricecheck {
  dialog -md price_check price_check
}
menu channel,menubar,status,nicklist {
  RuneScape Price Checker
  .Check Prices: pricecheck
}
dialog price_check {
  title "RuneScape Price Checker - By [M]ike"
  size -1 -1 198 113
  option dbu
  button "Search", 1, 155 6 37 12
  text "Item Name:", 2, 3 8 42 8
  edit "", 3, 48 7 104 10
  list 4, 3 28 188 67, size vsbar
  text "Thanks to slushpuppy for the price parser.", 5, 5 99 125 8
  text "", 6, 48 19 103 8
}
on *:DIALOG:price_check:sclick:1:{
  if (!$did(price_check,3).text) { 
    did -a $dname 6 Enter an item to search for...
  }

  else {
    set %search $did(price_check,3)
    set %price.item $replace(%search,$chr(32),+) 
    did -a $dname 6 Searching for " $+ %search $+ " - Please wait...
    var %price.read 
    var %price.readed
    sockopen rsprice slushpuppy.silverinterlocution.org 80
  } 
}
on *:SOCKOPEN:rsprice:{ 
  sockwrite -n $sockname GET $+(/price.php?price=,%price.item) HTTP/1.1 
  sockwrite -n $sockname Host: slushpuppy.silverinterlocution.org
  sockwrite -n $sockname $crlf
} 

on *:SOCKREAD:rsprice:{ 
  if ($sockerr) { did -a price_check 6 Socket Error | halt } 
  sockread %price.read

  while (%price.read) { sockread %price.read }

  while ($sockbr) {
    %price.readed = %price.readed $+ %price.read
    sockread -f %price.read
  }

  did -a price_check 4 $htmlfree($mid(%price.readed,3))
  did -a price_check 6 Search complete.
  unset %price.*
  sockclose rsprice
}

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