All pastes #261475 Raw Edit

Untitled

public text v1 · immutable
#261475 ·published 2006-11-29 14:03 UTC
rendered paste body
on $*:text:/^[!@]price(s|check)*/Si:#: {
  IF ($gettok(%noprices,$chan,42)) halt
  if (($istok(on off,$2,32)) && ($nick isop $chan)) {
    if (($2 == on) && ($istok(%noprices,$chan,42)) {
      notice $nick Price Guide now ON for $chan
      %noprices = $remtok(%noprices,$chan,1,42)
    }
    elseif (($2 == off) && (!$istok(%noprices,$chan,42)) {
      notice $nick Price Guide now OFF for $chan
      %noprices = $addtok(%noprices,$chan,42)
    }
  }
  if ( !$2 ) { notice $nick Sorry you must specify what to search for - !price <item> } 
  else { 
    /var %number 1 
    while ($sock(price.socket. $+ %number)) { /inc %number } 
    if (!* iswm $1) { /set %price.displaystyle. [ $+ [ %number ] ] private } 
    /set %price.item. [ $+ [ %number ] ] $2- 
    /set %price.nick. [ $+ [ %number ] ] $nick 
    /set %price.chan. [ $+ [ %number ] ] $chan 
    /sockopen $+(price.socket.,%number) zybez.net 80 
  } ;Closes Else 
} ;Ends the !pricecheck section 

on *:sockopen:price.socket.*:{ 
  sockwrite -nt $sockname GET /priceguide.php?search_terms= $+ $replace(%price.item. [ $+ [ $right($SockName,-13) ] ] ,$chr(32),$chr(43)) $+ &search_area=1&price_low=&price_high=&member=1 HTTP/1.1 
  sockwrite -nt $sockname Host: zybez.net 
  sockwrite -nt $sockname $crlf $crlf 
} 

on *:sockread:price.socket.*:{ 
  var %i $right($sockname,-13) 
  if ($sockerr) { /notice %price.nick. [ $+ [ %i ] ] Sorry but an error occured while searching for %price.item. [ $+ [ %i ] ] | halt } 
  else { 
    var %temptext 
    sockread %temptext 
    ;Once bot gets the Item + Price which is represented my %readnextline == 2, it runs this to display the results for the user then restarts the whole proccess. 

    if (%readnextline == 2) { 
      /inc %price.displayed. [ $+ [ %i ] ] 
      /var %price.displayprice $htmlfree(%temptext) 
      /var %message %price.displayitem. [ $+ [ %i ] ] - %price.displayprice 
      /unset %readnextline 

      ; Limits how many items are displayed before it stops reading. Prevents the bot from flooding. 
      if ( %price.displayed. [ $+ [ %i ] ] < 6 ) { 
        if ( %price.displaystyle. [ $+ [ %i ] ] == private ) { /notice %price.nick. [ $+ [ %i ] ] %message } 
        else { /msg %price.chan. [ $+ [ %i ] ] %message } 
      } ; Closes if statement - if ( %price.displayed. [ $+ [ %i ] ] < 6 ) 
      else { /notice %price.nick. [ $+ [ %i ] ] Sorry but your search for " $+ %price.item. [ $+ [ %i ] ] $+ " was not specific enough. Please narrow your searh down, ie: Rune --> Rune Platelegs | /sockclose $+(price.socket.,%i) | /unset %price.*. [ $+ [ %i ] ] }  
    } ; Closes if statement - if (%readnextline == 2) 

    if (%readnextline == 1) { /set %price.displayitem. [ $+ [ %i ] ] $htmlfree(%temptext) | /set %readnextline 2 } 
    if ( *<img src="/img/member.gif"* iswm %temptext || <td class="tablebottom"><!-- Blank --></td> isin %temptext $&
      || Zybez is screwing up our parser because we don't credit them. ^_^</td> isin %temptext || <td class="tablebottom">http://www.zybez.net</td> --> isin %temptext</td> isin %temptext) { /set %readnextline 1 } 
    if (*Your search did not * iswm %temptext) { /notice %price.nick. [ $+ [ %i ] ] Sorry I did not find " $+ %price.item. [ $+ [ %i ] ] $+ " in the Zybez database. Please make sure you spelled everything correctly and the item you are searching for exists in Runescape. } 
  } ; Closes else 
} ;Ends the sockread section 

on *:sockclose:price.socket.*:{ /unset %price.*. [ $+ [ $right($SockName,-13) ] ] } 

alias -l htmlfree { 
  ; Cleans all html from a file 
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;) 
  return %x 
} ;Ends the html cleaner alias