tmijs / tmi.js

💬 Javascript library for the Twitch Messaging Interface. (Twitch.tv)
https://tmijs.com
MIT License
1.54k stars 217 forks source link

Cheer messages are not detected with /me #401

Closed AlcaDesign closed 4 years ago

AlcaDesign commented 4 years ago

Currently, cheer messages with /me (action) are not detected as cheer messages. This is because the tmi.js code is checking for action messages before it could check for bits. These messages are possible and is a bug with tmi.js.

Relevant code https://github.com/tmijs/tmi.js/blob/92d7ccff8cecf33bc28c1f40612228e01943a4ff/lib/client.js#L1001-L1026

Instead, I'd like for cheer messages to always trigger the relevant chat/action events along with the message and cheer event. The issue with this is that it's no longer backwards compatible. tmi.js users with existing listeners for message and cheer will receive double events. It would be better for new tmi.js users because then they will always receive cheer messages and can use the cheer event to filter for just messages with bits.

I think the right thing to do is to set the message-type prop to "chat"/"action" depending on actionMessage, change the message, do the relevant debug log, then decide if it's a cheer message and emit to that event first. The action/chat events come last in that order.