feat(daemon): real Discord Gateway (WebSocket) + harden Telegram/Slack#76
Merged
Conversation
Discord: replace the REST-poll bridge (which only watched hand-configured channels and never actually fetched anything as wired) with the official Discord Gateway over WebSocket via bwmarrin/discordgo. Receives guild @mentions and DMs in real time; the bot user is learned from READY so no app/channel IDs need configuring. Library handles heartbeats, resume, reconnect, and rate limits. Message filtering and the pairing/allowlist forward policy are split into pure, unit-tested helpers. Cross-gateway hardening: - Bounded, lifecycle-tracked goroutines (asyncDispatcher) drained on Stop; Slack handlers now run under the gateway context, not context.Background. - Platform API errors are checked and logged instead of swallowed (Slack ok=false, Discord/Telegram non-2xx, Telegram getUpdates ok=false). - Telegram: fail-closed bare constructor, context-aware exponential backoff. - setDaemonURL via a daemonURLSetter interface instead of a type switch. Adds github.com/bwmarrin/discordgo (+ gorilla/websocket indirect).
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
Replaces the Discord bridge's REST-polling design — which only watched hand-configured channels and, as wired, never fetched anything — with the official Discord Gateway over WebSocket via
bwmarrin/discordgo(the industry-standard Go Discord library). Telegram (long-poll) and Slack (Events API + HMAC) keep their already-idiomatic designs but are hardened.Discord (rewritten)
GuildMessages | MessageContent | DirectMessages; library handles heartbeats, resume/reconnect, rate limits.READY→ no app/channel IDs to configure.wantsDiscordMessage,stripDiscordMention) and the pairing/allowlist forward policy (handleMessage) are pure and unit-tested without a live socket;openSessionis injectable.Cross-gateway hardening
asyncDispatcher) drained onStop; Slack handlers run under the gateway context (notcontext.Background).ok=false, Discord/Telegram non-2xx, TelegramgetUpdates ok=false).setDaemonURLvia adaemonURLSetterinterface instead of a concrete type switch.Dependency
Adds
github.com/bwmarrin/discordgo v0.28.1(+gorilla/websocketindirect;x/cryptoalready satisfied).go work syncreconciled go.mod/go.sum/go.work.sum.Notes
MessageContentis a privileged intent — enable it in the Discord developer portal or message text arrives empty.Verification
go build ./...,go vet,go test -race ./internal/daemon,golangci-lint(0 issues);go work syncidempotent andgo build -mod=readonly ./cmd/hawkclean.