Anavrins

kpatch

Jan 2nd, 2016
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.84 KB | None | 0 0
  1. local arg = {...}
  2.  
  3. local repl = {
  4.     ["local gui = 0"] = {
  5.         "local aliases = {}", -- Variable to store aliases
  6.         "local page = 0",
  7.     },
  8.     ["    openwallet()"] = {
  9.         '    aliases = textutils.unserialize(readconfig("aliases"))', -- Loads alliases from config kst/aliases
  10.         "    while page ~= 0 do",
  11.     },
  12.     ['    checkfile("autoupdate","true")'] = {
  13.         '    checkfile("aliases","-- Aliases are case sensitive\\n"..textutils.serialize({anavrins = "kanavi35hk", Mayu = "kzezw94nx3"}))', -- Default content of kst/aliases
  14.         '    checkfile("whitelisted","false")',
  15.     },
  16.     ["      local recipient = read()"] = {
  17.         "      recipient = aliases[recipient] or recipient", -- Alias functionality for transfer
  18.         "      term.setCursorPos(33,6)",
  19.     },
  20.     ["    subject = read()"] = {
  21.         "    subject = aliases[subject] or subject", -- Alias functionality for address lookup
  22.         "    if string.len(subject) == 10 then",
  23.     },
  24.     ["      maxspace = read():lower()"] = {
  25.         "      maxspace = aliases[maxspace] or maxspace", -- Alias functionality for domain transfer
  26.         "      term.setCursorPos(19,7)",
  27.     },
  28. }
  29.  
  30. shell.run("clr")
  31. print("KristPatch, by Anavrins")
  32. print("Adds address aliases")
  33. print("Tested to work with Kristwallet v16")
  34. print("\nPress a key to continue")
  35. os.pullEvent("key")
  36.  
  37. shell.run("clr")
  38. print("Downloading wallet")
  39. local web = http.get("https://raw.githubusercontent.com/BTCTaras/kristwallet/master/kristwallet")
  40. local lines = {}
  41. for line in web.readLine do
  42.     lines[#lines+1] = line
  43. end
  44. web.close()
  45.  
  46. local s = 0
  47. for i, line in pairs(lines) do
  48.     if repl[line] and repl[line][2] == lines[i+1] then
  49.         print("Patching line:", i)
  50.         table.insert(lines, i+1, repl[line][1])
  51.         s = s + 1
  52.     end
  53. end
  54. print("Patched "..s.." out of 6 lines")
  55.  
  56. local file = fs.open("kristwallet_aliases", "w")
  57. for i, line in pairs(lines) do
  58.     file.writeLine(line)
  59. end
  60. file.close()
Advertisement
Add Comment
Please, Sign In to add comment