Well, seeing a little of the API that youtube provides to be used, there is no form of "socket". Therefore, you will have to keep giving GET from time to time in a specific chat room to return a list of the messages sent. After that, put each message in a stack (to maintain the integrity of the moment the message was sent), or some similar structure and start scanning that stack for what you are interested in. That would be the way I would build such an application. If there is any other better solution, please let me know! :D
In order for the correct message to be displayed on the screen, you will need to connect this application with some livestreaming software (type: xplit, Obs) through some plugin that you will have to implement for them. For this you will have to study a little more about the API of these softwares too! I do not understand much how they work, but I know it is around. If I’m not mistaken, there must already be some plugin that performs the operations that you’re trying to implement. Try to study them! :)
Here’s the documentation that I’ve taken as the basis for this kind of implementation that you’re looking to do: https://developers.google.com/youtube/v3/live/docs
Go to the "Livechatmessages" session and there it will give you the available operations for chat manipulation.
If you have said something wrong, please correct me. Hugs!
Very well, it helped a lot, when the mind hangs, it gets hard to think of solutions, but it helped me man, thank you!
– Reginaldo Filho