Advertisement
wow0

Untitled

Nov 4th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. --[[||
  2. Wow's users API
  3. This API need:
  4. -Modem
  5. -StringUtilsAPI
  6.  
  7. All of the bank's servers and API are made by wow.
  8. All of the bank's graphics are made by Kuruyia.
  9. ||]]
  10.  
  11. --[[
  12. 0 = Nothing
  13. 1 = nil / bad type
  14. 2 = unknown user
  15. 3 = nil Token: Outdated
  16. 4 = Bad Token: Outdated
  17. 5 = Bad Password
  18. 6 = Bad accesslevel
  19. 7 = ?
  20. 8 = Not engouth money (RIP)
  21. 9 = Unknown User to send
  22. ]]
  23. if not fs.exists("/StringUtils") then shell.run("pastebin get ad3aUsVw StringUtils") end
  24. local channel = 644
  25. local modem = peripheral.find("modem")
  26. local encryptionPass = "1"
  27. os.loadAPI("StringUtils")
  28.  
  29. local function checkopened()
  30. if not modem.isOpen(channel) then modem.open(channel) end
  31. return true
  32. end
  33.  
  34. local function addCheck(sTable, Username, password,noSHA)
  35. local cryptoken
  36. if noSHA then
  37. cryptoken = password
  38. else
  39. cryptoken = StringUtils.encrypt(encryptionPass, password)
  40. end
  41. sTable["fromUsername"] = Username
  42. sTable["fromPassword"] = cryptoken
  43. sTable["fromId"] = os.getComputerID()
  44. return sTable
  45. end
  46.  
  47. local function send(sTable, password, Username, noSHA)
  48. checkopened()
  49. if sTable == nil then return 0x1 end
  50. local sTable = addCheck(sTable, password, Username, noSHA)
  51. modem.transmit(channel, channel, sTable)
  52. local x = true
  53. while x do
  54. local event, side, sChan, rChan, msg, distance = os.pullEvent("modem_message")
  55. if sChan == channel then
  56. x = false
  57. return msg
  58. end
  59. end
  60. end
  61. local pingInfo
  62. local function timeout()
  63. sleep(1)
  64. pingInfo = false
  65. return false
  66. end
  67.  
  68. local function localPing()
  69. local TEMP_TABLE = {type = "ping"}
  70. send(TEMP_TABLE, "ptdr", "joke")
  71. pingInfo = true
  72. return true
  73. end
  74.  
  75. function ping()
  76. parallel.waitForAny(timeout, localPing)
  77. return pingInfo
  78. end
  79.  
  80. function createUser(username, password, biolock, al, uName, uPassword) --Will be removed in future (RIP)
  81. if username == nil or password == nil or biolock == nil or type(al) ~= "number" or type(uName) ~= "string" or type(uPassword) ~= "string" then
  82. return 0x1
  83. else
  84. local TEMP_TABLE = {type = "database", todo = "createUser", Username = username, Password = password, Biolock = biolock, accesslevel = al}
  85. local lol = textutils.serialise(TEMP_TABLE)
  86. return send(TEMP_TABLE, uName, uPassword)
  87. end
  88. end
  89.  
  90. local function resetDB(uName, uPassword) --Will be removed in the future (Only for beta)
  91. if type(uName) ~= "string" or type(uPassword) ~= "string" then return 0x1 end
  92. local TEMP_TABLE = {type = "database", todo = "reset"}
  93. return send(TEMP_TABLE, uName,uPassword)
  94. end
  95.  
  96. function getInfo(uName, uPassword)
  97. if type(uName) ~= "string" or type(uPassword) ~= "string" then
  98. return 0x1
  99. else
  100. local TEMP_TABLE = {type = "database", todo = "Userinfo"}
  101. return send(TEMP_TABLE, uName, uPassword)
  102. end
  103. end
  104.  
  105. function updateInfo(whatupdate, new, who, uName, uPassword)
  106. if type(whatupdate) ~= "string" or type(new) ~= "string" or type(who) ~= "string" or type(uName) ~= "string" or type(uPassword) ~= "string" then return 0x5 end
  107. local TEMP_TABLE = {type = "database", todo = "update", toupdate = whatupdate, newupdate = new, who = who}
  108. return send(TEMP_TABLE, uName, uPassword)
  109. end --Not finished
  110. --Mark 1
  111.  
  112. local function findBiolock(bioID, uName, uPassword)
  113. if type(bioID) ~= "string" or type(uName) ~= "string" or type(uPassword) ~= "string" then return 0x1 end
  114. local TEMP_TABLE = {type = "database", todo = "findBL", toFind = bioID}
  115. return send(TEMP_TABLE, uName, uPassword)
  116. end --Mark 2
  117.  
  118. function sendMoney(samount, sto, uName, uPassword)
  119. if type(samount) ~= "number" or type(sto) ~= "string" or type(uName) ~= "string" or type(uPassword) ~= "string" then return 0x1 end
  120. local TEMP_TABLE = {type = "transaction", amount = samount, to = sto}
  121. return send(TEMP_TABLE, uName, uPassword)
  122. end
  123.  
  124. function sendMoneyNoSHA(samount, sto, uName, uPassword)
  125. if type(samount) ~= "number" or type(sto) ~= "string" or type(uName) ~= "string" or type(uPassword) ~= "string" then return 0x1 end
  126. local TEMP_TABLE = {type = "transaction", amount = samount, to = sto}
  127. return send(TEMP_TABLE, uName, uPassword, true)
  128. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement