diff options
Diffstat (limited to 'xmpp.lua')
-rw-r--r-- | xmpp.lua | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -17,11 +17,10 @@ local function make_auth(authz, authn, password) return base64.encode(authz..'\0'..authn..'\0'..password) end -function Xmpp.makepylon(pylonname, conf, cq, network) +function Xmpp.make(wilson, conf) local self = { - pylonname = pylonname, - cq = cq, - network = network, + name = conf.name, + wilson = wilson, inbox = Queue.make(), } local function conf_var(name) @@ -36,7 +35,6 @@ function Xmpp.makepylon(pylonname, conf, cq, network) setmetatable(self, {__index=Xmpp}) return self - end function Xmpp._connect_c2s(self) @@ -124,9 +122,9 @@ function Xmpp.recving(self) local fr = x.xarg.from local t = x.xarg.to if body and fr:match"/" and t == 'wilson@'..self.component then - self.network:post(self.pylonname, THE_MUC, { + self.wilson:deliver(Channel(self, THE_MUC), { body = body, - source = '[x]'..x.xarg.from:match("/(.*)") + sender = '[x]'..x.xarg.from:match("/(.*)") }) end end @@ -151,10 +149,10 @@ function Xmpp.sending(self) X.history{maxstanzas='0'}}})) end ensure_joined(THE_MUC, 'wilson', 'wilson') - for ch, msg in self.inbox:iter() do - pprint(ch,msg) - ensure_joined(THE_MUC, msg.source, msg.source) - local user = msg.source:gsub("[^a-zA-Z0-9%.]","."):match("^%.*(.-)%.*$") + for dest_channel, message in self.inbox:iter() do + pprint(dest_channel, message) + ensure_joined(THE_MUC, message.sender, message.sender) + local user = message.sender:gsub("[^a-zA-Z0-9%.]","."):match("^%.*(.-)%.*$") local jid = user..'@'..self.component self.sock:write(xmlify( X.message{to=THE_MUC, type='groupchat', from=jid, |