Advertisement
croc

Is Minecraft Down?

Oct 29th, 2018
12,226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // To be used with Scriptable for iOS
  2. // Learn more at https://scriptable.app
  3.  
  4. // Checks if Discord is down by examining
  5. // their status page. This script works
  6. // well when when triggered from a Siri
  7. // Shortcut. You can configure a Siri
  8. // Shortcut from the script settings.
  9. let url = "https://status.mojang.com/check"
  10. let r = new Request(url)
  11. let body = await r.loadJSON()
  12. Safari.openInApp(url)
  13. // Use the global variable "config" to check
  14. // if the app is run from Siri before we
  15. // speak a text.
  16. if (config.runsWithSiri) {
  17.     let table = new UITable()
  18.     table.showSeparators = true
  19.     let names = [
  20.         "Minecraft Website",
  21.         "Sessions",
  22.         "Accounts",
  23.         "Auth Servers",
  24.         "Session Servers",
  25.         "API",
  26.         "Textures",
  27.         "Mojang Website"
  28.     ]
  29.  
  30.     let count = 0
  31.  
  32.     body.forEach(function (statusObj) {
  33.         for (var key in statusObj) {
  34.             if (statusObj.hasOwnProperty(key)) {
  35.                 let row = new UITableRow()
  36.                 let name = names[count]
  37.                 if (statusObj[key] == "green") {
  38.                     let nameCell = row.addText(name, key)
  39.                     nameCell.leftAligned()
  40.                     let statusCell = row.addText("ONLINE")
  41.                     statusCell.rightAligned()
  42.                 } else {
  43.                     let nameCell = row.addText(name, key)
  44.                     nameCell.leftAligned()
  45.                     let statusCell = row.addText("OFFLINE")
  46.                     statusCell.rightAligned()
  47.                 }
  48.                 table.addRow(row)
  49.             }
  50.             count++
  51.         }
  52.     });
  53.  
  54.     table.present()
  55.  
  56.     let status = null
  57.  
  58.     if (body[3]["authserver.mojang.com"] == "green" || body[4]["sessionserver.mojang.com"] == "green") {
  59.         status = true
  60.     } else {
  61.         status = false
  62.     }
  63.  
  64.     if (status) {
  65.         Speech.speak("No")
  66.     } else {
  67.         Speech.speak("Yes")
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement