TCL Xbox Live GamerTag Status & Gamerscore

By GrimReaper on Apr 27, 2011

This is a code that I was asked to make by Radien on GeekShed.. I've not really done TCL that much but gave it a go.

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.

[01:38] Xbox Live status for StealthyPeer: Last seen 1 hour ago playing Xbox Dashboard

I would like to thank FordLawnmower in help with some of the tcl problems that I was having.. He has been a great help.

[b]UPDATE:[\b] I have now added another command where you can now get the desired Gamerscore for the user.. The command is .xblgs GamerTag

NOTE: When posting this script into SSH, Please make sure you have your PuTTY or SSH window Maximized, Otherwise the client will wordwrap the script, Thus not making it work correctly.. Either that or use an FTP client to load the script.

UPDATE: I have updated the code slightly to add an error message into it if the desired gamertag wasn't found on xbox live.. Thank you to Ford for helping me figure it out.. :) He's a great help!! :D

#####################################################
## 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"

Comments

Sign in to comment.
LostInInaka   -  Dec 03, 2012

http://www.xboxgamertag.com/ seems to be a non-SSL solution...just my TCL is non-existent so unsure how to edit the script...

 Respond  
GrimReaper   -  Nov 12, 2012

I am currently working on an update to this, as xbox.com now uses SSL to connect and I am not sure how to do that in TCL, So using a completely different site.

 Respond  
GrimReaper   -  May 31, 2012

@iDLE When you loaded the script into your eggdrop how did you do it? Because if you pasted it in PuTTY without it being maximized then it would word wrap the code meaning there will be misplaced information. I would suggest using some sort of FTP program and pasting the code that way, Or maximizing PuTTY before pasting it.

 Respond  
iDLE   -  Apr 19, 2012

[11:35:14] Tcl error [xblinfo]: unmatched open quote in list

any idea? :(

 Respond  
GrimReaper   -  Jan 17, 2012

@Corndawg32, I could add that in another update.. I am looking for more things to add to it.

@itskamel, Who are you trying to look for? You can PM me the Gamertag and I will see if it works on my Eggdrop.

 Respond  
corndawg32   -  Jan 17, 2012

Seet :) Ive got an idear tho, is it possible to show a link to the users xbl page so we can compare games etc?

 Respond  
itskamel   -  Jan 17, 2012

.< i c its in the update now.

 Respond  
GrimReaper   -  Jan 17, 2012

Updated again to now receive GamerScore from the user as well.. Please check description on information. :)

 Respond  
itskamel   -  Nov 01, 2011

awesome script. now i must ask is this possible to do with the playstation network?

 Respond  
GrimReaper   -  Jul 17, 2011

Updated the code, Please read the description above!!!

Screenshot of the update: Image

 Respond  
GrimReaper   -  Jun 05, 2011

@corndawg32, I am currently on that newtork you Administer, I would like to talk to you on there.. If you could PM me when you see this.. Nick on the network is the same as here.

 Respond  
corndawg32   -  May 01, 2011

BTW, being one of the administrators for XBConnect, (gaming for the xbox, psp, 360) this script would come in mighty handy for us.

 Respond  
corndawg32   -  May 01, 2011

eggdrop 1.6.20 incase your wondering.

 Respond  
GrimReaper   -  May 01, 2011

That's odd, I don't get that when I load it into my Eggdrop. :s I will have a look over the code again.

 Respond  
corndawg32   -  Apr 30, 2011

Tcl error [xblinfo]: wrong # args: no script following "[catch {set xblsrcsock [socket -async $xblsite 80]} sockerr]" argument

eh?

 Respond  
  -  Apr 29, 2011

Ah great GrimReaper, Just what I was looking for on my other TCL network.

Thanks!

 Respond  
GrimReaper   -  Apr 28, 2011

@xbox_gamer1, Where you see this:

#####################################################

Initial Setup

#####################################################

set xblchar "."

#####################################################

End Setup

#####################################################

Change the character in the quotes to a ! from a . Then it should work as !xbl.

 Respond  
xbox_gamer1   -  Apr 28, 2011

GrimReaper can you make it so it's like !xbl if you can :)

 Respond  
GrimReaper   -  Apr 28, 2011

Bielie, Ask and you shall recieve. :)

Image

 Respond  
Bielie   -  Apr 28, 2011

Could you please show a printscreen or a photo anything :)? I wanna see how it works :)

 Respond  
GrimReaper   -  Apr 27, 2011

Thanks :P

 Respond  
Radien   -  Apr 27, 2011

good job danneh :P

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.