Created
October 1, 2010 16:13
-
-
Save andsve/606416 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module("modules/xb/xb") | |
function parse_message(bot, msg) | |
local i,j,chan,n = string.find(msg, ":.-!.- PRIVMSG (.-) ::xb (.+)") | |
if not (i == nil) then | |
local http = require("socket.http") | |
local b, c, h = http.request("http://profile.mygamercard.net/" .. tostring(n)) | |
if not (b == nil) then | |
local i,j = string.find(b, "Invalid GamerTag") | |
if (i == nil) then | |
local i,j,s = string.find(b, "userProfileStatusImage\" />%s+(.-)</div>") | |
if not (i == nil) then | |
local s = string.gsub(s, "<br.->", ", ") | |
s = string.gsub(s, "%s+", " ") | |
s = string.gsub(s, "%s+,%s+", " ") | |
s = string.gsub(s, "<span.->", "") | |
s = string.gsub(s, "</span>", "") | |
bot:say(chan, tostring(s)) | |
else | |
bot:say(chan, "Unable to find status for gamertag.") | |
end | |
else | |
bot:say(chan, "Invalid GamerTag!") | |
end | |
else | |
bot:say(chan, "Error while trying to get MyGamerCard webpage.") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment