Advertisement
Jeyjey0

Pastebin updater

Nov 18th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. function update(name,prna)
  2. print("Searching for updates...")
  3. local function ininstaller(code,name2)
  4. local response = http.get(
  5. "http://pastebin.com/raw/"..code
  6. )
  7.  
  8. if response then
  9.  
  10. local sResponse = response.readAll()
  11. response.close()
  12. h = fs.open(name2,"w")
  13. h.write(sResponse)
  14. h.close()
  15. return sResponse
  16. else
  17. print( "Failed." )
  18. end
  19. end
  20.  
  21.  
  22. ininstaller(name,"file")
  23. h = fs.open("file","r")
  24. chfi = h.readAll()
  25. h.close()
  26. h = fs.open(prna,"r")
  27. fi = h.readAll()
  28. h.close()
  29. if chfi == fi == false then
  30. print("Updating...")
  31. fs.delete(prna)
  32. h = fs.open(prna,"w")
  33. h.write(chfi)
  34. h.close()
  35. print("Updated pls restart program")
  36. fs.delete("file")
  37. error()
  38. else
  39. print("No update")
  40. end
  41. end
  42.  
  43.  
  44.  
  45.  
  46. function updateAPI(name3,prna2)
  47. print("Searching for updates...")
  48. local function ininstaller(code,name2)
  49. local response = http.get(
  50. "http://pastebin.com/raw/"..code
  51. )
  52.  
  53. if response then
  54.  
  55. local sResponse = response.readAll()
  56. response.close()
  57. h = fs.open(name2,"w")
  58. h.write(sResponse)
  59. h.close()
  60. return sResponse
  61. else
  62. print( "Failed." )
  63. end
  64. end
  65.  
  66. ininstaller(name3,"file")
  67. h = fs.open("file","r")
  68. chfi2 = h.readAll()
  69. h.close()
  70. h = fs.open(prna2,"r")
  71. fi2 = h.readAll()
  72. h.close()
  73. if chfi == fi == false then
  74. print("Updating...")
  75. fs.delete(prna)
  76. h = fs.open(prna2,"w")
  77. h.write(chfi)
  78. h.close()
  79. fs.delete("file")
  80. os.loadAPI(prna2)
  81. error()
  82. else
  83. print("No update")
  84. end
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement