tmijs / tmi.js

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

Using client.say with emote msg triggers message with null emotes. #278

Closed CurtisFissel closed 6 years ago

CurtisFissel commented 6 years ago

Actual behaviour: If I send a msg in a chat with client.say When i get the msg I just sent the message event userstate data has no emote data.

client.say(currentChannel, "Kappa Kappa Kappa"); `` image

Expected behaviour: When sending "Kappa Kappa Kappa" from the normal Twitch client and listening for a message event I get the correct userstate info. image

Am I missing something here? Is there a way to add the emote data to the say function? Any help would be awesome.

Thanks, Curtis

AlcaDesign commented 6 years ago

Sadly Twitch doesn't send back IRC tags for sent messages, the library would only be able to guess. You will have to parse you're own messages for emotes using the identity's available emote sets and the Twitch API. I could point you in the right direction if you wish. You could also try using 2 clients: one to send, one to receive and do something with the tags.

CurtisFissel commented 6 years ago

Ah ya. I figured it would be something like that. Thank you for the super quick reply. Yes that would be great! any extra reference material would be super helpful.

AlcaDesign commented 6 years ago

tmi.js will auto-populate the emotesets property with the "https://api.twitch.tv/kraken/chat/emoticon_images" endpoint for the available emote sets sent by Twitch and will keep it relatively up-to-date. client.emotesets is an object with each property being a set ID. Each of these points to an array of emote objects with an ID and a string.

ex:

{
    "0": [
        { "id": 973, "code": "DAESuppy" },
        { "id": 15, "code": "JKanStyle" },
        { "id": 16, "code": "OptimizePrime" },
        { "id": 17, "code": "StoneLightning" }
    ]
}

Every user has access to set 0; subscriptions, special emote sets, etc. may contain 1 or more emotes. You will need to check all text for every emote code. Note that some codes, especially in set 0, will be a regular expression string. (Smilies and whatnot)

See: Get Chat Emoticons by Set client.prototype._updateEmoteset