Advertisement
osmarks

PotatOS Tetrahedron - potatoAPI

Dec 14th, 2019
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local run = shell.run
  2.  
  3. local lib = {}
  4.  
  5. -- Get data which is probably sufficient to uniquely identify a computer on a server.
  6. function lib.get_host()
  7.     return {
  8.         label = os.getComputerLabel(),
  9.         ID = os.getComputerID(),
  10.         lua_version = _VERSION,
  11.         CC_host = _HOST,
  12.         build = _G.build_number,
  13.         craftOS_version = os.version(),
  14.         debug_available = _G.debug ~= nil,
  15.         ingame_location = lib.location
  16.     }
  17. end
  18.  
  19. -- Reports provided incidents to Santa, or possibly just me. Not Steve. See xkcd.com/838. Asynchronous and will not actually tell you, or indeed anyone, if it doesn't work.
  20. function lib.report_incident(incident, notify)
  21.     local json = require "json"
  22.     if type(incident) ~= "string" then error "incident description must be string" end
  23.     http.request("https://osmarks.tk/wsthing/report", json.encode({ report = incident, host = get_host() }), {["content-type"] = "application/json"})
  24.     if notify then print "This incident has been reported." end
  25. end
  26.  
  27. function lib.update() run "autorun update" end
  28.  
  29. return lib
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement