Update linkedGet.lua
This commit is contained in:
parent
ed999ffe4c
commit
ca9b74a530
1 changed files with 6 additions and 13 deletions
|
@ -1,23 +1,14 @@
|
||||||
local event = require("event")
|
local event = require("event")
|
||||||
local keyboard = require("keyboard")
|
local keyboard = require("keyboard")
|
||||||
local component = require("component")
|
local component = require("component")
|
||||||
local fs = require("filesystem")
|
|
||||||
local internet = require("internet")
|
|
||||||
local tunnel = component.tunnel
|
local tunnel = component.tunnel
|
||||||
|
|
||||||
local success = "console: команда выполнена успешно"
|
local success = "console: команда выполнена успешно"
|
||||||
local fail = "console: неизвестная команда - пиши help"
|
local fail = "console: неизвестная команда - пиши help"
|
||||||
|
|
||||||
function os.dateRL(format)
|
function getTime()
|
||||||
if not fs.get("/").isReadOnly() then
|
local _, _, _, _, _, time = event.pull("modem_message")
|
||||||
local time = io.open("/tmp/.time", "w")
|
return time
|
||||||
time:write()
|
|
||||||
time:close()
|
|
||||||
os.sleep(0.01)
|
|
||||||
return os.date(format, fs.lastModified("/tmp/.time") / 1002.7)
|
|
||||||
else
|
|
||||||
return os.date(format)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function handleMessage(msg)
|
function handleMessage(msg)
|
||||||
|
@ -43,7 +34,9 @@ end
|
||||||
while true do
|
while true do
|
||||||
local _, _, from, _, _, message = event.pull("modem_message")
|
local _, _, from, _, _, message = event.pull("modem_message")
|
||||||
local answer = handleMessage(tostring(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)
|
print(log)
|
||||||
local f = io.open("logs.txt", "a")
|
local f = io.open("logs.txt", "a")
|
||||||
f:write(log.."\n")
|
f:write(log.."\n")
|
||||||
|
|
Loading…
Reference in a new issue