From 5dea96ad915692e9abbc0620930756c51c256179 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 27 Feb 2025 23:23:57 +0000 Subject: restructure, refactor, a bit --- irc/pylon.lua | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) (limited to 'irc/pylon.lua') 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) -- cgit v1.2.3