function whois(player, html)
local w = html
if not w then
ui.alert("There has been an error retrieving information from the website.")
if IsConnected() then SendNoEcho("") end
return
end
local m = core.match("(?:City|Commune)\: ([A-Z][a-z]+)", w)
if not m then
ui.message("This person appears to either be a rogue, or not exist at all.")
if IsConnected() then SendNoEcho("") end
return
end
add_name(player, m[1])
if IsConnected() then SendNoEcho("") end
end
function download_page(player)
local h = "www.ironrealms.com"
local c = assert(socket.connect(h, 80))
c:send("GET http://www.ironrealms.com/game/honors/Lusternia/"..player.." HTTP/1.0\r\n\r\n")
local x = coroutine.create(
function ()
whois(player, receive(c))
end)
coroutine.resume(x)
end
function receive(c)
local status = "timeout"
local msg, a
c:settimeout(0)
while (status == "timeout") or (status==nil and a~=nil) do
a, status, d = c:receive()
if a then msg = msg..a end
if d then msg = msg..d end
if status == "timeout" then
coroutine.yield(true)
end
end
c:close()
return msg
end
Here's my lastest attempt to get it to work, but it just does nothing when I run the download function. |