All pastes #707945 Raw Edit

Unnamed

public text v1 · immutable
#707945 ·published 2007-09-23 13:07 UTC
rendered paste body
on $*:text:/^[@!.]stats:{
  if ($mid($me,5) == SwiftRS) {
    set %output $iif($left($1,1) == @,msg $chan,notice $nick)
    if (!$2) {
      %output Syntax: [!@.]stats <user>
      halt
    }
    if (*$* iswm $2-) || (*%* iswm $2-) {
      notice $nick Error: $replace($v1,*,') found in ' $+ $1- $+ '
      halt
    }
    else {
      var %sockid $rand(1,99999)
      unset %stats | set %id [ $+ [ %sockid ] ] 0  
      set %output [ $+ [ %sockid ] ] $iif($left($1,1) == @,msg $chan,notice $nick)
      set %statname [ $+ [ %sockid ] ] $replace($2-,$chr(32),_)
      sockopen $+(stats.%sockid) hiscore.runescape.com 80
    }
  }
}

on *:sockopen:stats.*:{
  sockwrite -nt $sockname GET $+(/index_lite.ws?player=,%statname [ $+ [ $gettok($sockname,2,46) ] ]) HTTP/1.1
  sockwrite -nt $sockname Host: hiscore.runescape.com
  sockwrite -nt $sockname $crlf $crlf
}
on *:sockread:stats.*:{
  var %sockread
  sockread %sockread
  if (*HTTP/1.1 404 Not found* iswm %sockread) {
    %output [ $+ [ $gettok($sockname,2,46) ] ] $+($c1,[,$c2,HighScores,$c1,],$c2) %statname [ $+ [ $gettok($sockname,2,46) ] ] does not feature in the highscores
    sockclose $sockname
  } 
  if (($Chr(44) isin %sockread) && (GMT !isin %sockread)) {
    tokenize 44 %sockread
    if (%id [ $+ [ $gettok($sockname,2,46) ] ] == 0) {
      set %stats [ $+ [ $gettok($sockname,2,46) ] ] %stats [ $+ [ $gettok($sockname,2,46) ] ] $c1($skill(%id [ $+ [ $gettok($sockname,2,46) ] ])) $c2($iif($2 != -1,$2,-))
      inc %id [ $+ [ $gettok($sockname,2,46) ] ]
    }
    else {
      set %stats [ $+ [ $gettok($sockname,2,46) ] ] %stats [ $+ [ $gettok($sockname,2,46) ] ] $iif($2 != -1,$c1($skill(%id [ $+ [ $gettok($sockname,2,46) ] ] )) $c2($2))
      inc %id [ $+ [ $gettok($sockname,2,46) ] ]
    }
  }
}
on *:sockclose:stats.*:{
  %output [ $+ [ $gettok($sockname,2,46) ] ] 12Stats for7 %statname [ $+ [ $gettok($sockname,2,46) ] ]
  %output [ $+ [ $gettok($sockname,2,46) ] ] %stats [ $+ [ $gettok($sockname,2,46) ] ]
  unset %statname [ $+ [ $gettok($sockname,2,46) ] ]
  unset %output [ $+ [ $gettok($sockname,2,46) ] ]
  unset %id [ $+ [ $gettok($sockname,2,46) ] ]
  unset %stats [ $+ [ $gettok($sockname,2,46) ] ]
}

alias -l skill {
  if (($1 == 0) || ($regex($1,/^Over(?:all)?$/Si))) return Overall
  if (($1 == 1) || ($regex($1,/^Att?(?:a)?c?k?$/Si))) return Attack 
  if (($1 == 2) || ($regex($1,/^Def(?:en[sc]e)$/Si))) return Defence
  if (($1 == 3) || ($regex($1,/^Str(?:ength)?$/Si))) return Strength
  if (($1 == 4) || ($regex($1,/^H(?:its?|p(?:oints)?)$/Si))) return Hitpoints
  if (($1 == 5) || ($regex($1,/^Ranged?$/Si))) return Ranged
  if (($1 == 6) || ($regex($1,/^Pray(?:er)?$/Si))) return Prayer
  if (($1 == 7) || ($regex($1,/^Mag(?:e|ic)$/Si))) return Magic
  if (($1 == 8) || ($regex($1,/^Cook(?:ing?)?$/Si))) return Cooking
  if (($1 == 9) || ($regex($1,/^W(?:ood)?c(?:ut)?(?:ing?)?$/Si))) return Woodcutting
  if (($1 == 10) || ($regex($1,/^Fletch(?:ing)?$/Si))) return Fletching
  if (($1 == 11) || ($regex($1,/^Fish(?:ing)?$/Si))) return Fishing
  if (($1 == 12) || ($regex($1,/^F(?:(?:ire)?m(?:ak(?:e|ing))?)$/Si))) return Firemaking
  if (($1 == 13) || ($regex($1,/^Craft(?:ing?)?$/Si))) return Crafting
  if (($1 == 14) || ($regex($1,/^Smith(?:ing?)?$/Si))) return Smithing
  if (($1 == 15) || ($regex($1,/^Min(?:e|ing?)$/Si))) return Mining
  if (($1 == 16) || ($regex($1,/^Herb(?:y|i?(?:lor)?e)?$/Si))) return Herblore
  if (($1 == 17) || ($1 == Agility)) return Agility
  if (($1 == 18) || ($regex($1,/^Thie[fv](?:e|ing)?$/Si))) return Thieving
  if (($1 == 19) || ($regex($1,/^Slay(?:er)?$/Si))) return Slayer
  if (($1 == 20) || ($regex($1,/^Farm(?:ing)?$/Si))) return Farming
  if (($1 == 21) || ($regex($1,/^R(?:une)?C(?:raft(?:ing)?)?$/Si))) return Runecraft
  if (($1 == 22) || ($regex($1,/^Hunt(?:er|ing)?$/Si))) return Hunter
  if (($1 == 23) || ($regex($1,/^Con(?:struct(?:ion)?)?$/Si))) return Construction
}


alias c1 { return $+(7,$1-) }
alias c2 { return $+(12,$1-) }