Skip to content

Instantly share code, notes, and snippets.

@andsve
Created October 1, 2010 16:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andsve/606416 to your computer and use it in GitHub Desktop.
Save andsve/606416 to your computer and use it in GitHub Desktop.
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