From 28a876fa341174e8d17640fc215854328ce65b42 Mon Sep 17 00:00:00 2001 From: rebecca Date: Fri, 25 Sep 2026 16:41:52 +0100 Subject: consistentize 'channels' maps in pylons for live reloading to work, wilson needs to know which channels each pylon currently cares about, so it knows which combination of add_channel and remove_channel to call on each one discord: rename channel_to_webhook --> channels xmpp: rename mucs --> channels quaddle: add channels map --- discord/pylon.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'discord/pylon.lua') diff --git a/discord/pylon.lua b/discord/pylon.lua index ebf185d..c2afc3a 100644 --- a/discord/pylon.lua +++ b/discord/pylon.lua @@ -15,7 +15,7 @@ local API_BASE = "https://discord.com/api/v10/" local Discord = class.extend(BasePylon) function Discord.init(self) self:_check_fields "token" - self.channel_to_webhook = {} + self.channels = {} end local function identify_payload(token) @@ -76,14 +76,14 @@ function Discord.add_channel(self, channel) for _,wh in pairs(webhooks) do if wh.application_id == self.bot_id then self.log("Found existing webhook for channel",channel.id) - self.channel_to_webhook[channel.id] = wh + self.channels[channel.id] = {wh=wh} return end end 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.id] = wh + self.channels[channel.id] = {wh=wh} end function Discord._heartbeating(self, interval_ms) @@ -121,8 +121,8 @@ function Discord.handle_dispatch(self, event) if event.t == 'MESSAGE_CREATE' then self.log:proto('<',d.channel_id,d.author.username,d.content) if - self.channel_to_webhook[d.channel_id] - and d.author.id ~= self.channel_to_webhook[d.channel_id].id + self.channels[d.channel_id] + and d.author.id ~= self.channels[d.channel_id].wh.id and d.author.id ~= self.bot_id then self.wilson:deliver(Message { @@ -138,7 +138,7 @@ end function Discord.sending(self) for dest_channel, message in self.inbox:iter() do self.log:proto('>',dest_channel,message.author,message.body) - local wh = self.channel_to_webhook[dest_channel.id] + local wh = self.channels[dest_channel.id].wh self:_req('webhooks/'..wh.id..'/'..wh.token, { username = message.author:name_with_shortname(), content = message.body, -- cgit v1.2.3