Update linkedGet.lua
This commit is contained in:
parent
23fa723a74
commit
c8ac167947
1 changed files with 15 additions and 8 deletions
|
@ -1,16 +1,23 @@
|
|||
local event = require("event")
|
||||
local keyboard = require("keyboard")
|
||||
local component = require("component")
|
||||
local internet = require("internet")
|
||||
local fs = require("filesystem")
|
||||
local tunnel = component.tunnel
|
||||
local TIME_ZONE = 2
|
||||
local t_correction = TIME_ZONE * 3600
|
||||
local function getTimeHost()
|
||||
local file = io.open('/tmp/unix.tmp', 'w')
|
||||
file:write('')
|
||||
file:close()
|
||||
local lastmod = tonumber(string.sub(fs.lastModified('UNIX.tmp'), 1, -4)) + t_correction
|
||||
local date = os.date('%x', lastmod)
|
||||
local time = os.date('%X', lastmod)
|
||||
local dt = os.date('%Y.%m.%d %H:%M:%S', lastmod)
|
||||
return dt
|
||||
end
|
||||
while true do
|
||||
local _, _, _, _, _, message = event.pull("modem_message")
|
||||
local result = ""
|
||||
local handle = internet.request("http://worldtimeapi.org/api/timezone/Europe/Moscow")
|
||||
for chunk in handle do
|
||||
result = result..chunk
|
||||
end
|
||||
local mt = getmetatable(handle)
|
||||
print(result..message)
|
||||
local date = getTimeHost()
|
||||
print("[ "..date.." ]"..message)
|
||||
tunnel.send("succes!")
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue