diff options
author | ubq323 <ubq323@ubq323.website> | 2025-02-27 23:23:57 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2025-02-27 23:23:57 +0000 |
commit | 5dea96ad915692e9abbc0620930756c51c256179 (patch) | |
tree | 881d7680a521474f262bac262f382e778c1fc191 /irc | |
parent | ec4053dea479c3c85d57c447e262a90addcce5c3 (diff) |
restructure, refactor, a bit
Diffstat (limited to 'irc')
-rw-r--r-- | irc/pylon.lua | 30 |
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) |