All pastes #132397 Raw Edit

Mine

public text v1 · immutable
#132397 ·published 2006-08-15 09:03 UTC
rendered paste body
;########################################################## 
;##            Multi Socket News Script                  ## 
;##             Coded by : A7u2s4t9i4n                   ## 
;## Uses multiple sockets so several users can use the   ## 
;## code at the same time. Also displays multiple        ## 
;## results from z3.invisionfree.com/Runescape_Blitz     ## 
;## Usage:                                               ## 
;## !rsb - Private                                       ## 
;## @rsb - Public                                        ## 
;########################################################## 

on *:text:/^[!@]rsb*/Si:#: { 
  else { 
    /var %number 1 
    while ($sock(rsb.socket. $+ %number)) { /inc %number } 
    if (!* iswm $1) { /set %rsb.displaystyle. [ $+ [ %number ] ] private } 
    /set %price.item. [ $+ [ %number ] ] $replace($2-,$chr(32),$chr(43)) 
    /set %price.nick. [ $+ [ %number ] ] $nick 
    /set %price.chan. [ $+ [ %number ] ] $chan 
    /sockopen $+(rsb.socket.,%number) http://z3.invisionfree.com/Runescape_Blitz 80 
  } ;Closes Else 
} ;Ends the !rsb section 

on *:sockopen:rsb.socket.*:{ 
  sockwrite -nt $sockname GET /Runescape_Blitz/index.php?showforum=16 / HTTP/1.1
  sockwrite -nt $sockname Host: z3.invisionfree.com
  sockwrite -nt $sockname $crlf $crlf 
} 

on *:sockread:rsb.socket.*:{ 
  var %i $right($sockname,-13) 
  if ($sockerr) { /notice %rsb.nick. [ $+ [ %i ] ] Sorry but an error occured while searching for rsb news. [ $+ [ %i ] ] | halt } 
  else { 
    var %temptext 
    sockread %temptext 
    ;Once bot gets the news it runs this to display the results for the user then restarts the whole proccess. 
    if (%readnextline == 2) { 
      /inc %rsb.displayed. [ $+ [ %i ] ] 
      /set %rsb.displayprice. [ $+ [ %i ] ] $htmlfree(%temptext) 
      /set %rsb.message. [ $+ [ %i ] ] %rsb.displayitem. [ $+ [ %i ] ] - %rsb.displayprice. [ $+ [ %i ] ] 
      /unset %readnext

      ; Limits how many items are displayed before it stops reading. Prevents the bot from flooding. 
      if ( %rsb.displayed. [ $+ [ %i ] ] < 6 ) { 
        if ( %rsb.displaystyle. [ $+ [ %i ] ] == private ) { /notice %rsb.nick. [ $+ [ %i ] ] %rsb.message. [ $+ [ %i ] ] } 
        else { /msg %price.chan. [ $+ [ %i ] ] %price.message. [ $+ [ %i ] ] } 
      } ; Closes if statement - if ( %rsb.displayed. [ $+ [ %i ] ] < 6 ) 
      else { /notice %rsb.nick. [ $+ [ %i ] ] Please search again | /sockclose $+(rsb.socket.,%i) | /unset %rsb.*. [ $+ [ %i ] ] }  
    } ; Closes if statement - if (%readnext == 2) 

    if (%readnext == 1) { /set %rsb.displayitem. [ $+ [ %i ] ] $htmlfree(%text) | /set %readnext 2 } 
    if ( <td class="tablebottom"><img src="/img/member.gif" alt="[M]"/></td> isin %text || <td class="tablebottom"><!-- Blank --></td> isin %text) { /set %readnext 1 } 
    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 %text) { /notice %rsb.nick. [ $+ [ %i ] ] Sorry I did not find what you were looking for. } 
  } ; Closes else 
} ;Ends the sockread section 

on *:sockclose:rsb.socket.*:{ /unset %rsb.*. [ $+ [ $right($sockname,-11) ] ] } 


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