Add standalone wsdebug tool for inspecting the raw Sneedchat WebSocket stream

Loads the same .env credentials as the bridge, connects to the Sneedchat
WebSocket independent of Discord, and prints every raw frame to stdout
while also appending it to a log file. Adds an OnRaw hook to sneed.Client
so the full, untruncated frame is available to callers.
This commit is contained in:
Claude
2026-08-02 00:04:53 +00:00
parent adba77b3e5
commit 98eeb2e2ba
4 changed files with 128 additions and 0 deletions
+9
View File
@@ -63,6 +63,11 @@ type Client struct {
OnConnect func()
OnDisconnect func()
// OnRaw, if set, is called with every raw WebSocket frame exactly as
// received, before any parsing or truncation. Intended for debugging
// tools that need to observe the unfiltered stream.
OnRaw func(string)
recentOutboundIter func() []map[string]interface{}
mapDiscordSneed func(string, int, string)
@@ -197,6 +202,10 @@ func (c *Client) readLoop(ctx context.Context) {
raw := string(message)
if c.OnRaw != nil {
c.OnRaw(raw)
}
// Server sends plaintext "cannot join" when session has expired.
if isCannotJoin(raw) {
log.Println("⚠️ 'cannot join' received — refreshing session and reconnecting...")