All pastes #795321 Raw Edit

Something

public text v1 · immutable
#795321 ·published 2007-11-24 00:20 UTC
rendered paste body

alias z1 { return $+($chr(3),03 $+ $1) }
alias z2 { return $+($chr(3),07 $+ $1) }

alias theoutput { return *** $chr(91) $+ 7 $1-  $+ $chr(93) }

on $*:text:/^[!@](halo3|h3)/Si:#: {
  if ($chan == #msl) { halt }
  var %randnum = $right($ticks,6)
  set %halo3.reply [ $+ [ %randnum ] ] $iif($left($1,1) == @, msg $chan, notice $nick)
  if (!$2) { %halo3.reply [ $+ [ %randnum ] ] $theoutput(ERROR) $z1(Please state the service you wish to use.) | unset %halo3.reply [ $+ [ %randnum ] ] | halt }
  if ($2 !== stats) { %halo3.reply [ $+ [ %randnum ] ] $theoutput(ERROR) $z1(Please state a valid service you wish to use.) | unset %halo3.reply [ $+ [ %randnum ] ] | halt }
  if (!$3) { %halo3.reply [ $+ [ %randnum ] ] $theoutput(ERROR) $z1(Please state the gamertag you wish to lookup.) | unset %halo3.reply [ $+ [ %randnum ] ] | halt }
  if ($len($3-) > 15) { %halo3.reply [ $+ [ %randnum ] ] $theoutput(ERROR) $z1(Invalid Gamertag - Gamertags can only be 15 chracters long.) | unset %halo3.reply [ $+ [ %randnum ] ] | halt }
  if ($left($3,1) isnum) { %halo3.reply [ $+ [ %randnum ] ] $theoutput(ERROR) $z1(Invalid Gamertag - Gamertags can't start with numbers.) | unset %halo3.reply [ $+ [ %randnum ] ] | halt | halt }
  if (!$regex($3-,/^[a-z0-9\s_-]+$/Si)) { %halo3.reply [ $+ [ %randnum ] ] $theoutput(ERROR) $z1(Invalid Gamertag - Gamertags can only contain Letters,Numbers and spaces.) $z2(Underscores and hyphons also representing spaces.) | unset %halo3.reply [ $+ [ %randnum ] ] | halt }
  set %halo3.name [ $+ [ %randnum ] ] $replace($3-,$chr(32),+,_,+,-,+)
  if ($right(%halo3.name [ $+ [ %randnum ] ],1) == +) {  %halo3.reply [ $+ [ %randnum ] ] $theoutput(ERROR) $z1(Invalid Gamertag - Gamertags can't end in spaces.) | unset %halo3.* [ $+ [ %randnum ] ] | halt }
  if ($left(%halo3.name [ $+ [ %randnum ] ],1) == +) {  %halo3.reply [ $+ [ %randnum ] ] $theoutput(ERROR) $z1(Invalid Gamertag - Gamertags can't start in spaces.) | unset %halo3.* [ $+ [ %randnum ] ] | halt }
  if (*++* iswm %halo3.name [ $+ [ %randnum ] ]) {  %halo3.reply [ $+ [ %randnum ] ] $theoutput(ERROR) $z1(Invalid Gamertag - Single spaces only.) | unset %halo3.* [ $+ [ %randnum ] ] | halt }
  if ($2 = stats) { sockopen halo3.stats [ $+ [ %randnum ] ] www.bungie.net 80 }
}

on *:SOCKOPEN:halo3.stats*: {
  sockwrite -nt $sockname GET /Stats/Halo3/Default.aspx?player= $+ %halo3.name [ $+ [ $right($sockname,6) ] ]  HTTP/1.0
  sockwrite -nt $sockname Host: www.bungie.net
  sockwrite -nt $sockname $crlf
}


on *:SOCKREAD:halo3.stats*: {
  var %id = $right($sockname,6)
  if ($sockerr) { %halo3.reply [ $+ [ %id ] ] $theoutput(ERROR) $z1(occured, please try again.) | unset %halo3.reply [ $+ [ %id ] ] | unset halo3.* [ $+ [ %id ] ] }
  else {
    var %bungepage
    sockread %bungepage
    if (*Halo 3 Service Record Not Found* iswm %bungepage) { %halo3.reply [ $+ [ %id ] ] $theoutput(ERROR) $z1(No Halo3 Player under the name of) $z2($qt($replace(%halo3.name [ $+ [ %id ] ],+,$chr(32)))) $z1(Was found.) | unset %halo3.* [ $+ [ %id ] ] | halt } 
    if (*<li><span id="ctl00_mainContent_identityStrip_lblRank">*</span>* iswm %bungepage) {
    set %halo3.rank [ $+ [ %id ] ] $remove($gettok(%bungepage,3,62),</span) }
    if (*<li>Highest Skill: <span id="ctl00_mainContent_identityStrip_lblSkill">* iswm %bungepage) {
      set %halo3.skill [ $+ [ %id ] ] $remove($gettok(%bungepage,3,62),</span)
      set %halo3.exp [ $+ [ %id ] ] $remove($gettok(%bungepage,5,62),</span)
    set %halo3.nextrank [ $+ [ %id ] ] $remove($gettok(%bungepage,7,62),</a) }
    if (*<div class="profile_picB"><a id="ctl00_mainContent_identityStrip_hypMultiStats"* iswm %bungepage) {
    set %halo3.pin [ $+ [ %id ] ] $remove($gettok(%bungepage,8,61),",title) }
    if (*<div class="profile_picB"><a id="ctl00_mainContent_identityStrip_hypCPStats"* iswm %bungepage) {
    set %halo3.mis [ $+ [ %id ] ] $gettok(%bungepage,12,34) }
    if (*<td>Total Games</td>* iswm %bungepage) {
      sockread %bungepage
      set %halo3.tgames [ $+ [ %id ] ] $remove($gettok(%bungepage,2,62),</td)
      sockopen halo3.scont [ $+ [ %id ] ] www.bungie.net 80
      sockclose $sockname
    }
  }
}


on *:SOCKOPEN:halo3.scont*: {
  sockwrite -nt $sockname GET /stats/Halo3/CareerStats.aspx?player= $+ %halo3.name [ $+ [ $right($sockname,6) ] ]  HTTP/1.0
  sockwrite -nt $sockname Host: www.bungie.net
  sockwrite -nt $sockname $crlf
}

on *:SOCKREAD:halo3.scont*: {
  var %id = $right($sockname,6)
  if ($sockerr) { %halo3.reply [ $+ [ %id ] ] $theoutput(ERROR) $z1(occured, please try again.) | unset halo3.* [ $+ [ %id ] ] }
  else {
    var %bungepage
    sockread %bungepage
    if (*<tr><td>Kills :</td>* iswm %bungepage) {
    set %halo3.rkills [ $+ [ %id ] ] $remove($gettok(%bungepage,5,62),</td) }
    if (*<tr><td>Deaths :</td>* iswm %bungepage) {
    set %halo3.rdeaths [ $+ [ %id ] ] $remove($gettok(%bungepage,5,62),</td) }
    if (*<tr><td>K/D Ratio :</td>* iswm %bungepage) {
      set %halo3.rratio [ $+ [ %id ] ] $remove($gettok(%bungepage,5,62),</td)
      sockopen halo3.rcont [ $+ [ %id ] ] www.bungie.net 80
      sockclose $sockname
    }
  }
}

on *:SOCKOPEN:halo3.rcont*: {
  sockwrite -nt $sockname GET /stats/Halo3/CareerStats.aspx?player= $+ %halo3.name [ $+ [ $right($sockname,6) ] ] $+ &social=true&map=0 HTTP/1.0
  sockwrite -nt $sockname Host: www.bungie.net
  sockwrite -nt $sockname $crlf
}

on *:SOCKREAD:halo3.rcont*: {
  var %id = $right($sockname,6)
  if ($sockerr) { %halo3.reply [ $+ [ %id ] ] $theoutput(ERROR) $z1(occured, please try again.) | unset halo3.* [ $+ [ %id ] ] }
  else {
    var %bungepage
    sockread %bungepage
    if (*<tr><td>Kills :</td>* iswm %bungepage) {
    set %halo3.skills [ $+ [ %id ] ] $remove($gettok(%bungepage,5,62),</td) }
    if (*<tr><td>Deaths :</td>* iswm %bungepage) {
    set %halo3.sdeaths [ $+ [ %id ] ] $remove($gettok(%bungepage,5,62),</td) }
    if (*<tr><td>K/D Ratio :</td>* iswm %bungepage) {
      set %halo3.sratio [ $+ [ %id ] ] $remove($gettok(%bungepage,5,62),</td)
      %halo3.reply [ $+ [ %id ] ] $theoutput($upper($replace(%halo3.name [ $+ [ %id ] ],+,$chr(32)))) $z1(Rank:) $z2(%halo3.rank [ $+ [ %id ] ]) 1 $+ $chr(124) $z1(Skill Level:) $z2(%halo3.skill [ $+ [ %id ] ]) 1 $+ $chr(124) $z1(Exp:) $z2(%halo3.exp [ $+ [ %id ] ]) 1 $+ $chr(124) $z1(Next Rank in:) $z2(%halo3.nextrank [ $+ [ %id ] ]) 1 $+ $chr(124) $z1(Has $iif(%halo3.pin [ $+ [ %id ] ], obtained an, not obtained) :) $z2($iif(%halo3.pin [ $+ [ %id ] ], %halo3.pin [ $+ [ %id ] ],Any pins!)) 1 $+ $chr(124) $iif(%halo3.mis [ $+ [ %id ] ],3 $+ $upper(%halo3.mis [ $+ [ %id ] ] campaign), 4 $+ $upper(Has not started a campaign))   
      %halo3.reply [ $+ [ %id ] ] $theoutput($upper($replace(%halo3.name [ $+ [ %id ] ],+,$chr(32)))) $z1(Total Games Played:) $z2(%halo3.tgames [ $+ [ %id ] ]) 1 $+ $chr(124) $z2(RANKED-) $z1(Kills:) $z2(%halo3.rkills [ $+ [ %id ] ]) 1 $+ $chr(124) $z1(Deaths:) $z2(%halo3.rdeaths [ $+ [ %id ] ]) 1 $+ $chr(124) $z1(K/D Ratio:) $z2(%halo3.rratio [ $+ [ %id ] ]) 1 $+ $chr(124) $z2(SOCIAL-) $z1(Kills:) $z2(%halo3.skills [ $+ [ %id ] ]) 1 $+ $chr(124) $z1(Deaths:) $z2(%halo3.sdeaths [ $+ [ %id ] ]) 1 $+ $chr(124) $z1(K/D Ratio:) $z2(%halo3.sratio [ $+ [ %id ] ])
      unset %halo3.* [ $+ [ %id ] ]
      sockclose $sockname
    }
  }
}