All pastes #234864 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-11-02 21:21 UTC
rendered paste body
alias world {
  if ($1 !isnum 1-132) { 
    echo Invalid world.
  }
  else { 
    set %world $1
    sockopen worlds www.runescape.com 80
  }
}

on *:sockopen:Worlds:{
  sockwrite -nt $sockname GET /lang/en/aff/runescape/serverlist.ws
  sockwrite -nt $sockname Host: www.runescape.com $+ $crlf $+ $crlf
}

on *:sockread:Worlds:{
  if ($sockerr) { 
    echo Socket error.
    unset %world
  }
  else {
    var %read
    while (1) {  
      sockread %read
      if (!$sockbr) {
        break 
      }
      else {
        write rsworlds.txt $nohtml(%read)
      }
    }
  }
}

on *:sockclose:Worlds:{
  if ($read(rsworlds.txt, w, World %world)) {
    var %info = World: %world $chr(124)
    var %info = %info Players: $remove($read(rsworlds.txt,$eval($calc($readn + 1),2)),players) $chr(124)
    var %info = %info Location: $read(rsworlds.txt,$eval($calc($readn + 1),2)) $chr(124) 
    var %info = %info Type: $read(rsworlds.txt,$eval($calc($readn + 1),2)) 
    echo -a %info 
    remove rsworlds.txt
    unset %world
  }
}

alias nohtml { 
  var %x,%y = $regsub($1-,/(<[^>]+>)/g,$null,%x)
  return $remove(%x,&nbsp;) 
}