Advertisement
alexexe82

pasteb.lua

Sep 17th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.37 KB | None | 0 0
  1. require("advancedLua")
  2. local component = require("component")
  3. local event = require("event")
  4. local term = require("term")
  5. local unicode = require("unicode")
  6. local ecs = require("ECSAPI")
  7. local fs = require("filesystem")
  8. local shell = require("shell")
  9. local internet = require("internet")
  10. local context = require("context")
  11. local xml = require("xmlParser")
  12. local unixtime = require("unixtime")
  13. local SHA2 = require("SHA2")
  14. -- local computer = require("computer")
  15. -- local keyboard = require("keyboard")
  16. -- local image = require("image")
  17.  
  18. local gpu = component.gpu
  19.  
  20. --//replace 1,3,12,11,13,7,16,15,14,582,56,73,166,165,21,167,168,228,229,10,11 0
  21. --
  22. --------------------------------------------------------------------------------------------------------------------------
  23.  
  24. local xSize, ySize = gpu.getResolution()
  25. local centerX, centerY = math.floor(xSize / 2), math.floor(ySize / 2)
  26.  
  27. local username = nil
  28. local password = nil
  29.  
  30. local userkey = nil
  31. local devKey = "e98db6da803203282d172156bc46137c"
  32. local pastebin_url = nil
  33.  
  34. local isNotLoggedIn = true
  35.  
  36. local pathToConfig = "System/Pastebin/Login.cfg"
  37.  
  38. --МАССИВ СО ВСЕМИ ПАСТАМИ С ПАСТЕБИНА
  39. local MyMassivWithPastes = {}
  40. local drawPastesFrom = 1
  41.  
  42. local tabColor1 = 0x103258
  43. local tabColor2 = 0x034879
  44. local tabTextColor = 0xffffff
  45.  
  46. --------------------------------------------------------------------------------------------------------------------------
  47.  
  48. --СОЗДАНИЕ ОБЪЕКТОВ
  49. local obj = {}
  50. local function newObj(class, name, ...)
  51.     obj[class] = obj[class] or {}
  52.     obj[class][name] = {...}
  53. end
  54.  
  55. --ЗАГРУЗИТЬ ФАЙЛ С ПАСТЕБИНА
  56. local function get(pasteId, filename)
  57.   local f, reason = io.open(filename, "w")
  58.   if not f then
  59.     io.stderr:write("Failed opening file for writing: " .. reason)
  60.     return
  61.   end
  62.  
  63.   --io.write("Downloading from pastebin.com... ")
  64.   local url = "http://pastebin.com/raw.php?i=" .. pasteId
  65.   local result, response = pcall(internet.request, url)
  66.   if result then
  67.     --io.write("success.\n")
  68.     for chunk in response do
  69.       --if not options.k then
  70.         chunk = string.gsub(chunk, "\r\n", "\n")
  71.         chunk = string.gsub(chunk, "    ", "  ")
  72.       --end
  73.       f:write(chunk)
  74.     end
  75.  
  76.     f:close()
  77.     --io.write("Saved data to " .. filename .. "\n")
  78.   else
  79.     --io.write("failed.\n")
  80.     f:close()
  81.     fs.remove(filename)
  82.     io.stderr:write("HTTP request failed: " .. response .. "\n")
  83.   end
  84. end
  85.  
  86. -- This makes a string safe for being used in a URL.
  87. local function encode(code)
  88.   if code then
  89.     code = string.gsub(code, "([^%w ])", function (c)
  90.       return string.format("%%%02X", string.byte(c))
  91.     end)
  92.     code = string.gsub(code, " ", "+")
  93.   end
  94.   return code
  95. end
  96.  
  97.  
  98.  
  99. --Удалить файлецкий
  100. local function delete(paste)
  101.     local result, response = pcall(internet.request,
  102.         "http://pastebin.com/api/api_post.php",
  103.         "api_option=delete&"..
  104.         "api_dev_key="..devKey.."&"..
  105.         "api_user_key="..userKey.."&"..
  106.         "api_paste_key="..paste
  107.     )
  108.  
  109.     if result then
  110.         return true
  111.     else
  112.         ecs.error("Отсутствует соединение с Pastebin.com")
  113.         return false
  114.     end
  115. end
  116.  
  117. --ЗАЛОГИНИТЬСЯ В АККАУНТ
  118. local function loginToAccount(username, password)
  119.  
  120.     --print("Логинюсь в пастебине... ")
  121.     local result, response = pcall(internet.request,
  122.         "http://pastebin.com/api/api_login.php",
  123.         "api_dev_key="..devKey..
  124.         "&api_user_name="..username..
  125.         "&api_user_password="..password
  126.     )
  127.  
  128.     if result then
  129.         --print("Запрос на пастебин пришел!")
  130.         local info = ""
  131.         for chunk in response do
  132.             info = info .. chunk
  133.         end
  134.         if string.match(info, "^Bad API request, ") then
  135.             --io.write(info)
  136.             return false, info
  137.         --ЕСЛИ ВСЕ ЗАЕБОК
  138.         else
  139.             --print("Получен юзеркей!")
  140.             userKey = info
  141.             --print("Вот так оно выглядит: "..info)
  142.             return true
  143.         end
  144.     else
  145.         --print("Хуйня произошла. Либо URL неверный, либо пастебин недоступен.\n")
  146.         --io.stderr:write(response)
  147.         return false, response
  148.     end
  149.  
  150. end
  151.  
  152. --ЗАГРУЗКА СПИСКА ФАЙЛОВ
  153. local function getFileListFromPastebin(countOfFilesToShow)
  154.     local result, response = pcall(internet.request,
  155.         "http://pastebin.com/api/api_post.php",
  156.         "api_dev_key="..devKey..
  157.         "&api_user_key="..userKey..
  158.         "&api_results_limit="..countOfFilesToShow..
  159.         "&api_option=list"
  160.     )
  161.  
  162.     --КИНУТЬ ОШИБКУ, ЕСЛИ ЧЕТ НЕ ТАК
  163.     if not result then io.stderr:write( response ) end
  164.  
  165.     --ПРОЧИТАТЬ ОТВЕТ С СЕРВЕРА ПАСТЕБИНА
  166.     local info = ""
  167.     for chunk in response do
  168.         info = info .. chunk
  169.     end
  170.  
  171.     --РАСПАСИТЬ ХМЛ
  172.     local x = xml.collect(info)
  173.  
  174.     --ЗАХУЯРИТЬ МАССИВ С ПАСТАМИ
  175.     MyMassivWithPastes = {}
  176.     for pasteID = 1, #x do
  177.         MyMassivWithPastes[pasteID]={}
  178.         MyMassivWithPastes[pasteID]["paste_key"] = x[pasteID][1][1]
  179.         MyMassivWithPastes[pasteID]["paste_date"] = x[pasteID][2][1]
  180.         MyMassivWithPastes[pasteID]["paste_title"] = x[pasteID][3][1]
  181.         MyMassivWithPastes[pasteID]["paste_size"] = x[pasteID][4][1]
  182.         MyMassivWithPastes[pasteID]["paste_expire_date"] = x[pasteID][5][1]
  183.         MyMassivWithPastes[pasteID]["paste_private"] = x[pasteID][6][1]
  184.         MyMassivWithPastes[pasteID]["paste_format_long"] = x[pasteID][7][1]
  185.         MyMassivWithPastes[pasteID]["paste_format_short"] = x[pasteID][8][1]
  186.         MyMassivWithPastes[pasteID]["paste_url"] = x[pasteID][9][1]
  187.         MyMassivWithPastes[pasteID]["paste_hits"] = x[pasteID][10][1]
  188.     end
  189. end
  190.  
  191. local xPos, yPos
  192. local widthTitle
  193. local widthOthers
  194. local xDate
  195. local xDownloads
  196. local xSyntax
  197. local maxPastesCountToShow = math.floor((ySize - 7) / 2)
  198.  
  199. local function displayPaste(i, background, foreground)
  200.  
  201.     ecs.square(1, yPos, xSize - 2, 1, background)
  202.  
  203.     --Нарисовать цветной кружочек
  204.     local color = ecs.colors.green
  205.     if tonumber(MyMassivWithPastes[i]["paste_private"]) == 1 then
  206.         color = ecs.colors.red
  207.     end
  208.     ecs.colorText(xPos, yPos, color, "●")
  209.     color = nil
  210.  
  211.     --Нарисовать имя пасты
  212.     ecs.colorText(xPos + 2, yPos, foreground, ecs.stringLimit("end", MyMassivWithPastes[i]["paste_title"], widthTitle - 3))
  213.    
  214.     --Нарисовать дату пасты
  215.     local date = unixtime.convert(tonumber(MyMassivWithPastes[i]["paste_date"]))
  216.     gpu.set(xDate, yPos, date)
  217.  
  218.     --Нарисовать Хитсы
  219.     gpu.set(xDownloads, yPos, MyMassivWithPastes[i]["paste_hits"])
  220.  
  221.     --Нарисовать формат
  222.     gpu.set(xSyntax, yPos, MyMassivWithPastes[i]["paste_format_long"])
  223. end
  224.  
  225. --Нарисовать пасты
  226. local function displayPastes(from)
  227.  
  228.     obj["Pastes"] = nil
  229.  
  230.     --Стартовые коорды
  231.     xPos, yPos = 2, 6
  232.  
  233.     --Размеры таблицы
  234.     widthTitle = math.floor((xSize - 2) / 2) + 5
  235.     widthOthers = math.floor((xSize - 2 - widthTitle) / 3)
  236.     xDate = xPos + widthTitle
  237.     xDownloads = xDate + widthOthers
  238.     xSyntax = xDownloads + widthOthers
  239.  
  240.     --Цвет фона на нужный сразу
  241.     gpu.setBackground(0xffffff)
  242.  
  243.     --Стартовая инфотаблица - ну, имя там, размер, дата и прочее
  244.     ecs.colorText(xPos, yPos, 0x990000, "Имя")
  245.     gpu.set(xDate, yPos, "Дата")
  246.     gpu.set(xDownloads, yPos, "Скачиваний")
  247.     gpu.set(xSyntax, yPos, "Синтакс")
  248.  
  249.     ecs.colorText(1, yPos + 1, 0x990000, string.rep("─", xSize - 2))
  250.     yPos = yPos + 2
  251.  
  252.     ecs.srollBar(xSize - 1, 6, 2, ySize - 5, #MyMassivWithPastes, from, 0xcccccc, ecs.colors.blue)
  253.  
  254.     --Все пасты рисуем
  255.     for i = from, (from + maxPastesCountToShow - 1) do
  256.  
  257.         if MyMassivWithPastes[i] then
  258.             displayPaste(i, 0xffffff, 0x000000)
  259.  
  260.             newObj("Pastes", i, 1, yPos, xSize - 2, yPos)
  261.  
  262.             --Нарисовать разделитель
  263.             if i ~= (from + maxPastesCountToShow - 1) then ecs.colorText(1, yPos + 1, 0xcccccc, string.rep("─", xSize - 2)) end
  264.         else
  265.             ecs.square(1, yPos, xSize - 2, 2, 0xffffff)
  266.         end
  267.  
  268.         yPos = yPos + 2
  269.     end
  270. end
  271.  
  272. local function getRandomCifri(length)
  273.     local cifri = ""
  274.     for i = 1, length do
  275.         cifri = cifri .. tostring(math.random(0, 1))
  276.     end
  277.     return cifri
  278. end
  279.  
  280. local function drawTopBar()
  281.  
  282.     --Полосочки
  283.     ecs.square(1, 1, xSize, 1, tabColor1)
  284.  
  285.     gpu.setBackground(tabColor2)
  286.     gpu.setForeground( tabColor1 )
  287.     gpu.fill(1, 2, xSize, 3, "░")
  288.  
  289.     ecs.square(1, 5, xSize, 1, tabColor1)
  290.  
  291.     --Листочек
  292.     local sheetWidth = 6
  293.     gpu.setForeground(0x000000)
  294.     gpu.setBackground(0xffffff)
  295.  
  296.     gpu.set(2, 2, getRandomCifri(sheetWidth))
  297.     gpu.set(3, 3, getRandomCifri(sheetWidth))
  298.     gpu.set(4, 4, getRandomCifri(sheetWidth))
  299.  
  300.     --Надписи всякие
  301.     ecs.colorTextWithBack(2, 1, tabColor2, tabColor1, "#1 paste tool since 2002")
  302.     ecs.colorTextWithBack(11, 3, tabTextColor, tabColor2, "PASTEBIN")
  303.     local name = "⛨Загрузить новый файл"; newObj("TopButtons", name, ecs.drawAdaptiveButton(1, 5, 1, 0, name, tabColor1, tabTextColor))
  304.    
  305.     local xPos = xSize - 23
  306.     if username then
  307.         name = "Разлогиниться"; newObj("TopButtons", name, ecs.drawAdaptiveButton(xPos, 5, 1, 0, name, tabColor1, tabTextColor)); xPos = xPos + unicode.len(name) + 3
  308.         name = "Выход"; newObj("TopButtons", name, ecs.drawAdaptiveButton(xPos, 5, 1, 0, name, tabColor1, tabTextColor)); xPos = xPos + unicode.len(name) + 3
  309.  
  310.         --Никнейм
  311.         ecs.colorTextWithBack(xSize - 1 - unicode.len(username), 3, tabTextColor, tabColor2, username)
  312.     end
  313. end
  314.  
  315. local function clear()
  316.     ecs.square(1, 6, xSize, ySize, 0xffffff)
  317. end
  318.  
  319. local function inputPassword()
  320.     --local massiv = ecs.input("auto", "auto", 20, "Войти в Pastebin", {"input", "Логин", ""},  {"input", "Пароль", ""})
  321.  
  322.     local data = ecs.universalWindow("auto", "auto", 24, tabColor1, true, {"EmptyLine"}, {"CenterText", 0xffffff, "Авторизация"}, {"EmptyLine"}, {"Input", 0xffffff, 0xccccff, "Логин"}, {"Input", 0xffffff, 0xccccff, "Пароль", "●"}, {"EmptyLine"}, {"Button", {tabColor2, 0xffffff, "Войти в аккаунт"}, {0x006dbf, 0xffffff, "Отмена"}})
  323.  
  324.     if data[3] == "Отмена" then return false end
  325.  
  326.     username = data[1] or ""
  327.     password = data[2] or ""
  328.     clear()
  329.  
  330.     return true
  331. end
  332.  
  333. local function analyseConfig()
  334.     if fs.exists(pathToConfig) then
  335.         local massiv = table.fromFile(pathToConfig)
  336.         username = massiv.username
  337.         password = massiv.password
  338.         massiv = nil
  339.     else
  340.         fs.makeDirectory(fs.path(pathToConfig))
  341.         local success = inputPassword()
  342.         if not success then return false end
  343.         table.toFile(pathToConfig, {username = username, password = password})
  344.     end
  345.  
  346.     return true
  347. end
  348.  
  349. local function waitForSuccessLogin()
  350.     while true do
  351.  
  352.         local success = analyseConfig()
  353.         if not success then return false end
  354.         ecs.info("auto", "auto", " ", "Захожу в аккаунт...")
  355.         local success, reason = loginToAccount(username, password)
  356.  
  357.         if success then
  358.             break
  359.         else
  360.             if string.match(reason, "^Bad API request, ") then
  361.                 reason = string.sub(reason, 18, -1)
  362.             end
  363.  
  364.             if reason == "invalid login" then fs.remove(pathToConfig); ecs.error("Неверное сочетание логин/пароль!"); clear() end
  365.         end
  366.        
  367.     end
  368.  
  369.     return true
  370. end
  371.  
  372. local function drawAll()
  373.     ecs.clearScreen(0xffffff)
  374.     drawTopBar()
  375. end
  376.  
  377. local function viewPaste(i)
  378.     local id = MyMassivWithPastes[i]["paste_key"]
  379.     local tmp = "System/Pastebin/tempfile.lua"
  380.     ecs.info("auto", "auto", " ", "Загружаю файл...")
  381.     os.sleep(0.3)
  382.     get(id, tmp)
  383.  
  384.     local file = io.open(tmp, "r")
  385.     local lines = {}
  386.     for line in file:lines() do
  387.         table.insert(lines, line)
  388.     end
  389.     file:close()
  390.  
  391.     ecs.clearScreen(0xffffff)
  392.  
  393.     local from = 1
  394.  
  395.     local back = 0xbbbbbb
  396.  
  397.     ecs.square(1, 1, xSize, 1, back)
  398.     gpu.setForeground(0xffffff)
  399.     ecs.centerText("x", 1, "Просмотр "..id)
  400.     ecs.colorTextWithBack(xSize, 1, 0x000000, back, "X")
  401.  
  402.     --ecs.error("#lines = ".. #lines)
  403.  
  404.     ecs.textField(1, 2, xSize, ySize - 1, lines, from, 0xffffff, 0x262626, 0xdddddd, ecs.colors.blue)
  405.  
  406.     fs.remove(tmp)
  407.  
  408.     while true do
  409.         local e = {event.pull()}
  410.         if e[1] == "scroll" then
  411.             if e[5] == 1 then
  412.                 if from > 1 then from = from - 1; ecs.textField(1, 2, xSize, ySize - 1, lines, from, 0xffffff, 0x262626, 0xdddddd, ecs.colors.blue) end
  413.             else
  414.                 if from < #lines then from = from + 1; ecs.textField(1, 2, xSize, ySize - 1, lines, from, 0xffffff, 0x262626, 0xdddddd, ecs.colors.blue) end
  415.             end
  416.         elseif e[1] == "touch" then
  417.             if e[3] == (xSize) and e[4] == 1 then
  418.                 ecs.colorTextWithBack(xSize, 1, 0xffffff, back, "X")
  419.                 os.sleep(0.3)
  420.                 return
  421.             end
  422.         end
  423.     end
  424. end
  425.  
  426. local function launch(i)
  427.     local tmp = "System/Pastebin/tempfile.lua"
  428.     ecs.info("auto", "auto", " ", "Загружаю файл...")
  429.     get(MyMassivWithPastes[i]["paste_key"], tmp)
  430.  
  431.     ecs.prepareToExit()
  432.     local s, r = shell.execute(tmp)
  433.     if not s then
  434.         ecs.displayCompileMessage(1, r, true, false)
  435.     else
  436.         ecs.prepareToExit()
  437.         print("Программа выполнена успешно. Нажмите любую клавишу, чтобы продолжить.")
  438.         ecs.waitForTouchOrClick()
  439.     end
  440.  
  441.  
  442.  
  443.     fs.remove(tmp)
  444. end
  445.  
  446. --ЗАГРУЗИТЬ ФАЙЛ НА ПАСТЕБИН
  447. local function upload(path, title)
  448.     ecs.info("auto", "auto", " ", "Загружаю \""..fs.name(path).."\"...")
  449.     local file = io.open(path, "r")
  450.     local sText = file:read("*a")
  451.     file:close()
  452.    
  453.     local result, response = pcall(internet.request,
  454.         "http://pastebin.com/api/api_post.php",
  455.         "api_option=paste&"..
  456.         "api_dev_key="..devKey.."&"..
  457.         "api_user_key="..userKey.."&"..
  458.         "api_paste_private=0&"..
  459.         "api_paste_format=lua&"..
  460.         "api_paste_name="..encode(title).."&"..
  461.         "api_paste_code="..encode(sText)
  462.     )
  463.        
  464.     if result then
  465.         --ecs.error(response)
  466.     else
  467.         ecs.error("Отсутствует соединение с Pastebin.com")
  468.         return false
  469.     end
  470. end
  471.  
  472.  
  473. --------------------------------------------------------------------------------------------------------------------------
  474.  
  475. local pasteLoadLimit = 50
  476. local args = {...}
  477.  
  478. drawAll()
  479. if not waitForSuccessLogin() then ecs.prepareToExit(); return true end
  480. drawTopBar()
  481.  
  482. if #args > 1 then
  483.     if args[1] == "upload" or args[1] == "load" then
  484.         if fs.exists(args[2]) and not fs.isDirectory(args[2]) then
  485.             upload(args[2], fs.name(args[2]))
  486.             os.sleep(5) -- Ждем, пока 100% прогрузится апи пастебина
  487.         else
  488.             ecs.error("Файл не существует или является директорией.")
  489.             return
  490.         end
  491.     end
  492. end
  493.  
  494. ecs.info("auto", "auto", " ", "Получаю список файлов...")
  495. getFileListFromPastebin(pasteLoadLimit)
  496.  
  497. displayPastes(drawPastesFrom)
  498.  
  499. while true do
  500.     local e = {event.pull()}
  501.     if e[1] == "scroll" then
  502.         if e[5] == 1 then
  503.             if drawPastesFrom > 1 then drawPastesFrom = drawPastesFrom - 1; displayPastes(drawPastesFrom) end
  504.         else
  505.             if drawPastesFrom < pasteLoadLimit then drawPastesFrom = drawPastesFrom + 1; displayPastes(drawPastesFrom) end
  506.         end
  507.     elseif e[1] == "touch" then
  508.         for key, val in pairs(obj["Pastes"]) do
  509.             if ecs.clickedAtArea(e[3], e[4], obj["Pastes"][key][1], obj["Pastes"][key][2], obj["Pastes"][key][3], obj["Pastes"][key][4] ) then
  510.                 --ecs.error("key = "..key)
  511.                 yPos = obj["Pastes"][key][2]
  512.                 displayPaste(key, ecs.colors.blue, 0xffffff)
  513.  
  514.                 if e[5] == 1 then
  515.                     local action = context.menu(e[3], e[4], {"Просмотр"}, "-", {"Запустить"}, {"Сохранить как"}, "-",{"Удалить"})
  516.  
  517.                     if action == "Сохранить как" then
  518.                         local data = ecs.universalWindow("auto", "auto", 36, tabColor1, true, {"EmptyLine"}, {"CenterText", 0xffffff, "Сохранить как"}, {"EmptyLine"}, {"Input", 0xffffff, 0xccccff, "Имя"}, {"EmptyLine"}, {"Button", {0xffffff, 0xccccff, "OK"}} )
  519.                         local path = data[1]
  520.                         if path ~= nil or path ~= "" or path ~= " " then
  521.                             fs.makeDirectory(fs.path(path))
  522.                             local action2 = ecs.askForReplaceFile(path)
  523.                             ecs.info("auto", "auto", " ", "Загружаю файл...")
  524.                             if action2 == nil or action2 == "replace" then
  525.                                 fs.remove(path)
  526.                                 get(MyMassivWithPastes[key]["paste_key"], path)
  527.                                 ecs.select("auto", "auto", " ", {{"Загрузка завершена."}}, {{"Заебись!"}})
  528.                             elseif action2 == "keepBoth" then
  529.                                 get(MyMassivWithPastes[key]["paste_key"], fs.path(path).."(copy)"..fs.name(path))
  530.                             end
  531.                             drawAll()
  532.                             displayPastes(drawPastesFrom)
  533.                         else
  534.                             ecs.error("Сохранение не удалось: не указан путь.")
  535.                         end
  536.                     elseif action == "Удалить" then
  537.                         ecs.info("auto", "auto", " ", "Удаляю файл...")
  538.                         delete(MyMassivWithPastes[key]["paste_key"])
  539.                         os.sleep(5)
  540.                         ecs.info("auto", "auto", " ", "Перезагружаю список файлов...")
  541.                         getFileListFromPastebin(pasteLoadLimit)
  542.                         drawAll()
  543.                         displayPastes(drawPastesFrom)
  544.                     elseif action == "Просмотр" then
  545.                         viewPaste(key)
  546.                         drawAll()
  547.                         displayPastes(drawPastesFrom)
  548.                     elseif action == "Запустить" then
  549.                         launch(key)
  550.                         drawAll()
  551.                         displayPastes(drawPastesFrom)
  552.                     end
  553.  
  554.                     displayPaste(key, 0xffffff, 0x000000)
  555.                 else
  556.                     --os.sleep(0.3)
  557.                     viewPaste(key)
  558.                     drawAll()
  559.                     displayPastes(drawPastesFrom)
  560.                 end
  561.  
  562.                 break
  563.             end
  564.         end
  565.  
  566.         for key, val in pairs(obj["TopButtons"]) do
  567.             if ecs.clickedAtArea(e[3], e[4], obj["TopButtons"][key][1], obj["TopButtons"][key][2], obj["TopButtons"][key][3], obj["TopButtons"][key][4] ) then
  568.                 ecs.drawAdaptiveButton(obj["TopButtons"][key][1], obj["TopButtons"][key][2], 1, 0, key, tabColor2, tabTextColor)
  569.  
  570.                 os.sleep(0.3)
  571.  
  572.                 if key == "Разлогиниться" then
  573.                     fs.remove("System/Pastebin/Login.cfg")
  574.                     drawAll()
  575.                     if not waitForSuccessLogin() then
  576.                         ecs.prepareToExit()
  577.                         return true    
  578.                     end
  579.                     drawTopBar()
  580.                     ecs.info("auto", "auto", " ", "Получаю список файлов...")
  581.                     getFileListFromPastebin(pasteLoadLimit)
  582.                     drawAll()
  583.                     displayPastes(drawPastesFrom)
  584.                 elseif key == "⛨Загрузить новый файл" then
  585.                     local data = ecs.universalWindow("auto", "auto", 36, tabColor1, true, {"EmptyLine"}, {"CenterText", 0xffffff, "Загрузить на Pastebin"}, {"EmptyLine"}, {"Input", 0xffffff, 0xccccff, "Путь к файлу"}, {"Input", 0xffffff, 0xccccff, "Имя на Pastebin"}, {"EmptyLine"}, {"Button", {tabColor2, 0xffffff, "OK"}})
  586.                     if fs.exists(data[1]) then
  587.                         if not fs.isDirectory(data[1]) then
  588.                             upload(data[1], data[2] or "Untitled")
  589.                             os.sleep(5)
  590.                             ecs.info("auto", "auto", " ", "Перезагружаю список файлов...")
  591.                            
  592.                             getFileListFromPastebin(pasteLoadLimit)
  593.                             drawAll()
  594.                             drawPastesFrom = 1
  595.                             displayPastes(drawPastesFrom)
  596.                         else
  597.                             ecs.error("Нельзя загружать папки.")
  598.                         end
  599.                     else
  600.                         ecs.error("Файл \""..fs.name(data[1]).."\" не существует.")
  601.                     end
  602.                 elseif key == "Выход" then
  603.                     ecs.prepareToExit()
  604.                     return true
  605.                 end
  606.  
  607.                 drawTopBar()
  608.  
  609.                 break
  610.             end
  611.         end
  612.     end
  613. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement