GH-59: feat(sdk/integrations/discord): port client, types, sanitize#61
Merged
Conversation
Add sdk/integrations/discord/: REST client (SendMessage, SendMessageWithComponents, EditMessage, CreateInteractionResponse) with rate-limit retry; Gateway/REST types (GatewayEvent with json.RawMessage D field, MessageCreate, InteractionCreate, User, Component, Button, constants); sanitizeMessageText via sdk/util/text. StripBotMention exported for the follow-up WS transport issue. Add testutil.FakeDiscordToken. No new deps; go.mod unchanged.
4 tasks
Contributor
Author
|
🚧 Merge blocked: approval not wired Environment To unblock: either enable approval in Tracked in #2598. |
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
Automated PR created by Pilot for task GH-59.
Closes #59
Changes
GitHub Issue #59: feat(sdk/integrations/discord): port client, types, sanitize
Context
Port the Discord chat connector's client + data layer into a new
sdk/integrations/discord/package (packagediscord), zero pilot deps. Conformsto the
sdk/corechat-bridge contract (.agent/system/chat-bridge-design.md;references =
sdk/integrations/telegram/andsdk/integrations/slack/). Clone:gh repo clone qf-studio/pilot /tmp/pilot-src -- --depth 1; port from/tmp/pilot-src/internal/adapters/discord/. Discord delivery = Gateway WS —the transport + bridge are the follow-up. This issue is the stdlib-only REST
Implementation
Port into
sdk/integrations/discord/:client.go,types.go,sanitize.go(+ table-driven tests). Transformations:
github.com/qf-studio/pilot/...import; inject*slog.Logger(
WithLogger). Replace anyinternal/textwithsdk/util/text.client.go— REST client overnet/http(https://discord.com/api/v10):SendMessage,SendMessageWithComponents(buttons via action rows),EditMessage,CreateInteractionResponse. Keep rate-limit handling.types.go— Discord Gateway/REST types (GatewayEvent,MessageCreate,InteractionCreate,User, action-row/button component types) + intents/opcodes constants +
Config{ BotToken, BotID string; AllowedGuilds, AllowedChannels []string }. ParseGatewayEvent.dintoMessageCreate/InteractionCreate; strip the bot-mention prefix from content. No WebSockethere (that's issue-2).
sanitize.go— NEW:sanitizeMessageText(s, logger)viasdk/util/text.SanitizeUntrusted.messenger.go,formatter.go,notifier.go,and the comms task-dispatch in
handler.go.sdk/testutilonly — addFakeDiscordToken = "test-discord-token".transport.go(Gateway WS) or the adapter — those are thefollow-up (they reuse the existing
gorilla/websocketdep).go.modisunchanged here.
⛔ Touch ONLY
sdk/integrations/discord/andsdk/testutil/tokens.go.Acceptance
client.go,types.go,sanitize.go(+ tests) exist; NO messenger/formatter/notifier host-domain code.grep -rn "qf-studio/pilot" sdk/nothing; inbound sanitize usessdk/util/text; bot-mention stripped.go mod tidya no-op (no new dep here — the REST layer is stdlib);sdk/{core,log,util,testutil}stdlib-only.go build ./...,go vet ./...,go test -race ./sdk/integrations/discord/...pass;gofmt -l sdk/empty.