From ca9b74a5303d1ecc521baa5a5480b379e94386f2 Mon Sep 17 00:00:00 2001 From: erius0 <63460770+erius0@users.noreply.github.com> Date: Fri, 8 Jan 2021 17:09:44 +0300 Subject: [PATCH] Update linkedGet.lua --- linkedGet.lua | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/linkedGet.lua b/linkedGet.lua index a08e3d3..5440dcb 100644 --- a/linkedGet.lua +++ b/linkedGet.lua @@ -1,23 +1,14 @@ local event = require("event") local keyboard = require("keyboard") local component = require("component") -local fs = require("filesystem") -local internet = require("internet") local tunnel = component.tunnel local success = "console: команда выполнена успешно" local fail = "console: неизвестная команда - пиши help" -function os.dateRL(format) - if not fs.get("/").isReadOnly() then - local time = io.open("/tmp/.time", "w") - time:write() - time:close() - os.sleep(0.01) - return os.date(format, fs.lastModified("/tmp/.time") / 1002.7) - else - return os.date(format) - end +function getTime() + local _, _, _, _, _, time = event.pull("modem_message") + return time end function handleMessage(msg) @@ -43,7 +34,9 @@ end while true do local _, _, from, _, _, message = event.pull("modem_message") local answer = handleMessage(tostring(message)) - local log = "["..os.dateRL("%x %X").."] "..getUser(tostring(from))..": "..message.."\n".."["..os.dateRL("%x %X").."] "..answer + local time = getTime() + local user = getUser(tostring(from)) + local log = "["..time.."] "..user..": "..message.."\n".."["..time.."] "..answer print(log) local f = io.open("logs.txt", "a") f:write(log.."\n")