summaryrefslogtreecommitdiff
path: root/xmpp/pylon.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp/pylon.lua')
-rw-r--r--xmpp/pylon.lua21
1 files changed, 15 insertions, 6 deletions
diff --git a/xmpp/pylon.lua b/xmpp/pylon.lua
index 930a54c..90a155a 100644
--- a/xmpp/pylon.lua
+++ b/xmpp/pylon.lua
@@ -56,8 +56,10 @@ function Xmpp.add_channel(self, channel)
bot.user, bot.nick, bot.user_jid, bot.nick_jid = self:ensure_and_get_user(channel.descriptor, "wilson")
end
-function Xmpp.ensure_and_get_user(self, muc_jid, nick)
+function Xmpp.ensure_and_get_user(self, muc_jid, msg_sender, source_pylon)
local muc = assert(self.mucs[muc_jid])
+ local nick = msg_sender
+ if source_pylon then nick = nick.."["..source_pylon.shortname.."]" end
local user = muc.nick_to_user[nick]
if user then
local user_jid = user..'@'..self.component
@@ -68,7 +70,12 @@ function Xmpp.ensure_and_get_user(self, muc_jid, nick)
-- join up new user
user = nick:gsub("[^a-zA-Z0-9%.]","."):match("^%.*(.-)%.*$")
- while muc.user_to_nick[user] do user = user..'-' end
+ if source_pylon then
+ while muc.user_to_nick[user.."."..source_pylon.name] do user = user..'-' end
+ user = user.."."..source_pylon.name
+ else
+ while muc.user_to_nick[user] do user = user..'-' end
+ end
muc.nick_to_user[nick] = user
muc.user_to_nick[user] = nick
@@ -94,7 +101,6 @@ function Xmpp.recving(self)
return t(self.sock:read'-2048')
end
for x in xml.stanzae(getmore) do
- ::next::
self.log:debug(xmlify(x))
if type(x) == 'string' then
self.log:warn("x was a string: ("..x..")")
@@ -111,20 +117,23 @@ function Xmpp.recving(self)
and from_nick and not muc.nick_to_user[from_nick]
then
self.log:proto('<',from_bare_jid,from_nick,body)
- self.wilson:deliver(Channel(self, from_bare_jid), {
+ self.wilson:deliver({
+ source_channel = Channel(self, from_bare_jid),
body = body,
- sender = '[x]'..from_nick
+ sender = from_nick,
})
end
end
end
+ ::next::
end
end
function Xmpp.sending(self)
for dest_channel, message in self.inbox:iter() do
self.log:proto('>',dest_channel,message.sender,message.body)
- local user, nick, user_jid, nick_jid = self:ensure_and_get_user(dest_channel.descriptor, message.sender)
+ local user, nick, user_jid, nick_jid
+ = self:ensure_and_get_user(dest_channel.descriptor, message.sender, message.source_channel.pylon)
self.sock:write(xmlify(
X.message{to=dest_channel.descriptor, type='groupchat', from=user_jid,
X.body{message.body}}))