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:
@@ -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...")
|
||||
|
||||
Reference in New Issue
Block a user