All pastes #122288 Raw Edit

Mine

public text v1 · immutable
·published 2006-08-08 16:07 UTC
rendered paste body
ALIAS -l c1 { RETURN $+($Chr(3),04,$1-,$Chr(3)) }

ALIAS -l RSW { RETURN $+($Chr(2),[,$c1(RS World Info),],$Chr(2),:) }

ON $*:TEXT:/^[!@.](World|RSWorld|Server|Serv)/Si:#:{
  IF (!$2) {
    .Notice $nick $RSW Syntax: $1 <Place/N> [-p2p|-f2p]
    .Notice $nick $RSW Where <Place/N> is, you can specify either a World Number or a Name, such as "Atlanta" to get info on ALL the Atlanta Servers.
    .Notice $nick $RSW Where [-p2p|-f2p] is, you can specify to return ONLY F2P or P2P servers.
    .Notice $nick $RSW Example: $1 Atlanta -p2p $Chr(124) This would return info on all the Atlanta P2P servers.
    Halt
  }
  ELSEIF (($2 isnum) && (($2 < 1) || ($2 > 132))) { .Notice $nick $RSW Server Number out of bounds. Valid Servers are 1-132. | Halt }
  VAR %s = 1
  WHILE ($Sock(RSW. $+ %s)) { Inc %s }
  SET $+(%,rsw.output.,%s) $iif($Left($1,1) == @ && $2 isnum,Msg $chan,.Notice $nick) $RSW
  SET $+(%,rsw.search.,%s) $iif($2 isnum,$2,$Remove($2-,-f2p,-p2p))
  IF (-p2p isin $2-) SET $+(%,rsw.type.,%s) Members
  ELSEIF (-f2p isin $2-) SET $+(%,rsw.type.,%s) Free
  SockOpen $+(RSW.,%s) thexx.6te.net 80
}

ON *:SOCKOPEN:RSW.*:{
  SockWrite -nt $SockName GET /sparse.php HTTP/1.1
  SockWrite -nt $SockName Host: thexx.6te.net
  SockWrite -nt $SockName $CrLf
}

ON *:SOCKREAD:RSW.*:{
  VAR %s = $Right($SockName,-4), %rsw, %search = $Eval($+(%,rsw.search.,%s),2), %output = $Eval($+(%,rsw.output.,%s),2), %stype = $Eval($+(%,rsw.type.,%s),2)
  IF ($SockErr > 0) { %output There was a Socket Error. Try again later. | SockClose $SockName | RETURN }
  :NextRead
  SockRead %rsw
  VAR %world = $GetTok(%rsw,2,32), %users = $GetTok(%rsw,3,32), %location = $GetTok(%rsw,$+($iif(%users == FULL,4-,5-),$Calc($NumTok(%rsw,32) - 1)),32), %type = $GetTok(%rsw,$NumTok(%rsw,32),32)
  IF (($SockBr == 0) || (%world !isnum)) { RETURN }
  IF ((%world == %search) || ($+(*,$Replace(%search,$Chr(32),*),*) iswm %location)) {
    IF ((%stype) && (%stype == %type)) %output World $c1(%world) is a $c1(%type) Server, Located in $c1(%location) and currently has $c1($Replace(%users,FULL,2000)) Players on it. $iif(%users == FULL,$c1(Server is Full.))
    ELSEIF (!%stype) %output World $c1(%world) is a $c1(%type) Server, Located in $c1(%location) and currently has $c1($Replace(%users,FULL,2000)) Players on it. $iif(%users == FULL,$c1(Server is Full.))
  }
  Goto NextRead
}

ON *:SOCKCLOSE:RSW.*:{ UnSet %rsw.*. [ $+ [ $Right($SockName,-4) ] ] }