All pastes #818366 Raw Edit

Justin

public text v1 · immutable
·published 2007-12-16 07:24 UTC
rendered paste body
alias -l Skills {
  return Overall,Attack,Defence,Strength,Hitpoints,Ranged,Prayer,Magic,Cooking,Woodcutting,Fletching,Fishing,Firemaking,Crafting,Smithing,Mining,Herblore,Agility,Thieving,Slayer,Farming,Runecraft,Hunter,Construction,Duel Tournament
}
on *:text:!stats *:#:{
  if ($2 != $null) {
    set %user $replace($2-,_,$chr(32))
    set %step 0
    set %i 1
    set %stats $null
    set %stats2 $null
    set %stats3 $null
    set %nick notice $nick
    sockopen GetStats hiscore.runescape.com 80
  }
}
on *:text:@stats *:#:{
  if ($2 != $null) {
    set %user $replace($2-,_,$chr(32))
    set %step 0
    set %i 1
    set %stats $null
    set %stats2 $null
    set %stats3 $null
    set %nick msg $chan
    sockopen GetStats hiscore.runescape.com 80
  }
}

on *:sockopen:GetStats:{
  sockwrite -nt $sockname GET http://hiscore.runescape.com/index_lite.ws?player= $+ %user HTTP/1.0
  sockwrite -nt $sockname Accept-Language: en-us
  sockwrite -nt $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
  sockwrite -nt $sockname Host: hiscore.runescape.com
  sockwrite -nt $sockname Connection: keep-alive
  sockwrite -t $sockname $str($crlf,2)
}

on *:sockread:GetStats:{
  sockread %buffer
  if (%step == 2) {
    if ($gettok(%buffer,2,44) != -1) {
      if (%i < 10) {
        set %stats %stats 14 $+ $chr(91) 03 $+ $gettok($Skills,%i,44) 14 $+ = $+ 03 $gettok(%buffer,2,44) 14 $+ $chr(93)
      }
      elseif (%i < 20) {
        set %stats2 %stats2 14 $+ $chr(91) 03 $+ $gettok($Skills,%i,44) 14 $+ = $+ 03 $gettok(%buffer,2,44) 14 $+ $chr(93)
      }
      else {
        set %stats3 %stats3 14 $+ $chr(91) 03 $+ $gettok($Skills,%i,44) 14 $+ = $+ 03 $gettok(%buffer,2,44) 14 $+ $chr(93)
      }
      inc %i
    }
    if (%i == $numtok($Skills,44)) {
      if (%stats == $null && %stats2 == $null && %stats3 == $null) {
        %nick 03The user14 $chr(91) $+ 03 %user $chr(93) 14 $+ $chr(93) does not appear on the hiscores.
      }
      else {
        %nick 03Stats for14 $chr(91) $+ 03 %user 14 $+ $chr(93) $+ 03: %stats
        %nick %stats2
        %nick %stats3
      }
      sockclose $sockname
    }
  }
  if (%step == 1) { inc %step }
  if (Content-length isin %buffer) { inc %step }
}