Advertisement
Guest User

test

a guest
Nov 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. function getLatestPaste()
  2.  
  3.   local h = http.post("https://pastebin.com/api/api_post.php","api_option=list&api_user_key=bb05551ae175b44ed1791e5efc6151ed&api_dev_key=eabc602e583049d95051a0e2f75cc77f&api_results_limit=1")
  4.   if not (h==nil) then
  5.     local r = ""
  6.  
  7.     while true do
  8.       local l = h.readLine()
  9.       if l==nil then break end
  10.       if string.sub(l,0,11)=="<paste_key>" then r=l end
  11.     end  
  12.  
  13.     local pk = string.gsub(r,"<paste_key>(%w+)</paste_key>","%1")
  14.    
  15.     local gh = http.get("https://pastebin.com/raw/"..pk)
  16.     local text = gh.readAll()
  17.  
  18.     local ret = {}
  19.        ret["key"]  = pk
  20.        ret["text"] = text
  21.     return ret
  22.   else
  23.     return nil
  24.   end
  25. end
  26.  
  27. function getNewPaste()
  28.   lkey = ""
  29.   if fs.exists("/last") then
  30.     f    = fs.open("/last","r")
  31.     lkey = f.readAll()
  32.     f.close()
  33.   end
  34.  
  35.   np   = getLatestPaste()
  36.  
  37.   if not (lkey==np["key"]) then
  38.     f = fs.open("/last","w")
  39.     f.writeLine(np["key"])
  40.     f.close()
  41.     return np
  42.   else
  43.     return nil
  44.   end
  45. end
  46.  
  47. local p = getNewPaset()
  48. write(p["key"].." >> "..p["text"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement