A really super simple tcl script for eggdrop bots that uses https://live.xbox.com to pull some basic profile information on a user.
make sure you add +xbl to the channel you want to use the .gt switch on.
#!/usr/bin/tclsh
######################################################################
# simple xbox live script for eggdrop #
# #
# feel free to change xlbchar to whatever you like ! or . etc... #
# this tcl script requires http and tls, after that you also must #
# set +xbl on the channel you wish to be able to use you .gt trigger #
# #
# synmuffin, Joakim #
######################################################################
######################################################################
# options #
######################################################################
set xblchar "."
set url "https://live.xbox.com/en-US/Profile?gamertag="
######################################################################
package require http
package require tls
proc gtfetch {nick host hand chan search} {
global url
if {[lsearch -exact [channel info $chan] +xbl] != -1} {
set gamertag [urlencode $search]
set lastseen "Unknown"
set gamerscore "Unknwon"
set badge "Unknown"
set cheater ""
http::register https 443 tls::socket
set token [http::geturl "${url}${gamertag}" -timeout 30000]
set status [http::status $token]
set pdata [http::data $token]
http::cleanup $token
http::unregister https
# check to see if we can find a profile for that user
if {[ regexp {<div class="grid-18 NotFound">} $pdata ]} {
putserv "PRIVMSG $chan ::\0033\002XBOX Live\002\003 Unable to find profile for $search"
return 0;
}
# lastseen
regexp {<div class="presence">(.*?)</div>} $pdata match lastseen
# gamerscore
regexp {<div class="gamerscore">(.*?)</div>} $pdata match gamerscore
# badge
regexp {<div class="goldBadge">(.*?)</div>} $pdata match badge
# cheater
if {[regexp {<div class="cheater">} $pdata ]} {
set cheater "\0034\002CHEATER\002\003"
}
putserv "PRIVMSG $chan :\0033\002XBOX Live\002\003 $search : $badge ($lastseen) \0033\002GamerScore:\002\003 $gamerscore \0033\002Profile:\002\003 ${url}${search} $cheater"
}
}
# urlencode function
proc urlencode {string} {
return [subst [regsub -nocase -all {([^a-z0-9+])} $string {%[format %x [scan "\\&" %c]]}]]
}
# url decode function
proc urldecode str {
set str [string map [list + { } "\\" "\\\\"] $str]
regsub -all -- {%([A-Fa-f0-9][A-Fa-f0-9])} $str {\\u00\1} str
return [subst -novar -nocommand $str]
}
bind pub - ${xblchar}gt gtfetch
setudef flag xbl
putlog "Xbox Live Eggdrop - by synmuffin / Joakim"