devomaa

Untitled

May 8th, 2020
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. --now with bruh!----
  2. ----IMGRAB-------//
  3. --------------/
  4. args = {...}
  5. local function getAPI(api)
  6. if api == "bigfont" then
  7. fs.makeDir("apis")
  8. local pbHandle = http.get("https://pastebin.com/raw/3LfWxRWh")
  9. local pbContents = pbHandle.readAll()
  10. local fileHandle = fs.open("/apis/bigfont", "w")
  11. fileHandle.write(pbContents)
  12. fileHandle.close()
  13. end
  14. end
  15. if not fs.exists("/apis/bigfont") then
  16. getAPI("bigfont")
  17. end
  18. local function loadAPI(file)
  19. local env = {}
  20. setmetatable(env, {__index = _G})
  21. local fn, err = loadfile(file, nil, env)
  22. if not fn then error(err) end
  23. fn()
  24. local api = {}
  25. for k, v in pairs(env) do
  26. if k ~= "_ENV" then
  27. api[k] = v
  28. end
  29. end
  30. return api
  31. end
  32. local function update()
  33. local fileR = fs.open("imgrab","r")
  34. local pbHandle = http.get("https://pastebin.com/raw/bvebq8PK")
  35. local pbContents = pbHandle.readAll()
  36. if fileR.readAll() ~= pbContents then
  37. fileR.close()
  38. fs.delete("imgrab")
  39. local file = fs.open("imgrab","w")
  40. file.write(pbContents)
  41. pbHandle.close()
  42. file.close()
  43. end
  44. end
  45. update()
  46. local function useAPI(filename)
  47. print("Use API?")
  48. input = read()
  49. if string.lower(input) == "y" or string.lower(input) == "yes" then
  50. local api = loadAPI(filename)
  51. print("Device ID, (term for terminal")
  52. input = read()
  53. if input == "term" then
  54. api.draw(term)
  55. else
  56. api.draw(peripheral.wrap(input))
  57. end
  58. else
  59. error("Done!")
  60. end
  61. end
  62.  
  63.  
  64. if args[1] == "disk" then
  65. print("Where is your disk located? (directory-wise)")
  66. input = read()
  67. local diskMode = input
  68. end
  69. print("Enter URL")
  70. input = read()
  71. url = "https://tojuroku.switchcraft.pw/?url="..textutils.urlEncode(input)
  72. urlHandle = http.get(url)
  73. local function getContents()
  74. urlContents = urlHandle.readAll()
  75. end
  76. print("Save or use from web?")
  77. input = read()
  78. if string.lower(input) == "web" or string.lower(input) == "yes" or string.lower(input) == "y" or string.lower(input) == "use" then
  79. getContents()
  80. if type(diskMode) == "string" then
  81. fs.makeDir("/"..diskMode.."/temp")
  82. fs.makeDir("/"..diskMode.."/temp/imgrab")
  83. fs.makeDir("/"..diskMode.."/temp/imgrab/XX667700/")
  84. filename = "/"..diskMode.."/temp/imgrab/XX667700/temp1.lua"
  85. local file = fs.open(filename, "w")
  86. file.write(urlContents)
  87. file.close()
  88. useAPI(filename)
  89. fs.delete(filename)
  90. else
  91. filename = "/temp/imgrab/XX667700/temp1.lua"
  92. local file = fs.open(filename, "w")
  93. file.write(urlContents)
  94. file.close()
  95. useAPI(filename)
  96. fs.delete(filename)
  97. end
  98. else
  99. print("Enter Filename")
  100. input = read()
  101. if fs.exists(input) then
  102. printError("File Exists")
  103. print("Overwrite?")
  104. input = read()
  105. input = filename
  106. if string.lower(input) == "y" or string.lower(input) == "yes" then
  107. fs.delete(input)
  108. else
  109. error("User said no")
  110. end
  111. end
  112. local file = fs.open(input, "w")
  113. getContents()
  114. file.write(urlContents)
  115. useAPI(filename)
  116. end
Add Comment
Please, Sign In to add comment