justintv / Twitch-API

A home for details about our API
www.twitch.tv
1.72k stars 381 forks source link

Possible misplaced quotation marks in PubSub bits message #595

Closed paglueck closed 7 years ago

paglueck commented 7 years ago

Was playing around with the PubSub system and tried to parse the messages to extract the data and i didnt get it to work correctly (i used javascript and used JSON.parse to extract the data, which works fine with the example message). Subscribing to the bits topic works, keeping the connection alive through ping messages works.

When the streamer i tried this with got a bits donation i received the following message:

{"type":"MESSAGE","data": {"topic":"channel-bitsevents.XXXXXXXX","message":"{\"user_name\":\"donor\",\"channel_name\":\"steamer\",\"user_id\":\"XXXXXXX\",\"channel_id\":\"XXXXXXX\",\"time\":\"2016-08-09T19:43:10.397Z\",\"chat_message\":\"cheer100 cheer message\",\"bits_used\":100,\"total_bits_used\":500,\"context\":\"cheer\"}"}}

This is the example message from the PubSub bits page (which works fine):

{"type": "MESSAGE","data": {"topic": "channel-bitsevents.XXXXXXXX","message": {"user_name": dallasnchains","channel_name": "twitch", "user_id": "...", "channel_id": "...", "time": "2015-12-19T16:39:57-08:00", "chat_message": "Omg that baneling bust was Kreygasm cheer10 cheer10 cheer100","bits_used": 120,"total_bits_used": 620,"context": "cheer"}}}

If you disregard the backslashes (which go away when parsing the JSON) the only differences are the quotation marks after the colon after the "message" and the quotation marks at the end before the two last curly brackets.

I don't know if it's a mistake, or if i don't see my error.

Edit: It would be nice if it was possible to send a request with a test message as response.