Add EQNotify feature under /eqnotify command#263
Merged
Conversation
Ports the standalone EQNotify batphone-notification bot into castle as a native feature. Subscribers register a delivery channel and a set of keyword tags; batphones posted in the batphone channel are matched against each subscriber's tags (buff / last-hour RTE calls filtered out) and an alert is pushed to their phone. - New /eqnotify slash command with subcommands: register, unregister, add-tag, remove-tag, list-tags, clear-tags, test, plus officer-gated add-user / remove-user (Officer/Mod/Knight). - Two delivery backends selected per-subscriber: WirePusher (Android) and Telegram (iOS/Android/desktop), dispatched via a pluggable notifier. Telegram requires TELEGRAM_BOT_TOKEN; when unset it is offered nowhere. - Persists subscribers in Postgres via a new eqnotify_subscriber Prisma model + migration, replacing the original users.json. - Dispatch runs from the message-create listener before the bot-author guard, since castle posts batphones itself via /bp send. Watched channel defaults to the batphone channel, overridable via eqnotifyChannelId. - Pure matching/filtering logic extracted to matcher.ts with unit tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BWXRmPbtEz35wquwFd8Cu7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Merges the standalone EQNotify batphone-notification bot into castle as a native feature under a new
/eqnotifyslash command. Subscribers register a delivery channel and a set of keyword tags; batphones posted in the batphone channel are matched against each subscriber's tags (buff / last-hour RTE calls filtered out) and an alert is pushed to their phone.Ported from a v11-era standalone discord.js bot to castle's conventions: TypeScript, discord.js v14,
Command/Subcommandclasses, and Prisma/Postgres persistence (replacing the originalusers.json).Commands
All commands moved to subcommands under
/eqnotify:register,unregister,add-tag,remove-tag,list-tags,clear-tags,testadd-user,remove-userThe original prefix commands map as:
!add→add-tag,!remove→remove-tag,!list→list-tags,!cleartags→clear-tags,!adduser→add-user,!testmsg→test.Delivery backends
Two backends are selected per-subscriber and dispatched through a pluggable notifier that switches on
type:TELEGRAM_BOT_TOKEN; when unset, Telegram is offered nowhere and WirePusher works standalone.Notable implementation detail
The original was a separate bot, so it saw castle's batphones as another bot's messages. Integrated, batphones are authored by castle itself (via
/bp send), andmessageCreateListenerearly-returns on bot authors — so the EQNotify dispatch runs before that guard, filtered to the watched channel. The buff/RTE content filter, substring tag-matching, and thealltag are all preserved. The watched channel defaults to the batphone channel and is overridable viaeqnotifyChannelId.Changes
eqnotify_subscriberPrisma model + migration (20260724000000_add_eqnotify_subscribers).src/features/eqnotify/: command + subcommands, service, notifiers (WirePusher/Telegram/dispatcher), and a channel message-action.matcher.tswith unit tests.TELEGRAM_BOT_TOKEN(optional),eqnotifyChannelId(optional).Deployment notes
prisma migrate deploy— already wired as thepostdeploystep).TELEGRAM_BOT_TOKEN. Users get their numeric chat ID (e.g. from @userinfobot) and paste it into/eqnotify register.Testing
yarn test:ci— 71 tests pass (11 new for the matcher).yarn tsc— clean.🤖 Generated with Claude Code
Generated by Claude Code