DisStreamChat/Backend

improve twitch emote parsing

Closed this issue · 2 comments

the current twitch emotes parsing relies on the length of the message staying the same, but the HTML cleaning changes the length of the message, the current solution involves getting the difference in length between the original message and the HTML cleaned message and using that to offset the emotes. This solution doesn't always work because the emotes don't always need to be shifted by the full difference in length but only the difference in length of the substring that came before it. I don't know a good way to implement that.

I think we can use https://twitchemotes.com/apidocs to fix this with a find and replace. use the twitchemotes api to convert the emote ids into their names and then replace the name with correct html. What do you think @MurdocTurner

I fixed this without using that api because it didn't support emoticons. My solution uses part of cj's parsing method to get all the emote names and match them with the id, then I use a find and replace to replace all the emotes. This method doesn't rely on the length of the message staying the same.