summaryrefslogtreecommitdiff
path: root/xmpp.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2025-02-22 00:20:52 +0000
committerubq323 <ubq323@ubq323.website>2025-02-22 00:20:52 +0000
commit989b6349b0c7e5a0d7ec06d2ca24d629c618fe12 (patch)
treec424e6eac3ee626db4b4993def6eda4b9292eb66 /xmpp.lua
parentbf776624fb59d147b82d2a6a13c36292844a47b7 (diff)
many thingsHEADtrunk
Diffstat (limited to 'xmpp.lua')
-rw-r--r--xmpp.lua20
1 files changed, 9 insertions, 11 deletions
diff --git a/xmpp.lua b/xmpp.lua
index 24a5a3c..0b7a33d 100644
--- a/xmpp.lua
+++ b/xmpp.lua
@@ -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,