Advertisement
ENCIOK

gclone

Sep 23rd, 2024 (edited)
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | Gaming | 0 0
  1. if #arg < 2 then
  2.     print("ERROR: Debilu, trzeba 2 argumenty: gist name i file name")
  3.     return
  4. end
  5.  
  6. local gist_name, file_name = ...
  7.  
  8. local answer, error = http.get("https://api.github.com/users/ENCIOK/gists")
  9. local gists_list_text = answer.readAll()
  10. local gists_table = textutils.unserialiseJSON(gists_list_text)
  11. answer.close()
  12.  
  13. local url
  14.  
  15. for i, table in ipairs(gists_table) do
  16.     if table.files[gist_name] then
  17.         url = table.files[gist_name].raw_url
  18.         break
  19.     end
  20. end
  21.  
  22. if url == nil then
  23.     print("ERROR: Nie ma tekiego gistu, ciołku -_-")
  24.     return
  25. end
  26.  
  27. answer, error = http.get(url)
  28. local code = answer.readAll()
  29.  
  30. fs.delete(file_name)
  31. local file = fs.open(file_name, "w")
  32. file.write(code)
  33. file.close()
  34. answer.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement