local function parsePotato(spud)
for sp = 1,#spud do
   if string.match(spud[sp],"***") then
     for i in string.gmatch(spud[sp], "%S+") do
      table.insert(tabl,i)
      print(i)
     end
     if tabl[3] then
    print(tabl[3].." Has left the IRC")
    end
   elseif not string.match(spud[sp],"<TKServer>") then
    print(spud[sp])
   else
    print(string.sub(spud[sp],12))
   end
 end
end

local function getPotato()
potatohandle = http.get("http://alekbnc.tk/potato/index.php?channel=turtlekingdom&lines=1&raw=true")

if potatohandle.getResponseCode() == 200 and potatohandle then
 local count = 0
 currcache = {}
 for lines in potatohandle.readLine do
  if count ~= 0 then
   local stringz = string.sub(lines,10)
   table.insert(currcache,stringz)
  else count = nil
  end
 end
 potatohandle.close() 
end
 return currcache
end

local function checkPotato()
 currcache = getPotato()
 if lastcache[1] == currcache[1] then
  --print("SAME")
 else
   --print("not same..")
   parsePotato(currcache)
   lastcache = currcache
 end
end

lastcache = {}
while true do
 checkPotato()
 sleep(1)
end
