Beginner Question regarding Twitch chat

Hey,

I am trying to understand how Chrome Extensions while browsing Twitch. What i am looking to do is:

  • Have an extension that when viewing a twitch channel it can get all the incoming chat messages
  • Ability to send a chat message as the current broadcaster (i assume i’ll need to Authenticate before being able to do it, even though i saw extensions that sent messages without any authentication and i am not sure if they just enter the message in the twitch chat textarea somehow and click the Chat button to send the message).

Any kind of direction to the right documentation or examples will be appreciated.

Thank You.

This sounds more like a Twitch Chat Bot then a Chrome Extension use case to me. I assume you want the extension to send a message as a different user which means that the broadcaster has to authenticate and allow the application to do something on their behalf. I am guessing that extensions are using the IRC or WebSocket interfaces to send data to Twitch chat and as the broadcaster already granted the extensions some rights, chat was probably one of the rights included.

Any particular reason you are looking to do this as a Chrome extension instead of as perhaps a separate service? Just curious is all.

Cheers

1 Like

Thank you for that information. I’m actually trying to mimic the twitch giveaway chrome extension. When installed it allows to track certain keywords entered in chat and add the person who sent it to a list of the possible winners of the giveaway. It also alllows to send a chat message when the giveaway starts, stops and winner announced.

That extension didn’t require me to authenticate in any way.

Thanks again for the help.

I was able to find this resource to get a list of the current viewers which is helpful for what i am looking to do.

https://tmi.twitch.tv/group/user/:channel/chatters

i was hoping something similar exists for the actual chat log where we can either query to get the chat log at the current moment or maybe using WS, for example when viewing a stream there is a WS:

wss://irc-ws.chat.twitch.tv/

that pushes the chat messages in the following format:

`

@badges=subscriber/0;color=;display-name=zzAqua;emotes=;id=8970d3d5-2566-49db-92f0-c1ef0230350e;mod=0;room-id=60056333;subscriber=1;tmi-sent-ts=1531535850610;turbo=0;user-id=233748772;user-type= :zzaqua!zzaqua@zzaqua.tmi.twitch.tv PRIVMSG #tfue :@kunai360x exactly

`

Something like that to be able to get those inside a chrome extension JS code will probably be the easiest solution but i am not sure if that something that is possible?

Thank You.

1 Like

If you are wanting to obtain chat messages via a browser extension then it would be better to work with the Mutation Observer API built into browsers to listen when changes to the dom tree are made. More specifically when the dom tree changes on the chat itself so you can then obtain the messages added and search for the keywords you are talking about.

However this way might not allow you to send a message in chat so you’ll need to figure that part out, but you can always try programmatically clicking the chat button to send a test message when there is data in the textarea to see if that works.

Hopefully that helped!

2 Likes

Thank You. I was finally able to find the repository for the referenced twitch giveaways. It seems that that is what they do as well.

https://github.com/darsain/twitch-giveaways

This will be a good reference to see if i can work something out.

Thanks Again.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.