Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fs = require('filesystem')
- chat = require('component').chat_box
- event = require('event')
- cmp = require('component')
- isNetwork = false
- args = {}
- function getRealTime(e123q)
- local handel = io.open("/time", "w")
- handel:close()
- local timestamp = fs.lastModified("/time") / 1000 + 4
- return timestamp
- end
- function answer()
- if isNetwork == true then
- _, _, _, _, _, e1,e2 = event.pull('modem_message')
- if e1 == 'chat_message' then
- return e2
- end
- else
- _,_,_,message = event.pull('chat_message')
- return message
- end
- end
- function say(message)
- if isNetwork == false then
- chat.say(message)
- else
- modem.broadcast(port,'tosay',message)
- end
- end
- local a = io.open('/timestamp.dat','r')
- local time = tonumber(a:read())
- a:close()
- print(getRealTime())
- print(time)
- if os.date('%d',getRealTime()) > os.date('%d',time) then
- a = io.open('/timestamp.dat',"w")
- a:write(getRealTime())
- a:close()
- print('Просмотрю обновление...')
- args[1] = 'get' args[2] = 'fKAgn16d' args[3] = '/tmp/Angela_version.dat'
- os.execute('/bin/pastebin.lua')
- local a = io.open('/usr/version.dat','r')
- curversion = a:read()
- a:close()
- local a = io.open('/tmp/Angela_version.dat','r')
- actversion = a:read()
- a:close()
- if tonumber(curversion) < tonumber(actversion) then
- say('Нашла обновление. Устанавливаю.')
- args[2] = 'MaBDZ6j4' args[3] = '/home/chat_box'
- os.execute('/bin/pastebin.lua')
- a = io.open('/usr/version.dat',"w")
- a:write(actversion)
- a:close()
- require('computer').shutdown(true)
- else
- require('term').clear()
- end
- fs.remove('/tmp/Angela_version.dat')
- end
- while true do
- e1 = answer()
- tbl = {}
- if type(e1) == 'string' then
- for part in string.gmatch(e1,"[^ ]+") do
- table.insert(tbl, part)
- end
- if tbl[1] == '!' then
- if tbl[2] == 'network' then
- if cmp.isAvailable('modem') == true then
- if isNetwork == false then
- say('Какой бы вы предпочли порт?')
- port = tonumber(answer())
- modem = cmp.modem
- modem.open(port)
- isNetwork = true
- else
- isNetworl = false
- modem.close(port) port = nil
- end
- else
- say('Вам нужна беспроводная плата.')
- end
- else
- args= {}
- for i = 3,#tbl do
- table.insert(args,tbl[i])
- end
- say('Запускаю программу по пути: /home/'..tbl[2])
- ifsucces, reason = pcall(function() end)
- os.execute('/home/'..tbl[2])
- if ifsucces == false or ifsucces == nil then
- say(reason)
- print('err')
- end
- end end end
- end
- -- ! внимание германия, к этой программе еще прилагается add который добавляет файл к функций компонента, сейчас надобности его сюда монтировать нету.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement