summaryrefslogtreecommitdiff
path: root/xmpp
diff options
context:
space:
mode:
authorrebecca <ubq323@ubq323.website>2026-09-13 16:25:56 +0100
committerrebecca <ubq323@ubq323.website>2026-09-13 16:25:56 +0100
commitc9b43b5bb9d85f68edded36428fb14f05debf190 (patch)
tree5c0c296c6b56fa66ceb874366e8b25e10e23baed /xmpp
parent57b7cec33e32f02fe67de91aec66662b6ae5c6ab (diff)
use log more pervasively, changes to discord and xmpp:
discord: fix some logic errors, correctly ignore messages in channels that we don't care about xmpp: reformat some of the recving logic, but it's still borken somehow, but olive says she wants to fix it not me
Diffstat (limited to 'xmpp')
-rw-r--r--xmpp/pylon.lua31
1 files changed, 17 insertions, 14 deletions
diff --git a/xmpp/pylon.lua b/xmpp/pylon.lua
index 302b787..9568999 100644
--- a/xmpp/pylon.lua
+++ b/xmpp/pylon.lua
@@ -12,7 +12,6 @@ local Xmpp = class.extend(BasePylon)
function Xmpp.init(self)
self:_check_fields"server component component_secret"
-
self.nicks_inuse = {}
end
@@ -42,8 +41,6 @@ function Xmpp._connect_component(self)
end
Xmpp._connect = Xmpp._connect_component
-local THE_MUC = 'd@conference.ubq323.website'
-
function Xmpp.recving(self)
local function getmore()
local function t(...)
@@ -53,15 +50,20 @@ function Xmpp.recving(self)
return t(self.sock:read'-2048')
end
for x in xml.stanzae(getmore) do
- -- pprint(x)
- -- print(xmlify(x))
+ self.log:debug(xmlify(x))
local body = x'body' and x'body'[1]
if x.label == 'message' then
- local fr = x.xarg.from
- local t = x.xarg.to
- local from_nick = fr:match("/(.*)")
- if not self.nicks_inuse[from_nick] and body and fr:match"/" and t == 'wilson@'..self.component then
- self.wilson:deliver(Channel(self, THE_MUC), {
+ local from = x.xarg.from
+ local to = x.xarg.to
+ local from_addr, from_nick = from and from:match"(.*)/(.*)"
+ if
+ from_nick
+ and not self.nicks_inuse[from_nick]
+ and body
+ and to == 'wilson@'..self.component
+ then
+ self.log:proto('<',from_addr,from_nick,body)
+ self.wilson:deliver(Channel(self, from_addr), {
body = body,
sender = '[x]'..from_nick
})
@@ -86,14 +88,15 @@ function Xmpp.sending(self)
X.x{xmlns='http://jabber.org/protocol/muc',
X.history{maxstanzas='0'}}}))
end
- ensure_joined(THE_MUC, 'wilson', 'wilson')
+ ensure_joined('d@conference.ubq323.website', 'wilson', 'wilson')
for dest_channel, message in self.inbox:iter() do
- -- pprint(dest_channel, message)
- ensure_joined(THE_MUC, message.sender, message.sender)
+ self.log:proto('>',dest_channel,message.sender,message.body)
+ local muc = dest_channel.descriptor
+ ensure_joined(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,
+ X.message{to=muc, type='groupchat', from=jid,
X.body{message.body}}))
end
end