Sirshark10

PLoad

Feb 23rd, 2017
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2. ---------------+
  3. Documentation--|
  4. ---------------+
  5.  
  6. Load(pastebin code) | performs a loadstring()
  7.  
  8. on the pastebin code you insert.
  9.  
  10. ----|
  11. ----|
  12. DLoad(code, path) | Downloads the pastebin code
  13.  
  14. you supply to the path you supply
  15. ----|
  16. ----|
  17. ULoad(path) | Uploads the file you specify to
  18.  
  19. pastebin
  20.  
  21. Returns the pastebin code.
  22.  
  23.  
  24. --]]
  25.  
  26.  
  27. local function getString(pastebin)
  28.   A = http.get("http://pastebin.com/raw/"..pastebin)
  29.   return A.readAll()
  30. end
  31.  
  32.  
  33.  
  34.  
  35. function Load(pastebin)
  36.   loadstring(getString(pastebin))()
  37.   return true
  38. end
  39.  
  40.  
  41.  
  42.  
  43. function DLoad(pastebin,path)
  44.   local A = getString(pastebin)
  45.   local file = fs.open(path,"w")
  46.   file.write(A)
  47.   file.flush()
  48.   file.close()
  49.   return true
  50. end
  51.  
  52.  
  53.  
  54.  
  55. function ULoad(file)
  56.   local f = fs.open(file,"r")
  57.   local uF = f.readAll()
  58.   f.close()
  59.   local name = fs.getName(file)
  60.   local key = "0ec2eb25b6166c0c27a394ae118ad829"
  61.   local response = http.post(
  62.   "http://pastebin.com/api/api_post.php",
  63.   "api_option=paste&"..
  64.   "api_dev_key="..key.."&"..
  65.   "api_paste_format=lua&"..
  66.   "api_paste_name="..textutils.urlEncode(name).."&"..
  67.   "api_paste_code="..textutils.urlEncode(uF)
  68.   )
  69.   local sResponse = response.readAll()
  70.   response.close()
  71.   local CODE = string.match( sResponse, "[^/]+$" )
  72.   return CODE
  73. end
Add Comment
Please, Sign In to add comment