Update linkedGet.lua
This commit is contained in:
parent
1e0eb7f531
commit
ec9444f0a0
1 changed files with 22 additions and 9 deletions
|
@ -3,25 +3,38 @@ local keyboard = require("keyboard")
|
||||||
local component = require("component")
|
local component = require("component")
|
||||||
local fs = require("filesystem")
|
local fs = require("filesystem")
|
||||||
local tunnel = component.tunnel
|
local tunnel = component.tunnel
|
||||||
local TIME_ZONE = 2
|
|
||||||
local t_correction = TIME_ZONE * 3600
|
local success = "команда выполнена успешно"
|
||||||
|
local fail = "неизвестная команда - пиши help"
|
||||||
|
|
||||||
function os.dateRL(format)
|
function os.dateRL(format)
|
||||||
if not fs.get("/").isReadOnly() then
|
if not fs.get("/").isReadOnly() then
|
||||||
local time = io.open("/tmp/.time", "w")
|
local time = io.open("/tmp/.time", "w")
|
||||||
time:write()
|
time:write()
|
||||||
time:close()
|
time:close()
|
||||||
os.sleep(0.01)
|
os.sleep(0.01)
|
||||||
return os.date(format, fs.lastModified("/tmp/.time") / 1002.7)
|
return os.date(format, fs.lastModified("/tmp/.time") / 1002.7)
|
||||||
else
|
else
|
||||||
return os.date(format)
|
return os.date(format)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function handleMessage(msg)
|
||||||
|
if message == "help" then
|
||||||
|
return success
|
||||||
|
elif message == "rain"
|
||||||
|
return success
|
||||||
|
else
|
||||||
|
return fail
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local _, _, _, _, _, message = event.pull("modem_message")
|
local _, _, from, _, _, message = event.pull("modem_message")
|
||||||
local log = "["..os.dateRL("%x %X").."]".." "..message
|
local log = "["..os.dateRL("%x %X").."]".." "..from..": "..message.."/n"..handleMessage(message)
|
||||||
print(log)
|
print(log)
|
||||||
local f = io.open("logs.txt", "a")
|
local f = io.open("logs.txt", "a")
|
||||||
f:write(log)
|
f:write(log.."/n")
|
||||||
f:close()
|
f:close()
|
||||||
tunnel.send("succes!")
|
tunnel.send("succes!")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue