1. Hey Guest, are you looking for a place to host your IRC related project? Then check out the Resource Manager on IRCForums! Click the resources tab above this notice!
  2. Hello Guest, are you new to IRCForums? Why not introduce yourself in the introduction forum!
  3. We have updated the layout of our forums. Please see this thread for more information.

[TCL] Xbox live GamerStatus/GamerScore getter.

Discussion in 'Script Gallery (Depreciated)' started by GrimReaper, Feb 26, 2012.

  1. Offline

    GrimReaper Recruit

    Member Since:
    Feb 26, 2012
    Message Count:
    23
    Likes Received:
    8
    Trophy Points:
    18
    Syntax after adding to Eggdrop Bot:

    .xbl Gamertag ;retrieves what the Gamertag is doing (See quote below)
    .xblgs Gamertag ; retrieves the gamerscore for the Gamertag selected.

    Code (tcl):

    #####################################################
    ## Xbox Live GamerTag Status' by Danneh/GrimReaper ##
    #####################################################
    ## Initial Setup ##
    #####################################################
     
    set xblchar "."
     
    #####################################################
    ## End Setup ##
    #####################################################
     
    proc xblinfo {nick host hand chan search} {
      if {[lsearch -exact [channel info $chan] +xblinfo] != -1} {
        set xbllogo "\0039X\00314box Live\003"
        set xblsite "Live.xbox.com"
        set xblstatusfound "0"
        if {$search == ""} {
          putserv "PRIVMSG $chan :$xbllogo, Please enter a GamerTag to search for.."
        } else {
          set xblsrcurl1 [urlencode [regsub -all { } $search +]]
          set xblsrcurl2 [encurl $search]
          set xblsrcurl3 "/en-GB/Profile?gamertag=${xblsrcurl2}"
          if {[catch {set xblsrcsock [socket -async $xblsite 80]} sockerr]} {
            return 0
          } else {
            puts $xblsrcsock "GET $xblsrcurl3 HTTP/1.0"
            puts $xblsrcsock "Host: $xblsite"
            puts $xblsrcsock "User-Agent: Opera 9.6"
            puts $xblsrcsock ""
            flush $xblsrcsock
            while {![eof $xblsrcsock]} {
              set xblstatus "[gets $xblsrcsock]"
              if {$xblstatusfound == "on"} {
                putserv "PRIVMSG $chan :$xbllogo status for \0037$search\003: [xblstrip [string trimleft [recode "${xblstatus}"]]]"
                close $xblsrcsock
                return 0
              }
              if {[regexp -all {<div class="custom">} $xblstatus]} {
                set xblstatusfound "on"
              }
            }
            putserv "PRIVMSG $chan :Sorry, I couldn't find \0037$search\003 on $xbllogo"
            close $xblsrcsock
            return 0
          }
        }
      }
    }
     
    proc xblgsinfo {nick host hand chan search} {
      if {[lsearch -exact [channel info $chan] +xblinfo] != -1} {
        set xbllogo "\0039X\00314box Live\003"
        set xblsite "Live.xbox.com"
        if {$search == ""} {
          putserv "PRIVMSG $chan :$xbllogo, Please enter a GamerTag to search GamerScore for.."
        } else {
          set xblsrcurl1 [urlencode [regsub -all { } $search +]]
          set xblsrcurl2 [encurl $search]
          set xblsrcurl3 "/en-GB/Profile?gamertag=${xblsrcurl2}"
          if {[catch {set xblsrcsock [socket -async $xblsite 80]} sockerr]} {
            return 0
          } else {
            puts $xblsrcsock "GET $xblsrcurl3 HTTP/1.0"
            puts $xblsrcsock "Host: $xblsite"
            puts $xblsrcsock "User-Agent: Opera 9.6"
            puts $xblsrcsock ""
            flush $xblsrcsock
            while {![eof $xblsrcsock]} {
              set xblstatus "[gets $xblsrcsock]"
              if {[regexp -all {<div class="gamerscore">(.*?)</div>} $xblstatus match xblgamerscore]} {
                putserv "PRIVMSG $chan :$xbllogo GamerScore for \0037$search\003: $xblgamerscore"
                close $xblsrcsock
                return 0
              }
            }
            putserv "PRIVMSG $chan :Sorry, I couldn't find \0037$search\003 on $xbllogo"
            close $xblsrcsock
            return 0
          }
        }
      }
    }
     
     
    proc encurl {string} {
      return [string map {" " %20} "$string"]
    }
    proc xblstrip {string} {
      return [regsub -all {<[^<>]+>} $string ""]
    }
    proc urlencode {string} {
      return [subst [regsub -nocase -all {([^a-z0-9+])} $string {%[format %x [scan "\\&" %c]]}]]
    }
    proc recode { textin } {
      return [string map {&quot; \" &middot; ยท &amp; &} [subst [regsub -nocase -all {&#([0-9]{1,5});} $textin {\u\1}]]]
    }
    bind pub - ${xblchar}xbl xblinfo
    bind pub - ${xblchar}xblgs xblgsinfo
    setudef flag xblinfo
    putlog "
    Xbox Live Gamertag status' by Danneh/GrimReaper"
    Copy and paste the code into something like "xbl.tcl", Then go to your eggdrop bot's config file and add near the bottom: source scripts/xbl.tcl

    After you have done that.. Rehash your bot..

    After the rehash, You need to log into your bot via Telnet and do .chanset #yourchannelname +xblinfo

    Your channel would then be setup to work with the script.

    General output.
    I would like to thank FordLawnmower in help with some of the tcl problems that I was having.. He has been a great help.
    Bertrum and Tappy like this.
  2. Offline

    Tappy ParadoxIRC

    Member Since:
    Dec 17, 2011
    Message Count:
    329
    Likes Received:
    133
    Trophy Points:
    118
    Nice script, I'll have to add this to my bot.
  3. Offline

    GrimReaper Recruit

    Member Since:
    Feb 26, 2012
    Message Count:
    23
    Likes Received:
    8
    Trophy Points:
    18
    It's just something my friend requested me to attempt to write, And I did, I currently use it in my eggdrop bot. Works like a charm. Until xbox.com changes their HTML output, Then I have to go debugging again. lol
  4. Offline

    Tappy ParadoxIRC

    Member Since:
    Dec 17, 2011
    Message Count:
    329
    Likes Received:
    133
    Trophy Points:
    118
    Haha, good ol' m$.
  5. Offline

    Bertrum ParadoxIRC

    Member Since:
    Dec 17, 2011
    Message Count:
    1,822
    Likes Received:
    243
    Trophy Points:
    188
    Nice work :)
  6. Offline

    GrimReaper Recruit

    Member Since:
    Feb 26, 2012
    Message Count:
    23
    Likes Received:
    8
    Trophy Points:
    18
    Re-arranged the code above so it look's like it should do. >_> And it also make's it easier to read imo for some reason. o.0
  7. Offline

    Napa182 Moderator

    Member Since:
    Dec 18, 2011
    Message Count:
    222
    Likes Received:
    83
    Trophy Points:
    56
    nice work once again Grim..

Share This Page