summaryrefslogtreecommitdiff
path: root/irc/pylon.lua
diff options
context:
space:
mode:
Diffstat (limited to 'irc/pylon.lua')
-rw-r--r--irc/pylon.lua30
1 files changed, 5 insertions, 25 deletions
diff --git a/irc/pylon.lua b/irc/pylon.lua
index 0c898dd..8c43b13 100644
--- a/irc/pylon.lua
+++ b/irc/pylon.lua
@@ -2,10 +2,11 @@ local cqueues = require'cqueues'
local socket = require'cqueues.socket'
local pprint = require'pprint'
local rirc = require'irc.rirc'
-local Queue = require'util.queue'
-local Channel = require'util.channel'
+local Queue = require'queue'
+local Channel = require'channel'
+local pylon = require'pylon'
-local Irc = {}
+local Irc = pylon.subclass 'irc'
function Irc._send(self, args)
args.source = args.source or self.nodename
@@ -13,21 +14,8 @@ function Irc._send(self, args)
print('>', sent)
end
-function Irc.check_config(self, vars)
- for x in vars:gmatch("%S+") do
- assert(self[x], "missing conf field "..x) end end
-
-function Irc.make(wilson, conf)
- local self = setmetatable(conf, {__index=Irc})
-
- for k,v in pairs {
- wilson = wilson,
- inbox = Queue.make(),
- } do self[k] = v end
-
+function Irc.init(self)
self:check_config "host port password nodename"
-
- return self
end
function Irc._connect(self)
@@ -36,14 +24,6 @@ function Irc._connect(self)
self:_send{'SERVER', self.nodename, '1', 'i am wilson'}
end
-function Irc.run(self)
- local cq = cqueues.new()
- self:_connect()
- cq:wrap(self.recving, self)
- cq:wrap(self.sending, self)
- print('irc', cq:loop())
-end
-
function Irc.recving(self)
for line in self.sock:lines "*l" do
print('<', line)