All pastes #463174 Raw Edit

price script

public text v1 · immutable
#463174 ·published 2007-04-28 20:22 UTC
rendered paste body
alias priceconfig {
  echo -a * *********************************
  echo -a * To set price options use the following commands:
  echo -a * /priceall <on $+ $chr(124) $+ off> - Allows the use of the "all" trigger.  (.price -a rune set returns rune (g) set, rune (t) set, and rune set.)  Default is off due to flooding issues.
  echo -a * /pricecolor <color4 color11 color5> - Sets colors of the output text.  Default is 14 07 15 (looks like: 14Santa Hat:07 25,000,000gp |15 zybez.net)
  echo -a * *********************************
}
alias priceall {
  if ($1 == on) { set %priceall on | echo -a * Price All is now set to "on" | return Price All = On }
  elseif ($1 == off) { set %priceall off | echo -a * Price All is now set to "off" | return Price All = Off }
  else { echo -a * Invalid Syntax.  Either /priceall on or /priceall off. | return Invalid Syntax }
}
alias pricecolor {
  if ($len($1) == 2) && ($len($2) == 2) && ($len($3) == 2) && ($1 isnum) && ($2 isnum) && ($3 isnum) && ($1 <= 5) && ($2 <= 4) && ($3 <= 5) {
    set %c1 $1 | set %c2 $2 | set %c3 $3
    echo -a * Colors Set.  Output will now look like below:
    echo -a *  $+ %c1 Santa Hat: $+ %c2 25,000,000gp $chr(124) $+  $+ %c3 zybez.net
  }
  else { 
    echo -a * Invalid color selection.  Please use two digit color codes from 01 to 15.
  }
}
;Do not change priceappend.  Zybez will break the script again if you do.  Feel free to shorten it, but give credit to zybez ALWAYS.
;if it breaks again because of this, I wont release a new update.
alias priceappend {
  return $+(,%c3,,http://zybez.net)
}

on *:TEXT:.price*:#: {
  if (%price.busy != $null) { .notice $nick 3[14RannServ3] Sorry but %price.busy is already using this command... please wait 3 seconds and try again. | halt }
  set -u3 %price.busy $nick
  write -c pricedownload.txt
  if ($2 == -a) { 
    set %priceflag $2 
    set %rs.item $replace($3-,$chr(32),$chr(43))
  }
  else {
    set %rs.item $replace($2-,$chr(32),$chr(43))
  }
  set %pricenick $nick
  set %msg.type private
  price
}
on *:TEXT:.pprice*:#: {
  if (%price.busy != $null) { .notice $nick 3[14RannServ3] Sorry but %price.busy is already using this command... please wait 3 seconds and try again. | halt }
  set -u3 %price.busy $nick
  write -c pricedownload.txt
  if ($2 == -a) { 
    set %priceflag $2 
    set %rs.item $replace($3-,$chr(32),$chr(43))
  }
  else {
    set %rs.item $replace($2-,$chr(32),$chr(43))
  }
  set %pricechannel $chan
  set %pricenick $nick
  set %msg.type public
  price
}
alias pricemsg {
  if (%priceall == on) && (%priceflag == -a) {
    var %itemnamecount 1
    var %pricecount 2
    while ($read(pricedownload.txt,1)) {
      var %itemname $read(pricedownload.txt,1))
      var %price $read(pricedownload.txt,2)
      var %output  $+ %c1 $+ %itemname $+ : $+ %c2 %price $+  %type $chr(124) $+  $+ %c3 $priceappend
      if (spelling isin $read(pricedownload.txt,1)) { notice %pricenick 07Your search did not return any results. Please make sure your spelling is correct and that you are typing full words. | halt  }
      if (%msg.type == private) { notice %pricenick 3[14RannServ3] %output }  
      elseif (%msg.type == public) { msg %pricechannel 3[14RannServ3] %output }
      else { msg %pricechannel Error.  Please eat a sock. }
      write -dl 1 pricedownload.txt
      write -dl 1 pricedownload.txt
    }
  }
  else {
    var %itemname $read(pricedownload.txt,1)
    var %price $read(pricedownload.txt,2)
    var %output  $+ %c1 $+ %itemname $+ : $+ %c2 %price $+  %type $chr(124) $+  $+ %c3 $priceappend
    if (spelling isin $read(pricedownload.txt,1)) { notice %pricenick 07Your search did not return any results. Please make sure your spelling is correct and that you are typing full words. | halt  }
    if (%msg.type == private) { notice %pricenick 3[14RannServ3] %output }  
    elseif (%msg.type == public) { msg %pricechannel 3[14RannServ3] %output }
    else { msg %pricechannel Error.  Please eat a sock. }
  }
  unset %priceflag
}
alias price sockclose price | sockopen price zybez.net 80
on *:sockopen:price:{ 
  sockwrite -n $sockname GET /priceguide.php?search_terms= $+ %rs.item $+ &search_area=1&price_low=&price_high=&member=1&Search HTTP/1.1
  sockwrite -n $sockname Host: www.zybez.net $+ $crlf $+ $crlf
}
on *:sockread:price:{ 
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    sockread %temp 
    if ($regex(%temp,/^<!--name/)) || ($regex(%temp,/^<!--price/)) {
      write pricedownload.txt $htmlfree($replace(%temp,&amp $+ $chr(59),&))
      timerSOCKET 1 1 pricemsg
    }
  }
}
on *:sockclose:price:{
}