summaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
authorrebecca <ubq323@ubq323.website>2026-09-25 16:41:52 +0100
committerrebecca <ubq323@ubq323.website>2026-09-25 16:49:36 +0100
commit28a876fa341174e8d17640fc215854328ce65b42 (patch)
tree64be5771e6dd48e0d45a3cdc65bcda1f62369277 /discord
parent89c71b2939ce610b4251d0d9f22b9e0d2217a106 (diff)
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
Diffstat (limited to 'discord')
-rw-r--r--discord/pylon.lua12
1 files changed, 6 insertions, 6 deletions
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,