1
0
mirror of https://github.com/kepler155c/opus synced 2024-11-14 20:54:50 +00:00
opus/sys/services/chat.lua

44 lines
986 B
Lua
Raw Normal View History

2017-10-11 15:37:52 +00:00
local device = _G.device
local multishell = _ENV.multishell
local os = _G.os
2017-10-14 07:41:54 +00:00
if device.wireless_modem and false then
2017-10-11 15:37:52 +00:00
2017-10-12 02:39:04 +00:00
multishell.setTitle(multishell.getCurrent(), 'Chat')
2017-10-11 15:37:52 +00:00
2017-10-12 02:39:04 +00:00
multishell.openTab({
path = 'rom/programs/rednet/chat',
args = { 'host', 'opusChat-' .. os.getComputerID() },
title = 'Chat Daemon',
hidden = true,
})
2017-10-11 15:37:52 +00:00
2017-10-12 02:39:04 +00:00
local tab = multishell.getTab(multishell.getCurrent())
2017-10-11 15:37:52 +00:00
2017-10-12 02:39:04 +00:00
_G.requireInjector()
2017-10-11 15:37:52 +00:00
2017-10-12 02:39:04 +00:00
local Event = require('event')
local Util = require('util')
2017-10-11 15:37:52 +00:00
2017-10-12 02:39:04 +00:00
local h = Event.addRoutine(function()
2017-10-11 15:37:52 +00:00
while true do
2017-10-12 02:39:04 +00:00
Util.run(_ENV, 'rom/programs/rednet/chat',
'join', 'opusChat-' .. os.getComputerID(), 'owner')
end
end)
while true do
local e = { os.pullEventRaw() }
if e[1] == 'terminate' then
multishell.hideTab(tab.tabId)
else
if e[1] == 'rednet_message' and e[4] == 'chat' and e[3].sType == 'chat' then
if tab.hidden then
multishell.unhideTab(tab.tabId)
2017-10-11 15:37:52 +00:00
end
end
2017-10-12 02:39:04 +00:00
h:resume(table.unpack(e))
2017-10-11 15:37:52 +00:00
end
end
end