summaryrefslogtreecommitdiff
path: root/nanochat
diff options
context:
space:
mode:
authorrebecca <ubq323@ubq323.website>2026-09-24 17:20:42 +0100
committerrebecca <ubq323@ubq323.website>2026-09-24 18:55:05 +0100
commit71cee0014368f5d83fe94989526a4ffb2824f50c (patch)
treecd87a5c7d859d98f48866ff769ef89d60a28d5d5 /nanochat
parentdff5363f96029aba6d0f222d3e31ab3888d7111f (diff)
change fields on Message to include author
Diffstat (limited to 'nanochat')
-rw-r--r--nanochat/pylon.lua25
1 files changed, 20 insertions, 5 deletions
diff --git a/nanochat/pylon.lua b/nanochat/pylon.lua
index 2f408d4..6fbd725 100644
--- a/nanochat/pylon.lua
+++ b/nanochat/pylon.lua
@@ -30,9 +30,19 @@ function Nanochat:recving()
if chan then
local sender, body = msg:match("^([^:]+): (.+)$", msgi)
if sender then
- deliverables[i] = { source_channel=Thing(self, chan), sender=sender, body=body }
+ deliverables[i] = {
+ pylon=self,
+ channel=Thing(self, chan),
+ author=Thing(self,sender),
+ body=body
+ }
else
- deliverables[i] = { source_channel=Thing(self, chan), sender="", body=msg:sub(msgi,-1) }
+ deliverables[i] = {
+ pylon=self,
+ channel=Thing(self, chan),
+ author=Thing(self,""),
+ body=msg:sub(msgi,-1)
+ }
end
else -- luacheck: ignore 542
-- ignore messages without a channel, they stay nanochat-local
@@ -47,7 +57,7 @@ function Nanochat:recving()
if self.usids[id] then
self.usids[id] = nil
else
- self.log:proto('<', msg.source_channel.id, msg.sender, msg.body)
+ self.log:proto('<', msg.channel.id, msg.author, msg.body)
self.wilson:deliver(msg)
end
end
@@ -59,8 +69,13 @@ end
function Nanochat:sending()
for dest_channel, message in self.inbox:iter() do
- self.log:proto('>',dest_channel,message.sender,message.body)
- assert(self.sock:write("SEND "..dest_channel.id.." ["..message.source_channel.pylon.shortname.."] "..message.sender..": "..message.body.."\n"))
+ self.log:proto('>',dest_channel,message.author,message.body)
+ assert(self.sock:write(
+ "SEND "
+ ..dest_channel.id
+ ..message.author:name_with_shortname()
+ ..": "..message.body
+ .."\n"))
local id = tonumber(assert(self.sock:read("*l")))
self.usids[id] = true
end