LuaScripts/linkedGet.lua
2021-01-08 04:10:53 +03:00

40 lines
1 KiB
Lua

local event = require("event")
local keyboard = require("keyboard")
local component = require("component")
local fs = require("filesystem")
local tunnel = component.tunnel
local success = "команда выполнена успешно"
local fail = "неизвестная команда - пиши 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
end
function handleMessage(msg)
if message == "help" then
return success
elseif message == "rain" then
return success
else
return fail
end
end
while true do
local _, _, from, _, _, message = event.pull("modem_message")
local log = "["..os.dateRL("%x %X").."]".." "..from..": "..message.."/n"..handleMessage(message)
print(log)
local f = io.open("logs.txt", "a")
f:write(log.."/n")
f:close()
tunnel.send("succes!")
end