Add Slack support via unified entry point with symmetric adapter pattern#25
Add Slack support via unified entry point with symmetric adapter pattern#25
Conversation
- Add @slack/bolt dependency for Slack integration - Create SlackMessageAdapter to normalize Slack events to Discord message interface - Create slack.js entry point with Socket Mode support - Add start:slack npm script - Add Slack reminder daemon - Update README.md and getting-started.md with Slack setup instructions Co-authored-by: circa10a <21261388+circa10a@users.noreply.github.com>
Co-authored-by: circa10a <21261388+circa10a@users.noreply.github.com>
| } | ||
|
|
||
| // Listen for messages starting with the ava prefix | ||
| app.message(new RegExp(`^${avaPrefix}`, 'i'), async ({ message, client }) => { |
There was a problem hiding this comment.
Compiling regex on every message is fairly CPU intensive. This isn't great
There was a problem hiding this comment.
Fixed in 61de5ec — the regex is now pre-compiled once as a module-level constant (avaPrefixRegex) in both slack.js and index.js, instead of being created on every message.
| @@ -0,0 +1,139 @@ | |||
| import logger from '../logger/logger.js'; | |||
There was a problem hiding this comment.
If we have a slack adapter, we should replace the existing architecture to leverage a "discord" adapter also
There was a problem hiding this comment.
Done in 61de5ec — created lib/adapters/discord.js with a DiscordMessageAdapter and refactored index.js to use the same adapter dispatch pattern as slack.js. Both entry points are now symmetric: load commands → listen for prefix → wrap with adapter → dispatch. Also removed Events import and name/once properties from all 25 command files to fully decouple them from discord.js.
|
@copilot address open comments and resolve issues in CI |
…le regex, fix lint errors - Create lib/adapters/discord.js with DiscordMessageAdapter - Refactor index.js to use adapter pattern matching slack.js architecture - Pre-compile regex in both slack.js and index.js (no per-message compilation) - Remove Events import from all 25 command files (decouple from discord.js) - Fix 6 pre-existing no-useless-assignment lint errors in commands and lib files Co-authored-by: circa10a <21261388+circa10a@users.noreply.github.com>
Addressed both review comments and fixed CI in 61de5ec:
|
| "lint": "eslint .", | ||
| "fix-lint": "eslint . --fix", | ||
| "start": "node --no-deprecation ./index.js", | ||
| "start:slack": "node --no-deprecation ./slack.js", |
There was a problem hiding this comment.
We can not run both simultaneously? What about the docker image?
There was a problem hiding this comment.
Fixed in 0672c98. index.js is now a unified entry point that auto-detects platforms based on which env vars are set. A single npm start runs Discord, Slack, or both simultaneously. The Docker image needs no CMD override — just pass the relevant env vars:
# Both platforms simultaneously
docker run -e AVA_DISCORD_TOKEN="<token>" -e AVA_SLACK_BOT_TOKEN="<bot-token>" -e AVA_SLACK_APP_TOKEN="<app-token>" circa10a/avaRemoved the separate slack.js entry point and start:slack script. Platform logic extracted into lib/platforms/discord.js and lib/platforms/slack.js.
…multaneously - Refactor index.js to auto-detect platforms based on which env vars are set - Extract platform logic into lib/platforms/discord.js and lib/platforms/slack.js - Remove separate slack.js entry point and start:slack script - Docker image works for all configs via env vars alone (no CMD override) - Update README and docs to show unified usage Co-authored-by: circa10a <21261388+circa10a@users.noreply.github.com>
Co-authored-by: circa10a <21261388+circa10a@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Adds Slack as a supported platform alongside Discord using a symmetric adapter pattern. Both platforms now use the same architecture — commands are fully decoupled from Discord.js and receive messages through platform-specific adapters. A single
npm startauto-detects which platforms to run based on environment variables, supporting Discord only, Slack only, or both simultaneously.Approach
A unified
index.jsentry point loads commands once, then starts whichever platforms have tokens configured. Platform-specific logic is encapsulated inlib/platforms/discord.jsandlib/platforms/slack.js. Commands export only{ commandName, execute }and have no dependency on Discord.js events.Changes
lib/adapters/discord.js—DiscordMessageAdapterclass (thin wrapper for architectural consistency)lib/adapters/slack.js—SlackMessageAdapterclass +embedToBlocksconverter (DiscordEmbedBuilder→ Slack Block Kit)lib/platforms/discord.js— Discord platform startup logic (client setup, message listener, reminder daemon)lib/platforms/slack.js— Slack platform startup logic (@slack/boltSocket Mode, message listener, reminder daemon)index.js— Unified entry point that auto-detects and starts Discord, Slack, or both simultaneouslyEventsimport andname/onceproperties, decoupling from discord.js event systempackage.json—@slack/boltdependencyREADME.md/docs/getting-started.md— Updated docs showing unified usage for Discord, Slack, or both; Docker examplesno-useless-assignmenterrors in commands and lib filesConfig
AVA_DISCORD_TOKENAVA_SLACK_BOT_TOKENxoxb-bot tokenAVA_SLACK_APP_TOKENxapp-app-level token for Socket ModeAVA_SLACK_SIGNING_SECRETThe Docker image works for all configurations — just pass the relevant env vars:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.