diff options
| -rw-r--r-- | discord/pylon.lua | 14 | ||||
| -rw-r--r-- | irc/pylon.lua | 2 | ||||
| -rw-r--r-- | main.lua | 4 | ||||
| -rw-r--r-- | nanochat/pylon.lua | 4 | ||||
| -rw-r--r-- | quaddle/pylon.lua | 6 | ||||
| -rw-r--r-- | store.lua | 2 | ||||
| -rw-r--r-- | terminology.txt | 1 | ||||
| -rw-r--r-- | thing.lua | 16 | ||||
| -rw-r--r-- | xmpp/pylon.lua | 8 |
9 files changed, 29 insertions, 28 deletions
diff --git a/discord/pylon.lua b/discord/pylon.lua index b996ee7..70c6a40 100644 --- a/discord/pylon.lua +++ b/discord/pylon.lua @@ -79,18 +79,18 @@ function Discord._connect(self) end function Discord.add_channel(self, channel) - local webhooks = self:_req("channels/"..channel.descriptor.."/webhooks") + local webhooks = self:_req("channels/"..channel.id.."/webhooks") for _,wh in pairs(webhooks) do if wh.application_id == self.bot_id then - self.log("Found existing webhook for channel",channel.descriptor) - self.channel_to_webhook[channel.descriptor] = wh + self.log("Found existing webhook for channel",channel.id) + self.channel_to_webhook[channel.id] = wh return end end - self.log("Making webhook for channel",channel.descriptor) - local wh = self:_req("channels/"..channel.descriptor.."/webhooks", { + self.log("Making webhook for channel",channel.id) + local wh = self:_req("channels/"..channel.id.."/webhooks", { name=self.name:gsub("discord",""):gsub("clyde","").." wilson hook" }) - self.channel_to_webhook[channel.descriptor] = wh + self.channel_to_webhook[channel.id] = wh end function Discord._heartbeating(self, interval_ms) @@ -144,7 +144,7 @@ end function Discord.sending(self) for dest_channel, message in self.inbox:iter() do self.log:proto('>',dest_channel,message.sender,message.body) - local wh = self.channel_to_webhook[dest_channel.descriptor] + local wh = self.channel_to_webhook[dest_channel.id] self:_req('webhooks/'..wh.id..'/'..wh.token, { username = message.sender.." ["..message.source_channel.pylon.shortname.."]", content = message.body, diff --git a/irc/pylon.lua b/irc/pylon.lua index bed8261..039ec38 100644 --- a/irc/pylon.lua +++ b/irc/pylon.lua @@ -66,7 +66,7 @@ function Irc.sending(self) for dest_channel, message in self.inbox:iter() do local nick = message.sender.."["..message.source_channel.pylon.shortname.."]" - local channel_name = dest_channel.descriptor + local channel_name = dest_channel.id say(nick, channel_name, message.body) end end @@ -35,10 +35,10 @@ function Wilson.make(cls, conf) for name, bus_conf in pairs(conf.bus) do local bus = {} for _, item in ipairs(bus_conf) do - local pylon_name, channel_descriptor = item[1], item[2] + local pylon_name, channel_id = item[1], item[2] local pylon = self.pylons[pylon_name] assert(pylon,"no such pylon named "..pylon_name) - table.insert(bus, Thing(pylon, channel_descriptor)) + table.insert(bus, Thing(pylon, channel_id)) end self.log("constructed bus ",name,'with '..#bus_conf..' channels') self.busses[name] = bus diff --git a/nanochat/pylon.lua b/nanochat/pylon.lua index aa3aaa6..2f408d4 100644 --- a/nanochat/pylon.lua +++ b/nanochat/pylon.lua @@ -47,7 +47,7 @@ function Nanochat:recving() if self.usids[id] then self.usids[id] = nil else - self.log:proto('<', msg.source_channel.descriptor, msg.sender, msg.body) + self.log:proto('<', msg.source_channel.id, msg.sender, msg.body) self.wilson:deliver(msg) end end @@ -60,7 +60,7 @@ 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.descriptor.." ["..message.source_channel.pylon.shortname.."] "..message.sender..": "..message.body.."\n")) + assert(self.sock:write("SEND "..dest_channel.id.." ["..message.source_channel.pylon.shortname.."] "..message.sender..": "..message.body.."\n")) local id = tonumber(assert(self.sock:read("*l"))) self.usids[id] = true end diff --git a/quaddle/pylon.lua b/quaddle/pylon.lua index e85b699..2d283ea 100644 --- a/quaddle/pylon.lua +++ b/quaddle/pylon.lua @@ -52,8 +52,8 @@ function Quaddle._connect(self) end function Quaddle.add_channel(self, channel) - self.log("Subscribing to channel",channel.descriptor) - self.ws:send(json.encode{ op="subscribe", channel_id=channel.descriptor }) + self.log("Subscribing to channel",channel.id) + self.ws:send(json.encode{ op="subscribe", channel_id=channel.id }) end function Quaddle.recving(self) @@ -94,7 +94,7 @@ function Quaddle.sending(self) for dest_channel, message in self.inbox:iter() do self.log:proto('>', dest_channel, message.sender, message.body) - self:_req('channels/'..dest_channel.descriptor..'/messages', { + self:_req('channels/'..dest_channel.id..'/messages', { content = "["..message.source_channel.pylon.shortname.."] "..message.sender..": "..message.body, }) end @@ -40,7 +40,7 @@ function Store.storing(self) values (?, ?, ?, ?, ?, ?); ]], msg.source_channel.pylon.type, msg.source_channel.pylon.name, - msg.source_channel.descriptor, + msg.source_channel.id,--hello. msg.sender,os.time(),msg.body) self.log("stored",msg.body) assert(conn:commit()) end end diff --git a/terminology.txt b/terminology.txt index d8d029a..e26085f 100644 --- a/terminology.txt +++ b/terminology.txt @@ -17,6 +17,7 @@ Channel: a particular chatroom on a particular service Thing: used in the code for such a tuple of (pylon, pylon-specific-descriptor) actually it also has a display name, which defaults to the descriptor + descriptor is called id in the code because descriptor is too long to type used to represent Channels, Authors, ... Bus: a family of connected channels that messages will be bridged between @@ -1,22 +1,22 @@ local class = require'r.class' -- author or channel or whatever --- tuple of (pylon, pylon-specific-descriptor, optional displayname) +-- tuple of (pylon, pylon-specific-descriptor (id), optional display name) local Thing = class() -function Thing.make(cls, pylon, descriptor, displayname) - displayname = displayname or descriptor +function Thing.make(cls, pylon, id, name) + name = name or id return setmetatable({ pylon=pylon, - descriptor=descriptor, - displayname=displayname, + id=id, + name=name, }, cls) end function Thing.__eq(self, other) - return self.pylon == other.pylon and self.descriptor == other.descriptor + return self.pylon == other.pylon and self.id == other.id end function Thing.__tostring(self) return self.pylon.name - .. ':' .. self.descriptor - .. (self.displayname == self.descriptor and '('..self.displayname..')' or '') + .. ':' .. self.id + .. (self.name == self.id and '('..self.name..')' or '') end return Thing diff --git a/xmpp/pylon.lua b/xmpp/pylon.lua index c9f18f5..0e6094c 100644 --- a/xmpp/pylon.lua +++ b/xmpp/pylon.lua @@ -51,9 +51,9 @@ end function Xmpp.add_channel(self, channel) local muc = { nick_to_user={}, user_to_nick={} } - self.mucs[channel.descriptor] = muc + self.mucs[channel.id] = muc local bot = {} ; self.bot = bot - bot.user, bot.nick, bot.user_jid, bot.nick_jid = self:ensure_and_get_user(channel.descriptor, "wilson") + bot.user, bot.nick, bot.user_jid, bot.nick_jid = self:ensure_and_get_user(channel.id, "wilson") end function Xmpp.ensure_and_get_user(self, muc_jid, msg_sender, source_pylon) @@ -133,9 +133,9 @@ 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, message.source_channel.pylon) + = self:ensure_and_get_user(dest_channel.id, message.sender, message.source_channel.pylon) self.sock:write(xmlify( - X.message{to=dest_channel.descriptor, type='groupchat', from=user_jid, + X.message{to=dest_channel.id, type='groupchat', from=user_jid, X.body{message.body}})) end end |
